Some test text!


Get started with Go (C Interface Binding)

Welcome to PDFTron. You can start working with Go (C Interface Binding) from scratch, or integrate it into an existing application.

Existing Go (C Interface Binding) project & Windows PDF library integration

This guide will help you integrate a free trial of the PDFTron SDK with Go using PDFTron Headers on macOS with an existing Go app to create a new PDFDoc.


  • Go 1.6+

    Make sure Go is part of your path variable.

  • PDFTron Golang PDF library for Windows

No trial license key required.
The trial of PDFTron SDK works without a license key. 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).

linkIntegrate PDFTron SDK with Go

Start by adding these lines to the beginning of your .go file:

// #cgo CFLAGS: -Ipath/to/your/download/PDFNetC64/Headers
// #cgo LDFLAGS: -Lpath/to/your/download/PDFNetC64/Lib -Wl,-rpath,$$ORIGIN/PDFNetC64/Lib -lPDFNetC

Before calling other PDFTron API, you must initialize PDFNet. The PDFNet initialize header is found in C/PDF/TRN_PDFNet.h and the PDFDoc header is found in C/PDF/TRN_PDFDoc.h. Include both at the beginning of your .go file:

// #include "C/PDF/TRN_PDFNet.h"
// #include "C/PDF/TRN_PDFDoc.h"

Also import the unsafe library:

import (

Then initialize PDFNet by calling these lines:

// Declare a license key and convert it to CString
ccp := C.CString("Insert commercial license key here after purchase");
// Initialize PDFNet
// Free the memory used for the license key;

To create a new PDFDoc in Go, you must allocate memory for it and handle freeing the memory associated with it.

You can follow these steps to instantiate a PDFDoc:

// Declare a pointer for the PDFDoc.
var doc *C.TRN_PDFDoc;

// Get the size of the type using the pointer and allocate that amount of memory using malloc,
// then typecast void pointer returned by malloc to the required type explicitly.
doc = (*C.TRN_PDFDoc)(C.malloc(C.size_t(unsafe.Sizeof(*doc))));

// Call `TRN_PDFDocCreate` on the pointer to create the PDFDoc.

To deallocate the memory used by the PDFDoc, you can use;

linkNext step

GuidesAPI docsSamples

Get the answers you need: Support


Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.

Join our live demo to learn about use cases & capabilities for WebViewer

Learn more