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.

Download the SDK

Download

Prerequisites

Run Apryse SDK in production

A commercial license key is required for use in a production environment. Please contact sales to purchase a commercial key or if you need any other license key assistance.

Keep your commercial license key confidential.

License keys are uniquely generated. Please make sure that it is not publicly available (e.g. in your public GitHub).

Running PDFTron Go in your project

  1. Create a directory for your project and a main.go file within. Add the following code to your main.go.

Go

1package main
2
3import (
4 . "github.com/pdftron/pdftron-go/v2"
5)
6
7
8func main() {
9 PDFNetInitialize("YOUR_APRYSE_LICENSE_KEY");
10 doc := NewPDFDoc()
11 page := doc.PageCreate() // Start a new page
12 doc.PagePushBack(page) // Add the page to document
13 doc.Save("output.pdf", uint(SDFDocE_linearized)); // Save the document as a linearized PDF
14 doc.Close()
15}
  1. Initialize your go.mod

Bash

1go mod init
  1. Fetch the dependencies for your project.

Bash

1go get
  1. Set your PATH to point to the shared libraries in pdftron-go in your current command shell. Replace your_version with the version of pdftron-go you are running.

sh

1set PATH=%PATH%;%GOPATH%/pkg/mod/github.com/pdftron/pdftron-go/v2@your_version/shared_libs/win/Lib

Or in your powershell

sh

1$env:PATH += ';$env:GOPATH/pkg/mod/github.com/pdftron/pdftron-go/v2@your_version/shared_libs/win/Lib'

You may also copy the DLL files from the above path to the same place as your project executable.

  1. Run your created application.

Bash

1go run main.go

Running PDFTron Go samples

  1. 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

  1. Navigate to the ./samples directory and modify the runall_go.bat and set your LICENSE_KEY. If using Apryse modules such as CAD, MODULE_PATH to the directory where your modules are stored.
  2. 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

sh

1PDFNet is running in demo mode.
2Permission: write
3Done!

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.

sh

1go mod edit -require github.com/pdftron/pdftron-go/v2@v2.0.0`
2go get

Next steps

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales