> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/get-started/languages/go.md).

# Go PDF library integration

Welcome to Apryse. Get started with the Apryse SDK for Windows, Linux, and macOS. Integrate the SDK into Go applications with Apryse modules like CAD. Download now! The Apryse Server SDK streamlines s

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.

{% tabs %}
{% tab title="Windows" %}

## Windows Go library integration

This guide will help you [run Apryse samples](#running-apryse-go-samples) and [integrate the Apryse SDK into Go applications](/core/get-started/download.md) on Windows. Your free trial includes unlimited trial usage and support from solution engineers.

{% @apryse-download-button/apryse-download-button id="Go\_SDK\_core\_linux" showVersion="true" %}

## Prerequisites

* [Go (>= 1.15)](https://golang.org/doc/install/)
* [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)

{% hint style="info" %}
**Run Apryse SDK in production**

A commercial license key is required for use in a production environment. Please [contact sales](https://apryse.com/form/contact-sales) to purchase a commercial key or if you need any other license key assistance.
{% endhint %}

{% hint style="warning" %}
**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).
{% endhint %}

## Running Apryse 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`:

{% code lineNumbers="true" %}

```go
package main

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


func main() {
    PDFNetInitialize("YOUR_APRYSE_LICENSE_KEY");
    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()
}
```

{% endcode %}

2. Initialize your `go.mod`:

{% code lineNumbers="true" %}

```bash
go mod init
```

{% endcode %}

3. Fetch the dependencies for your project:

{% code lineNumbers="true" %}

```bash
go get
```

{% endcode %}

4. 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:

{% code lineNumbers="true" %}

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

{% endcode %}

Or in powershell:

{% code lineNumbers="true" %}

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

{% endcode %}

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

5. Set the CGO\_ENABLED environment variable to 1:

{% code lineNumbers="true" %}

```bash
set CGO_ENABLED=1
```

{% endcode %}

Or in powershell:

{% code lineNumbers="true" %}

```bash
$env:CGO_ENABLED="1"
```

{% endcode %}

6. Install a C compiler, like MinGW, TDM-GCC, LLVM/Clang, or MSVC, and add its location to your PATH.
7. Set the CC environment variable to the C compiler you installed. For MinGW/TDM-GCC, its "gcc". For LLVM/Clang, its "clang". For MSVC, its "cl.exe".

{% code lineNumbers="true" %}

```bash
set CC="gcc"
```

{% endcode %}

Or in powershell:

{% code lineNumbers="true" %}

```bash
$env:CC="gcc"
```

{% endcode %}

7. Run your created application:

{% code lineNumbers="true" %}

```bash
go run main.go
```

{% endcode %}

## Running Apryse 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`

{% code lineNumbers="true" %}

```sh
PDFNet is running in demo mode.
Permission: write
Done!
```

{% endcode %}

Output files will be created in `./TestFiles/Output`

## Running a specific version of Apryse Go

This can be done by modifying your go.mod via this command in your project directory.

{% code lineNumbers="true" %}

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

{% endcode %}

## Next steps

<a href="https://github.com/iKettles/apryse-gitbook/tree/main/core/guides/README.md" class="button primary">Guides</a><a href="/core/get-started/samples.md" class="button primary">Samples</a>
{% endtab %}

{% tab title="Linux" %}

## Linux Go 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

{% @apryse-download-button/apryse-download-button id="Go\_SDK\_core\_linux" showVersion="true" %}

## Prerequisites

* [Go (>= 1.15)](https://golang.org/doc/install/)
* [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)

{% hint style="info" %}
**Run Apryse SDK in production**

A commercial license key is required for use in a production environment. Please [contact sales](https://apryse.com/form/contact-sales) to purchase a commercial key or if you need any other license key assistance.
{% endhint %}

{% hint style="warning" %}
**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).
{% endhint %}

## 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`.

{% code lineNumbers="true" %}

```go
package main

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


func main() {
    PDFNetInitialize("YOUR_APRYSE_LICENSE_KEY");
    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()
}
```

{% endcode %}

1. Initialize your `go.mod`

{% code lineNumbers="true" %}

```bash
go mod init
```

{% endcode %}

1. Fetch the dependencies for your project.

{% code lineNumbers="true" %}

```bash
go get
```

{% endcode %}

1. Run your created application.

{% code lineNumbers="true" %}

```bash
go run main.go
```

{% endcode %}

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

{% code lineNumbers="true" %}

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

{% endcode %}

## Next steps

<a href="https://github.com/iKettles/apryse-gitbook/tree/main/core/guides/README.md" class="button primary">Guides</a><a href="/core/get-started/samples.md" class="button primary">Samples</a>
{% endtab %}

{% tab title="macOS" %}

## macOS Go library integration

This guide will help you [run Apryse samples](#running-pdftron-go-samples-1) and [integrate the Apryse SDK into Go applications](/core/get-started/download.md) on macOS. Your free trial includes unlimited trial usage and support from solution engineers.

Download the SDK

{% @apryse-download-button/apryse-download-button id="Go\_SDK\_core\_mac" showVersion="true" %}

## Prerequisites

* [Go (>= 1.15)](https://golang.org/doc/install/)
* [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)

{% hint style="info" %}
**Run Apryse SDK in production**

A commercial license key is required for use in a production environment. Please [contact sales](https://apryse.com/form/contact-sales) to purchase a commercial key or if you need any other license key assistance.
{% endhint %}

{% hint style="warning" %}
**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).
{% endhint %}

## 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`.

{% code lineNumbers="true" %}

```go
package main

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

func main() {
    PDFNetInitialize("YOUR_APRYSE_LICENSE_KEY");
    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()
}
```

{% endcode %}

1. Initialize your `go.mod`

{% code lineNumbers="true" %}

```bash
go mod init
```

{% endcode %}

1. Fetch the dependencies for your project.

{% code lineNumbers="true" %}

```bash
go get
```

{% endcode %}

1. Run your created application.

{% code lineNumbers="true" %}

```bash
go run main.go
```

{% endcode %}

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

{% code lineNumbers="true" %}

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

{% endcode %}

## Next steps

<a href="https://github.com/iKettles/apryse-gitbook/tree/main/core/guides/README.md" class="button primary">Guides</a><a href="/core/get-started/samples.md" class="button primary">Samples</a>
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/core/get-started/languages/go.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
