Ana içeriğe geç
Bu sayfa henüz Türkçeye çevrilmedi; İngilizce sürümü gösteriliyor.
Versiyon: 0.1

Design and Comparison

This page summarises why pidief is built the way it is and how it compares with other PDF tools.

Goal​

One self-hosted tool, as a CLI and an HTTP API, that covers what business applications need from PDFs (contracts and documents from HTML templates, reports with long tables, statements, receipts, phone scans, previews, merge/split/rotate, watermarks, passwords, PDF/A), with no licensing traps.

Other tools at a glance​

ToolStrengthsGapsLicense notes
QuestPDF (.NET)Fluent C# layout, repeated table headers, PDF/ANo HTML/CSS input, no rasterizingCommunity license free only below USD 1M annual revenue
Gotenberg (Go)Chromium + LibreOffice behind REST, header/footer templates, wait conditionsLarge image (~1.5-2 GB), no PDF to image, no CLIMIT
PDFsharp / MigraDoc (.NET)Low-level PDF writing, mergeNo HTML, no rasterizingMoved to AGPL in 6.5
wkhtmltopdfSimple single binaryArchived in 2023, old WebKit, buggy table headersLGPL-3
WeasyPrint (Python)Strong CSS Paged Media, PDF/A, PDF/UANo JavaScript, partial flex/gridBSD-3
Playwright/Puppeteer (Chromium)Highest HTML/CSS/JS fidelity, header/footer templatesNo PDF/A, passwords or manipulationApache-2.0, Chromium BSD
pdfcpu (Go)Pure Go merge, split, rotate, watermark, encryptionNo rasterizing, no HTML, no PDF/AApache-2.0
qpdf (C++)Structural transforms, encryption, repairNo rasterizing, HTML or watermarksApache-2.0
GhostscriptPDF/A, downsampling, rasterizingHeavyAGPL-3 or commercial
Stirling-PDFWeb UI and API for every operationVery large (~1-2 GB), an application rather than a componentCore MIT, some features commercial
iText (Java/.NET)Very mature, PDF/A, PDF/UA, signatures—AGPL-3 or commercial
PDFiumChrome-quality rasterizing and text extractionNo layout or creationBSD-3 / Apache-2.0
MuPDF / PopplerFast rasterizing—AGPL / GPL

What pidief takes from each​

  • Gotenberg: the multipart API (a main index.html plus fonts, images and CSS uploaded next to it), waitForSelector / waitForExpression / waitDelay, header/footer templates, per-request timeouts, health endpoints and Prometheus metrics. pidief adds a small image (no LibreOffice), a CLI, PDF to image, watermarks, passwords, PDF/A-2b, one switch to block external resources, and reuse of one Chromium process.
  • Playwright/Chromium: the print engine itself.
  • WeasyPrint/QuestPDF: PDF/A-2b as an output option, metadata written at creation time, a ready-made "Sayfa X / Y" footer.
  • pdfcpu: the page selection syntax (1-3,5,!2, even, odd, l-1) and watermark/stamp parameters (position, scale, opacity, rotation).
  • PDFium: rasterizing (thumbnails, previews) and text extraction.
  • Stirling-PDF: "everything in one tool", but as a service or component without a UI.

Why Go​

Mature, permissively licensed PDF manipulation (pdfcpu, Apache-2.0) and rasterizing (PDFium as WebAssembly, run from pure Go) both exist in Go without cgo. That means the same static binary can be built for linux/amd64 and linux/arm64, with low memory use and Chromium control through chromedp.

Architecture​

            ┌──────────── pidief (single Go binary) ─────────┐
CLI ───────▶│ │
│ ops registry ── each operation: name, │
HTTP API ──▶│ (one table) params struct, inputs, Run() │
│ │ │
│ ├─ chromium (chromedp → headless Chromium,│──▶ chromium-headless-shell
│ │ external requests blocked, PrintToPDF)│ (separate process, reused)
│ ├─ pdfops (pdfcpu: merge, split, ...) │
│ ├─ pdfa (XMP + sRGB output intent ...) │
│ ├─ imgpdf (EXIF orientation, fit, JPEG) │
│ ├─ raster (PDFium-WASM → PNG/WebP/JPEG) │
│ └─ tmpl (Handlebars/Mustache + tr-TR) │
└────────────────────────────────────────────────┘
  • One operation table: CLI subcommands and /v1/<operation> endpoints are generated from the same registry. Parameters are bound from struct tags to CLI flags, form fields, JSON and the OpenAPI schema, so the CLI and the API cannot drift apart.
  • Stateless: inputs stay in memory, and Chromium receives documents straight from memory, never from disk. Async job results are kept in memory with a TTL.
  • Security: external network requests are blocked by default, the container runs as a non-root user with a read-only root, and request size and concurrency are limited.

Notes on fonts and PDF/A​

  • The standard 14 PDF fonts cannot encode Turkish letters such as ş, ğ, ı and İ, so text watermarks need an embedded TrueType font. Chromium embeds variable fonts as Type3 glyphs, so pidief ships static font instances.
  • Chromium header/footer templates cannot load web fonts, so the Docker image installs Onest as a system font.
  • Chromium does not produce PDF/A by itself; pidief adds XMP metadata, an output intent and annotation flags afterwards.