chinmay-sawant/gopdfsuit
Acerca de
GoPDFSuit: un motor PDF ultrarrápido (Gin Web + gopdflib + pypdfsuit).
Desarrollo web y de aplicacionesCrecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- -2
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
README.md
OriginalGoPdfSuit - three PDF engines, one repo
gopdfsuit (REST API), gopdflib (Go library), pypdfsuit (Python bindings). I built it to generate PDFs from JSON templates, with multi-page support, merge, form fill, and HTML to PDF or image.
I got tired of hosted PDF services that charge per page and hide the layout logic. This repo keeps the template in JSON where you can read it, and the engine runs in memory with no Ghostscript and no external calls. Compliance output is slower, and that tradeoff is real. The numbers below show both sides.
Star history
Performance and efficiency
Zerodha reference workload (5000 iterations, 48 workers, 80 percent retail, 15 percent active, 5 percent HFT), measured with x10 sequential runs on WSL2 (Intel i7-13700HX, Go 1.26.4, June 2026). See documentation/BENCHMARKS.md for the full suite.
| Harness | PDF/A | PDF/UA | x10 peak | x10 mean | x10 median | Avg latency | Peak alloc |
|---|---|---|---|---|---|---|---|
bench-gopdflib-zerodha (compliant) |
PDF/A-4 | PDF/UA-2 | 6,611 ops/s | 6,203 ops/s | 6,362 ops/s | 7.54 ms | 798 MB |
bench-gopdflib-zerodha-nocomply |
PDF 2.0 (no PDF/A) | None | 37,853 ops/s | 34,035 ops/s | 35,181 ops/s | 1.38 ms | 310 MB |
Compliant runs turn on PDF/A-4, PDF/UA-2, Arlington-compatible tagging, ECDSA P-256 signing, and font embedding (HFT output 2.29 MB, veraPDF 6/6 PASS). Non-compliant runs still output PDF 2.0 but skip PDF/A, tagging, signing, and font embedding to show the throughput ceiling (HFT output 221 KB).
Full compliance hits about 6,600 ops/s peak on one machine, up 150 percent from the June 2026 baseline at 2,646 ops/s. The same workload without compliance hits about 37,900 ops/s peak, 5.7 times faster.
Table of contents
Documentation
Start with the suite guide, then pick your surface:
- PDF suite guide - one detailed walkthrough: install, generate, compress, merge, split, HTML, redact, fill, limits, privacy
- Go library API - every
pkg/gopdflibop with copy-paste Go snippets - Python API - every
pypdfsuitfunction with copy-paste Python snippets (package README) - REST API - every
/api/v1/*endpoint with curl, auth, error envelope, caps - Engine overview - in-memory pipeline: decode, render, fonts, tagging, XMP, sign, encrypt
- Compress guide - Light/Medium/Heavy tiers, limits, passthrough rules
- HTML guide - pure-Go conversion fields, defaults, limits
- Document ops guide - merge, split page specs, XFDF fill, redact modes
- WASM frontend - local-first browser app, artifacts, consent, offline
- Compliance and benchmarks - PDF/A-4, PDF/UA-2, signatures, validation and bench commands
- Samples catalog - every
sampledata/directory with run commands - Template reference - JSON template format with examples
- Docs index - full map of
documentation/(truth) vsguides/(frozen archive) - Web documentation - interactive API docs and playground
- Makefile reference - build, test, and deployment commands
Quickstart
Go library:
go get github.com/chinmay-sawant/gopdfsuit/[email protected]
import "github.com/chinmay-sawant/gopdfsuit/v7/pkg/gopdflib"
b := gopdflib.NewDocument("A4", true)
b.AddTitle("Hello", gopdflib.WithTitleFontOpts(gopdflib.TitleFontOptions{Name: "Helvetica", Size: 18, Bold: true}))
pdfBytes, err := b.Generate()
See Go library API and suite guide.
Python bindings:
cd bindings/python && ./build.sh && pip install .
from pypdfsuit.builder import TemplateBuilder, Font
b = TemplateBuilder("A4", True)
b.add_title("Hello", font="Helvetica", size=18, bold=True)
pdf_bytes = b.generate()
See Python API and package README.
REST API (server on :8080):
docker run --rm -p 8080:8080 chinmaysawant/gopdfsuit:7.0.0
curl -X POST http://localhost:8080/api/v1/generate/template-pdf \
-H "Content-Type: application/json" \
--data-binary @template.json --output out.pdf
See REST API. Samples live in sampledata/ (catalog).
Overview
Three apps, one repo. Pick what fits your stack.
| Component | Type | Use case |
|---|---|---|
| gopdfsuit | Language-agnostic REST API | Run as a service. Call it from Go, Python, JS, curl, and others |
| gopdflib | Go library | Import github.com/chinmay-sawant/gopdfsuit/v7/pkg/gopdflib in your Go project |
| pypdfsuit | Python bindings | Use from pypdfsuit.builder import TemplateBuilder, Font. CGO wrapper around gopdflib |
Key features.
- Template-based generation. You send JSON, the engine returns PDF. It handles page breaks and flow across pages.
- Fluent builders. Go
gopdflib.NewDocument("A4", true)plusFont(...).Size(...).Cell(...)inpkg/gopdflib, mirrored by PythonTemplateBuilderinbindings/python/pypdfsuit/builder.py. Seedocumentation/BUILDER_FLUENT_GO.mdanddocumentation/PY_BUILDER_PARITY.md. - Security and compliance. PKCS#7 and X.509 signatures, AES-256 encryption, granular permissions, PDF/A-4 and PDF/UA-2 when you opt in.
- Advanced elements. Text styling, tables, barcodes, QR codes, SVG vector graphics, and interactive forms with checkboxes and radio buttons.
- Navigation. Bookmarks, internal links, and named destinations the engine wires up for you.
- Form filling. Fills AcroForms and XFDF data.
- Redaction. Redacts by coordinates or by text search.
- Merge and split. Combines PDFs or splits them by page ranges.
- PDF compress. Shrinks PDFs in gopdflib or in the browser with WASM. No Ghostscript, no server round trip. Light, Medium, and Heavy JPEG tiers. Default path is local-first:
compress.wasmon the Compress page,gopdfsuit.wasmelsewhere, server upload only after explicit consent. Seedocumentation/WASM_VIEWER_EDITOR.md. - HTML conversion. Turns HTML into PDF or image with pure-Go gowkhtmltopdf, no browser needed.
- Web interfaces. React UI for viewer, editor, merger, filler, and converters.
Requirements. Go 1.26.4, Make for build and test targets. HTML conversion is pure-Go, no Chrome needed. See Prerequisites for the full list.
Prerequisites
| Requirement | Version and notes |
|---|---|
| Go | 1.26.4, must match go.mod |
| Make | Needed for make build, make test, make run |
| HTML conversion | Pure-Go via gowkhtmltopdf, no browser needed |
| Node.js plus npm | Frontend build, Node 18 or later |
| Python 3.8 or later | Python bindings tests for pypdfsuit |
| Java 11 or later | Optional, only for veraPDF PDF/A-4 and PDF/UA-2 validation with make install-pdf-validators |
Windows
On Windows, use WSL. The project needs Make and Unix shell scripts, which PowerShell and CMD do not provide. See CONTRIBUTING.md for setup.
FAQ
Go version compatibility?
This project needs Go 1.26.4 to build and run. The go.mod directive says go 1.26.4, and CI uses Go 1.26.4.
Install the exact version.
# Using go install (if you use multiple Go versions)
go install golang.org/dl/go1.26.4@latest
go1.26.4 download
# Verify
go1.26.4 version
Go 1.26.4 brings faster GC, better goroutine scheduling, and hardware crypto. The code does not need new language features, but I only test the module and deps against 1.26.4.
For older toolchains, you can try editing the go directive in go.mod and running go mod tidy. That path is unsupported. Releases track Go 1.26.4.
HTML conversion needs Chrome?
No. HTML to PDF or image is pure-Go via gowkhtmltopdf. No browser install needed.
How do auto page breaks work?
The engine tracks Y position and starts a new page when content passes the bottom margin. It redraws page borders and keeps page numbers correct across pages.
How do I create a digitally signed PDF?
Pass your PEM certificate and private key in the signature config.
{
"config": {
"signature": {
"enabled": true,
"visible": true,
"certificatePem": "-----BEGIN CERTIFICATE-----\n...",
"privateKeyPem": "-----BEGIN PRIVATE KEY-----\n..."
}
}
}
The engine accepts RSA and ECDSA keys, with optional chains.
What is PDF/A-4 compliance?
PDF/A-4 is the archival standard built on PDF 2.0. Set "pdfaCompliant": true. The engine embeds Liberation fonts, adds XMP metadata, and enforces the structure rules needed for long term storage.
How do internal links work?
- Add a destination anchor to a cell:
"dest": "my-section" - Link to it from another cell:
"link": "#my-section" - Add a bookmark if you want sidebar navigation:
{"title": "My Section", "dest": "my-section"}
XFDF form filling limitations?
The filler sets /NeedAppearances true at the byte level. It covers most AcroForms. PDFs with compressed object streams may need pdfcpu for full compatibility.
Performance benchmarks?
I measured on Intel i7-13700HX (24 cores), WSL2, Go 1.26.4. Zerodha mix is 80 percent retail, 15 percent active, 5 percent HFT. All PDFs below use PDF/A-4 plus PDF/UA-2 except where noted. Retail signs with ECDSA P-256.
| Engine | Harness | Peak | Latest avg | Notes |
|---|---|---|---|---|
| gopdflib | Zerodha x10 (compliant) | 6,611 ops/s | 6,203 ops/s (x10, 2026-06-24) | PDF/A-4 plus PDF/UA-2, library in process |
| gopdflib | Zerodha x10 (nocomply) | 37,853 ops/s | 34,035 ops/s (x10, 2026-06-24) | PDF 2.0, compliance off |
| gopdfsuit | k6 tagged_ecdsa |
1,333 req/s | best-of-5 (2026-06-18) | HTTP plus Gin |
| pypdfsuit | Zerodha x10 (compliant) | 937 ops/s | 916 ops/s (x10, 2026-06-24) | PDF/A-4 plus PDF/UA-2, Python CGO |
| pypdfsuit | Zerodha x10 (nocomply) | 1,284 ops/s | 1,242 ops/s (x10, 2026-06-24) | PDF 2.0, compliance off |
| Gotenberg | k6 HTML to PDF | 16.1 req/s | best-of-5 (2026-06-18) | Chromium, no PDF/A |
Reproduce.
# gopdflib Zerodha reference (5000x48)
make bench-gopdflib-zerodha-x10
make bench-gopdflib-zerodha-nocomply-x10
# gopdfsuit (k6 plus Gin)
make bench-k6
# pypdfsuit (rebuild bindings first: cd bindings/python && ./build.sh)
make bench-pypdfsuit-zerodha-x10
make bench-pypdfsuit-zerodha-nocomply-x10
All processing runs in memory with zero external runtime deps.
Development
Windows users. Use WSL. Make and shell scripts are required. See Prerequisites.
# Build
make build
# or directly:
go build -o bin/gopdfsuit ./cmd/gopdfsuit
# Cross-compile
GOOS=linux GOARCH=amd64 go build -o bin/gopdfsuit-linux ./cmd/gopdfsuit
# Test
make test
# or:
go test -cover ./...
# Format and lint
make fmt && make lint
Project structure
gopdfsuit/
├── bindings/ # Native language bindings (Python CGO)
├── cmd/gopdfsuit/ # Application entrypoint
├── docs/ # Built frontend assets
├── frontend/ # React frontend (Vite)
├── guides/ # Documentation guides
├── internal/
│ ├── handlers/ # HTTP handlers
│ ├── middleware/ # Gin middleware
│ ├── models/ # Template models
│ └── pdf/ # PDF generation and processing
├── pkg/
│ └── gopdflib/ # Standalone Go library
├── sampledata/ # Sample templates and data
└── test/ # Integration tests
Contributing
See CONTRIBUTING.md for setup, workflow, testing, and pull request rules.
Quick start.
- Fork the repository
- Create a feature branch (
git checkout -b feat/my-feature) - Run
make fmt && make lint && make test - Commit and open a pull request
License
MIT License - see LICENSE
Made by Chinmay Sawant
Star this repo if it helped you ship a PDF faster.
Built from scratch with assistance from GitHub Copilot.
Explorar proyectos relacionados
Cargando…