Go PDF library integration
Welcome to Apryse. Go for the Apryse SDK is cross-platform and supported on Windows, Linux and macOS. To get started, choose your preferred platform from the tabs below.
Windows Go library integration
This guide will help you run Apryse samples and integrate the Apryse SDK into Go applications on Windows. Your free trial includes unlimited trial usage and support from solution engineers.
Prerequisites
Running Apryse Go in your project
Create a directory for your project and a
main.gofile within. Add the following code to yourmain.go:
package main
import (
. "github.com/pdftron/pdftron-go/v2"
)
func main() {
PDFNetInitialize("YOUR_APRYSE_LICENSE_KEY");
doc := NewPDFDoc()
page := doc.PageCreate() // Start a new page
doc.PagePushBack(page) // Add the page to document
doc.Save("output.pdf", uint(SDFDocE_linearized)); // Save the document as a linearized PDF
doc.Close()
}Initialize your
go.mod:
Fetch the dependencies for your project:
Set your PATH to point to the shared libraries in
pdftron-goin your current command shell. Replaceyour_versionwith the version ofpdftron-goyou are running:
Or in powershell:
You may also copy the .dll files from the above path to the same place as your project executable.
Set the CGO_ENABLED environment variable to 1:
Or in powershell:
Install a C compiler, like MinGW, TDM-GCC, LLVM/Clang, or MSVC, and add its location to your PATH.
Set the CC environment variable to the C compiler you installed. For MinGW/TDM-GCC, its "gcc". For LLVM/Clang, its "clang". For MSVC, its "cl.exe".
Or in powershell:
Run your created application:
Running Apryse Go samples
Navigate to your go path where you installed the library, and search for our repository. It may be within this path based on your version of Golang.
$GOPATH/pkg/mod/github.com/pdftron/pdtron-go/v2@version
Navigate to the
./samplesdirectory and modify therunall_go.batand set yourLICENSE_KEY. If using Apryse modules such as CAD,MODULE_PATHto the directory where your modules are stored.Run the
runallgo.bat. All sample tests will be run. a. If you wish to run a specific test, this can be done by specifying the test./runall_go.bat AddImageTest
Output files will be created in ./TestFiles/Output
Running a specific version of Apryse Go
This can be done by modifying your go.mod via this command in your project directory.
Next steps
Linux Go library integration
This guide will help you run Apryse samples and integrate the Apryse SDK into Go applications on Linux. Your free trial includes unlimited trial usage and support from solution engineers.
Download the SDK
Prerequisites
Running PDFTron Go in your project
Create a directory for your project and a
main.gofile within. Add the following code to yourmain.go.
Initialize your
go.mod
Fetch the dependencies for your project.
Run your created application.
Running PDFTron Go samples
Navigate to your go path where you installed the library, and search for our repository. It may be within this path based on your version of Golang.
$GOPATH/pkg/mod/github.com/pdftron/pdtron-go/v2@version
Navigate to the
./samplesdirectory and modify therunall_go.shand set yourLICENSE_KEY. If using Apryse modules such as CAD,MODULE_PATHto the directory where your modules are stored.Run the
runall_go.sh. All sample tests will be run. a. If you wish to run a specific test, this can be done by specifying the test./runall_go.sh AddImageTest
Output files will be created in ./TestFiles/Output
Running a specific version of PDFTron Go
This can be done by modifying your go.mod via this command in your project directory.
Next steps
macOS Go library integration
This guide will help you run Apryse samples and integrate the Apryse SDK into Go applications on macOS. Your free trial includes unlimited trial usage and support from solution engineers.
Download the SDK
Prerequisites
Running PDFTron Go in your project
Create a directory for your project and a
main.gofile within. Add the following code to yourmain.go.
Initialize your
go.mod
Fetch the dependencies for your project.
Run your created application.
Running PDFTron Go samples
Navigate to your go path where you installed the library, and search for our repository. It may be within this path based on your version of Golang.
$GOPATH/pkg/mod/github.com/pdftron/pdtron-go/v2@version
Navigate to the
./samplesdirectory and modify therunall_go.shand set yourLICENSE_KEY. If using Apryse modules such as CAD,MODULE_PATHto the directory where your modules are stored.Run the
runall_go.sh. All sample tests will be run. a. If you wish to run a specific test, this can be done by specifying the test./runall_go.sh AddImageTest
Output files will be created in ./TestFiles/Output
Running a specific version of PDFTron Go
This can be done by modifying your go.mod via this command in your project directory.
Next steps
Last updated
Was this helpful?