Skip to content
gotenbergPublic

Repository files navigation

litho Logo

litho

A pure-Go PDF Conforming Processor

Continuous Integration Go Reference


litho is a pure-Go PDF Conforming Processor. Read, validate, remediate, and produce PDF documents with no C dependencies.

litho implements ISO 32000 (PDF 1.4 through 2.0). It extracts text and structured content, validates against PDF/A, PDF/UA, WTPDF, Factur-X and ZUGFeRD, repairs non-conformant files, and edits, renders, encrypts and signs them.

Install

go get github.com/gotenberg/litho
go install github.com/gotenberg/litho/cmd/litho@latest

Go 1.27.3+. No CGO.

Prebuilt litho binaries for Linux (amd64, arm64, 386, armv7, ppc64le, riscv64, s390x, loong64), macOS, FreeBSD and Windows (amd64, arm64) ship with each GitHub release. On Linux, macOS and FreeBSD, the install script downloads one, verifies its checksum and installs it in /usr/local/bin:

curl -fsSL https://raw.githubusercontent.com/gotenberg/litho/main/install.sh | sh

Set LITHO_VERSION=v1.2.3 to pin a release and LITHO_INSTALL_DIR to install elsewhere.

Quick start

r, err := pdf.OpenFile(ctx, "input.pdf")
if err != nil {
	log.Fatal(err)
}
defer r.Close()

violations, err := r.ValidatePDFAReport(ctx, models.PDFA2b)
litho validate --profile PDF/A-2b document.pdf
litho remediate --profile PDF/A-2b --font-dir /usr/share/fonts -o fixed.pdf document.pdf
litho sign --cert cert.pem --key key.pem --reason Approved -o signed.pdf document.pdf

Run litho with no arguments to list every subcommand, or litho <command> -h to see its flags.

Features

  • Extract text with layout inference, positioned text, tables, images decoded to sRGB, annotations, form fields, bookmarks, attachments, and PDF 2.0 data (geospatial, measurements, 3D, formulas).
  • Validate PDF/A (every part and level), PDF/UA-1 and UA-2, WTPDF 1.0, Factur-X and ZUGFeRD, with the clause, test number and severity of each violation.
  • Remediate PDF/A, PDF/UA and WTPDF violations, embedding the fonts you supply, behind an integrity check that rolls back a fix that degrades the document.
  • Edit pages (rotate, delete, insert, split, merge), stamps and watermarks, metadata, form fields, bookmarks and attachments, auto-tagging, redaction, colour conversion and transparency flattening.
  • Render pages to images, on screen or for print, RGB or CMYK.
  • Protect with RC4, AES-128 or AES-256 encryption, and PKCS#7 or PAdES signatures up to B-LTA.
  • Optimize with object streams, stream deduplication, lossless image recompression and font subsetting.
  • Stay safe on hostile input: configurable resource limits, no panics, deterministic output.

Documentation

  • Library reference: Reader opens and extracts, Writer queues edits and writes, Pipeline chains them.
  • Examples: runnable programs for common tasks.
  • CLI reference: global flags, exit status, encrypted documents.

Contributing

License

litho is licensed under the GNU Affero General Public License v3.0.

Gotenberg embeds litho and ships it under the MIT License, as its copyright owner allows. Contributors sign the Contributor License Agreement, which grants that right for their contributions. Any other use of litho follows the AGPL-3.0.

Acknowledgments

litho's text extraction, CMap handling and font resolution draw on Mozilla's PDF.js. Its PDF/A, PDF/UA and WTPDF rule set and clause numbering follow veraPDF.

Releases

Sponsor this project

Used by

Contributors

Languages