Some test text!

Search
Hamburger Icon

Linux / Guides / Go

Go & Linux PDF 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

Run Apryse SDK in production
A commercial license key is required for use in a production environment. Please fill out our licensing form if you do not have a valid license key.
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.
package main

import (
    . "github.com/pdftron/pdftron-go/v2"
)


func main() {
    PDFNetInitialize("myLicenseKey");
    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()
}
  1. Initialize your go.mod
go mod init
  1. Fetch the dependencies for your project.
go get
  1. Run your created application.
go 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.sh 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 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.

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

Next steps

Guides Samples

Get the answers you need: Chat with us