Some test text!

Loading...
Guides
Go

Go & Windows PDF library integration

This guide will help you run PDFTron samples and integrate the PDFTron SDK into Go applications on Windows. Your free trial includes unlimited trial usage and support from solution engineers.

Prerequisites

Mingw-w64 requirements
During installation, the default option will be i686 but this must be set to x86_64 in order to install the 64-bit version of this software.
Run PDFTron 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).

Initial setup

  1. Run our Windows Go installer script located on github:
# Download the batch file or use curl from the command line
curl https://raw.githubusercontent.com/PDFTron/pdftron-go/main/RunSampleWindows.bat -o RunSampleWindows.bat

# Double-click RunSampleWindows.bat or run the batch file from the command line
start RunSampleWindows.bat
  1. Get your PDFTron trial key.
Loading...

If your OS or Go version is not supported, the installation will fail.

Run the samples

  1. Open a command line console
  2. Change the directory to the samples folder
  3. Run all samples:
cd %HOMEPATH%\go\src\pdftron\Samples\
runall_go.bat

You can also enter any individual sample folder to run them separately. For example, here's how to run the AddImageTest sample:

cd %HOMEPATH%\go\src\pdftron\Samples\AddImageTest\GO
RunTest.bat

Integrate into your application

This section will show you how to use our SDK to create a simple PDFTron "Hello World!" application. It will create a document with one blank page and save it as a linearized PDF in its running directory.

  1. Navigate into your /Samples directory and make a new directory called myApp (if it does not exist already). This guide will assume your application is named myApp. For organization, create a new directory inside myApp called GO.

  2. Navigate inside that GO directory and create a new GO file called myApp.go. Open it with your favorite text editor and paste this into it:

//@data {"ga":2375600232}// package main import ( "fmt" . "pdftron" )

func main(){
    PDFNetInitialize()           // PDFNet must be initialized before accessing any PDFTron API
    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()
}
```

Run your application by executing `go run myApp.go`. Make sure that your interpreter can find the PDFNetC library. If all goes well, your console should output:

```

//@data {"ga":8778353426}// PDFNet is running in demo mode. Permission: write Hello World! ```

Check the output.pdf that the program output in the same directory. It should be a PDF with one blank page.

Next step

Guides Samples

Get the answers you need: Support