Some test text!
Core / Guides
This guide will help you integrate a free trial of the Apryse SDK with Go using Apryse Headers on macOS, Linux or Windows in a new Go app. (Or see instructions for incorporation with an existing project .) Your free trial includes unlimited trial usage and support from solution engineers.
macOS
Windows
Linux
Make sure Go is installed at /usr/local/go
and /usr/local/go/bin
.
Apryse collects some data regarding your usage of the SDK for product improvement.
If you wish to continue without data collection, contact us and we will email you a no-tracking trial key for you to get started.
Create a project directory called myApp
.
Extract the PDFNetCMac
package as a folder into your project directory.
~/myApp
~/myApp/PDFNetCMac
~/myApp/PDFNetCMac/Headers
~/myApp/PDFNetCMac/Lib
...
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 (
"fmt";
"unsafe"
)
func main() {
// PDFNet must be initialized before calling other Apryse API
ccp := C.CString("YOUR_DEMO_KEY")
C.TRN_PDFNetInitialize(ccp)
// Create a new PDFDoc
var doc *C.TRN_PDFDoc
doc = (*C.TRN_PDFDoc)(C.malloc(C.size_t(unsafe.Sizeof(*doc))))
C.TRN_PDFDocCreate(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.TRN_UStringCreateFromCharString(C.CString("output.pdf"), C.int(10),
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:
~/myApp
~/myApp/PDFNetCMac
~/myApp/PDFNetCMac/Headers
~/myApp/PDFNetCMac/Lib
...
~/myApp/myApp.go
In the project folder, run:
go build
This will produce a myApp
executable file.
Run the executable file. The executable will produce a pdf with a blank page in a linearized format.
You can generate bindings for Apryse 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\
.
Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales