Skip to content
Guides

Guides

The first thing to settle is whether you are building a document from nothing or working on one that already exists. The two use different halves of the library and barely overlap.

Creating means the creator package: you make a Creator, add components to it, and write the result. Reading and modifying means model: you open a PdfReader, and either pull data out through extractor or write changes back through a PdfWriter or a PdfAppender.

New to UniPDF? Start with the getting started guide to get an API key and a working environment.

Create a document

Building a PDF with the creator package.

SectionCovers
TablesCell-by-cell tables: alignment, spans, borders, header rows, page-break behavior.
GridThe newer tabular component. Explicit rows, and an error rather than a silent reflow when a row overfills.
Text manipulationStyled paragraphs, drop caps, right-to-left text, gradient fills.
DrawingLines and shapes.
ImagesPlacing images, and building a document from a set of them.
TemplatesMarkup-driven layout: write the design in a .tpl file and supply resources from Go.
ReportMulti-page reports and invoices: chapters, generated tables of contents, running headers and footers.

Grid is usually the better pick over Table for new work, for the reasons on its section page. Templates keep layout out of your Go code, which matters if a designer owns the design.

Read and extract

Getting data out of an existing document.

SectionCovers
ExtractionText, tables, images and fonts, and choosing an extraction mode.
AnalysisInspecting PDF internals: objects, content streams, document properties.
OCRText from scanned pages. Needs a separate OCR service running, not just the library.
ConversionRendering pages to images.

If extraction output looks wrong, the extraction mode is the first thing to change rather than the last. Text extraction compares the four.

Modify an existing document

Opening a document and writing changes back.

SectionCovers
Page manipulationMerging, splitting, reordering, rotating, cropping, flattening.
AnnotationsComments, shapes and file attachments layered on top of page content.
FormsReading, filling and flattening AcroForm fields.
MetadataThe document info dictionary and XMP, which are two separate systems.
OutlinesReading and writing the bookmark tree.
AttachmentsEmbedding files in a document and retrieving them.
WatermarkStamping text or an image across pages.
RedactionRemoving text, with limits worth reading before you rely on it.
Search and replaceFinding text by pattern and substituting it.
PDF optimizationReducing file size, font subsetting, and linearization for fast web view.

Changes are written either by rebuilding the file through a PdfWriter or by appending an incremental update through a PdfAppender. The appender preserves the original bytes, which is what keeps existing signatures valid.

Sign and secure

SectionCovers
SignatureDigital signatures: PKCS12, external signing services, timestamps, LTV, PAdES levels, DocMDP, validation.
SecurityEncryption, passwords and permissions.

Standards and compliance

SectionCovers
PDF/AArchival conformance, parts 1 to 4, applying and validating.
AccessibilityTagged PDF and the structure tree, plus PDF/UA validation.

Performance

SectionCovers
ConcurrencyProcessing documents in parallel, and reading pages of one document across goroutines.

Notes on this listing

A few sections sit in more than one group in practice. Forms is listed under modifying a document, which is the common case, but create form builds one from nothing. Metadata is listed there too, and covers both reading and writing. The sidebar lists every section alphabetically if you would rather scan than be routed.

Last updated on