Skip to main content

Go Client Library for DynamicPDF API


The DynamicPDF API provides a full‑featured client library for GO that simplifies integration with the REST endpoints.
The Go client library is the official SDK for integrating the DynamicPDF API into Go applications. It provides idiomatic Go types and methods that make it easy to generate new PDF documents, convert HTML and images to PDF, merge multiple PDFs, extract text and metadata, and perform detailed PDF inspection without having to construct raw HTTP requests.

This library gives developers access to the complete set of DynamicPDF API capabilities, including creating PDFs from code, merging or splitting existing documents, filling and flattening interactive forms, stamping text or images onto pages, retrieving XMP and document information, rasterizing PDF pages into images, and applying encryption or other security options. The DynamicPDF API offers an extensive collection of PDF focused endpoints that support generation, conversion, manipulation, analysis, and secure delivery of PDF content directly from Go applications.

The DynamicPDF API offers clean, intuitive wrappers around the following REST endpoints:

  • dlex-layout for creating dynamic PDF reports from DLEX templates and JSON data,
  • image-info for extracting detailed metadata from images,
  • pdf for creating and manipulating PDFs, merging documents, and converting HTML, Word, and Excel files to PDF,
  • pdf-info for retrieving document information and metadata from existing PDFs,
  • pdf-security-info for obtaining PDF encryption details and security settings,
  • pdf-text for extracting text content from PDF pages, and
  • pdf-xmp for reading embedded XMP metadata from PDF files.

Installation

The DynamicPDF API library is available using the Go Package Manager (https://pkg.go.dev/github.com/dynamicpdf-api/go-client).

go get github.com/dynamicpdf-api/go-client@latest

Source & Repo

Usage Example

func main() {
pr := endpoint.NewPdf()
pr.Endpoint.ApiKey = apiKey
pdfResource := resource.NewPdfResourceWithResourcePath("DocA.pdf", "DocA.pdf")
prInput := input.NewPdfWithResource(pdfResource)
pr.Inputs = append(pr.Inputs, prInput)
pdfResource2 := resource.NewPdfResourceWithResourcePath("DocB.pdf", "DocB.pdf")
prInput2 := input.NewPdfWithResource(pdfResource2)
pr.Inputs = append(pr.Inputs, prInput2)
resp := pr.Process()
res := <-resp
os.WriteFile("output.pdf", res.Content().Bytes(), os.ModeType)
}
Source: merge-pdfs.go