Prompt
I'm building a self-hosted workflow for sensitive documents, what PDF API or library makes sense?
Latest observation
For sensitive documents and a self-hosted setup, the best choice usually depends on whether you need rendering/viewing, text extraction, editing/merging, or full conversion.
Good self-hosted options
1) Apache PDFBox (Java)
Best if you want a solid, mature open-source library for:
- reading PDFs
- extracting text
- merging/splitting
- form handling
- basic PDF creation
Pros
- Fully self-hosted
- No external service
- Mature and widely used
- Good for document workflows
Cons
- Java-based
- Not the best for high-fidelity rendering or complex conversions
2) iText 7 (commercial/open-core)
Best if you need advanced PDF generation/manipulation.
Pros
- Very powerful
- Excellent for creation, stamping, signatures, forms, encryption
- Good documentation
Cons
- License matters a lot
- Open-source use is limited; commercial license often required for proprietary use
- Not ideal if you want “free and simple”
3) Apache Tika + PDFBox
Best if your workflow is about extracting and indexing document content.
Pros
- Great for text extraction and metadata
- Self-hosted
- Useful in document pipelines
Cons
- Not for editing/rendering PDFs
- More of a processing stack than a single PDF API
4) qpdf (CLI/library)
Best for low-level PDF operations like:
- linearization
- encryption/decryption
- splitting/merging
- structural fixes
Pros
- Very reliable
- Self-hosted
- Great for backend automation
Cons
- Not a high-level document API
- Limited creation/editing features compared to PDFBox/iText
5) Ghostscript
Best if you need PDF/PostScript conversion or rendering pipelines.
Pros
- Powerful
- Common in document-processing systems
Cons
- Can be tricky to secure and sandbox
- More conversion-oriented than application-level PDF handling
6) LibreOffice headless
Best for Office-to-PDF conversions self-hosted.
Pros
- Excellent for DOCX/XLSX/PPTX → PDF
- Fully self-hosted
Cons
- Heavy
- Not a PDF API
- Needs sandboxing and process isolation
If you need a web viewer/editor
If your “workflow” includes end users viewing PDFs in browser:
PDF.js
- Best open-source browser PDF viewer
- Can be self-hosted
- Great for secure document viewing in a web app
My practical recommendation
If you’re building a backend workflow:
- Java stack: PDFBox + qpdf
- Python stack: pypdf / PyMuPDF for operations, plus LibreOffice for conversion
- Need advanced PDF creation/signing: iText 7 if license is acceptable
- Need document text indexing: Apache Tika + PDFBox
- Need browser viewing: PDF.js
For sensitive documents specifically
A self-hosted workflow should also include:
- store files encrypted at rest
- isolate conversion/rendering in containers or VMs
- disable outbound network access for PDF-processing workers
- use temporary file cleanup
- validate untrusted PDFs carefully
- log access, not content
Short answer
If you want the safest, most general self-hosted choice:
- PDFBox if you’re in Java
- PyMuPDF or pypdf if you’re in Python
- PDF.js for viewing
- qpdf for backend PDF hygiene
If you tell me your language/runtime and what you need to do with the PDFs (view, extract, sign, redact, convert, generate), I can recommend a tighter stack.