Metadata, Compression and Best Practices
Harry
· 24 Sep 2026
· 1 views
Log in to track your progress and mark lessons complete.
Sponsored
Document Metadata
PdfDocumentInfo info = pdf.getDocumentInfo();
info.setTitle("Invoice INV-2026-001");
info.setAuthor("GroovyGrails");
info.setCreator("Billing Service v2");Checklist
- License: iText 7 Core is AGPL — buy a commercial license for closed-source products, or evaluate OpenPDF/PDFBox for permissive licensing.
- Close documents in try-with-resources; generate to a temp file then atomic-move for served downloads.
- Embed fonts you rely on (
pdf.setDefaultPageSizeaside, unembedded fonts render differently per machine). - Reuse
PdfFontinstances; creating them per paragraph is slow. - Compress: iText compresses streams by default; downscale images before adding them — a 3 MB photo in a one-page invoice is the classic bloat.