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.

New Go (C Interface Binding) project & macOS PDF library integration

This guide will help you integrate a free trial of the PDFTron SDK with Go using PDFTron Headers on macOS. Your free trial includes unlimited trial usage and support from solution engineers.


  • Go 1.6+

    Make sure Go is installed at /usr/local/go and /usr/local/go/bin.

  • PDFTron SDK for macOS

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


  1. Create a project directory called myApp.
  2. Extract the PDFNetCMac package as a folder into your project directory.


linkIntegrate PDFTron SDK with Go

  1. In your project directory, create a new file called myApp.go

    Add the following code inside:

    package main
    // #cgo CFLAGS: -IPDFNetCMac/Headers
    // #cgo LDFLAGS: -LPDFNetCMac/Lib -Wl,-rpath,PDFNetCMac/Lib -lPDFNetC
    // #include "C/PDF/TRN_PDFNet.h"
    // #include "C/SDF/TRN_SDFDoc.h"
    // #include "C/PDF/TRN_PDFDoc.h"
    // #include "C/PDF/TRN_Page.h"
    // #include "C/Common/TRN_UString.h"
    // #include "C/Common/TRN_Types.h"
    // #include <stdlib.h>
    // #include <stdio.h>
    import "C"
    import (
    func main() {
        // PDFNet must be initialized before calling other PDFTron API
        ccp := C.CString("YOUR_DEMO_KEY")
        // Create a new PDFDoc
        var doc *C.TRN_PDFDoc
        doc = (*C.TRN_PDFDoc)(C.malloc(C.size_t(unsafe.Sizeof(*doc))))
        // Allocate memory for a blank page
        var page *C.TRN_Page
        page = (*C.TRN_Page)(C.malloc(C.size_t(unsafe.Sizeof(*page))))
        // Allocate memory for a default rectangle
        var box *C.TRN_Rect
        box = (*C.TRN_Rect)(C.malloc(C.size_t(unsafe.Sizeof(*box))))
        // Create the page and add it to the document
        C.TRN_PDFDocPageCreate(*doc, box, page)
        C.TRN_PDFDocPagePushBack(*doc, *page)
        // Save the document as a linearized PDF
        var filepath C.TRN_UString
        C.e_UString_utf8, &filepath)
        C.TRN_PDFDocSave(*doc, filepath, 0);
        fmt.Println("Hello World!");

    Save and close the file.

    Your folder should look similar to:

  2. In the project folder, run:

    go build

    This will produce a myApp executable file.

  3. Run the executable file. The executable will produce a pdf with a blank page in a linearized format.
Want to generate your own bindings?

You can generate bindings for PDFTron SDK APIs using various methods. It is recommended to use SWIG to generate these bindings. The header files to include can be found in PDFNET_BASE\Headers\ and the library can be found in PDFNET_BASE\Lib\.

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