Metadata, Compression and Best Practices

Harry · 24 Sep 2026 · 1 views
Log in to track your progress and mark lessons complete.

Document Metadata

PdfDocumentInfo info = pdf.getDocumentInfo();
info.setTitle("Invoice INV-2026-001");
info.setAuthor("GroovyGrails");
info.setCreator("Billing Service v2");

iText best practices checklist

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.setDefaultPageSize aside, unembedded fonts render differently per machine).
  • Reuse PdfFont instances; 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.
Share this post:

Comments (0)

Please login or register to comment.

Create a free account to keep reading

You've enjoyed a free tutorial! Register (it's free) to unlock every tutorial, track your progress and save code.

or sign in with your account

Already have an account? Log in