PDF Library Features
PDF Library Features
This page summarises the major feature areas in Aspose.PDF FOSS for Go. Each section links to dedicated developer-guide pages with complete code examples.
Document Management
Document is the central type. It supports opening (Open, OpenWithPassword),
creating (NewDocument), saving (Save), and operating on page collections
(Split, Append, Extract, PageCount). SetMetadata and Metadata provide
read/write access to Info dictionary fields.
doc, _ := pdf.Open("input.pdf")
pages, _ := doc.Split()
fmt.Printf("Split into %d pages\n", len(pages))Security and Encryption
EncryptionOptions configures password-based encryption in a single call to
Document.SetEncryption. Supported algorithms: AES-128 (default), AES-256
(ISO 32000-2 / PDF 2.0), and RC4-128. Permissions controls individual
operations — print, copy, accessibility — independently.
doc, _ := pdf.Open("doc.pdf")
doc.SetEncryption(pdf.EncryptionOptions{
UserPassword: "user",
OwnerPassword: "owner",
Permissions: &pdf.Permissions{AllowPrint: true},
})
doc.Save("doc_secured.pdf")AcroForm Processing
Document.Form returns a *Form providing access to all fields. Type
assertions expose the specific field types: TextBoxField, CheckboxField,
RadioButtonField, ComboBoxField, ListBoxField, and ButtonField.
Field values are written; appearances are regenerated automatically by PDF viewers.
doc, _ := pdf.Open("form.pdf")
text := doc.Form().Field("name").(*pdf.TextBoxField)
text.SetValue("Jane Doe")
doc.Save("form_filled.pdf")Table Layout
Table, Row, and Cell build grid layouts positioned on pages. BorderInfo
sets border styles per cell or for the whole table. MarginInfo sets padding.
TextStyle, Font, Color, HAlign, and VAlign control text presentation.
Bookmarks and Navigation
OutlineItemCollection represents a single bookmark. Configure title, bold/italic
style, link color, and destination (DestinationXYZ, DestinationFit,
DestinationFitH). Nested bookmarks build a chapter/section hierarchy.
NamedDestinations provides reusable page targets accessible by name.
Annotations
AnnotationCollection holds all annotations on a page. Available types include
TextAnnotation, FreeTextAnnotation, StampAnnotation, HighlightAnnotation,
LinkAnnotation, RedactAnnotation, InkAnnotation, LineAnnotation,
SquareAnnotation, and CircleAnnotation.
Image Handling
Image represents an embedded image resource. ImageInfo exposes dimensions and
color space. Images can be added to pages directly or embedded in table cells.
OptimizeImageOptions provides compression parameters for file size reduction.
Rendering to Image
BmpDevice, PngDevice, JpegDevice, GifDevice, and TiffDevice render
individual PDF pages to raster images. Each device is constructed with a
Resolution value and exposes a Render* method that writes the output to
an io.Writer. RenderOptions controls rendering parameters — output resolution (DPI) and background colour.
doc, _ := pdf.Open("report.pdf")
page, _ := doc.Page(1)
dev := pdf.NewPngDevice(pdf.Resolution{DPI: 150})
f, _ := os.Create("page1.png")
defer f.Close()
dev.Process(page, f)Text Search
SearchText accepts a query string and SearchOptions and returns a slice of
TextMatch results. Each TextMatch exposes the matched text, its bounding
box on the page, and the page index where it was found.
doc, _ := pdf.Open("report.pdf")
matches, _ := doc.SearchText("invoice", pdf.SearchOptions{CaseInsensitive: true})
for _, m := range matches {
fmt.Printf("Found %q on page %d\n", m.Text, m.PageNumber)
}Form Flattening
Document.Flatten converts all interactive form fields to static content.
Field values are baked into the page graphics and the form fields are removed,
producing a PDF that cannot be edited.
doc, _ := pdf.Open("form_filled.pdf")
doc.Flatten()
doc.Save("form_flat.pdf")API Reference Summary
| Type | Purpose |
|---|---|
Document | Core document container — open, create, save, split, merge |
Page | Single page access — size, annotations, content |
Form | AcroForm container — field enumeration and access |
Table | Grid layout element |
EncryptionOptions | Password and algorithm configuration |
Permissions | Per-operation access control flags |
OutlineItemCollection | Bookmark tree node |
AnnotationCollection | Page annotation container |
Metadata | Info dictionary read/write |
Image | Embedded image resource |
BmpDevice | Render PDF page to BMP |
PngDevice | Render PDF page to PNG |
JpegDevice | Render PDF page to JPEG |
TiffDevice | Render PDF page to TIFF |
GifDevice | Render PDF page to GIF |
RenderOptions | Render parameters — DPI and background colour |
SearchOptions | Text search configuration |
TextMatch | Single text search result with bounding box |
LinearGradient | Linear gradient fill for vector shapes |
RadialGradient | Radial gradient fill for vector shapes |