Virtual PDF Printer
A virtual printer written in Java that regenerates a compliant PDF/A from even badly damaged documents, integrated into FACILE.
Overview
Some PDFs submitted to FACILE cannot be made compliant with the PDF/A archiving standard by a simple conversion: missing fonts, corrupted internal structures, elements forbidden by the standard. Virtual PDF Printer reproduces what a user does when printing a document to a PDF file: the content is reinterpreted and a brand-new document is produced. The component implements the IPP network printing protocol (RFC 8011) and Java's standard printing API, so a document is submitted to it just like to a real printer. It is now a dependency of FACILE.
Key features
- Implementation of the IPP protocol (RFC 8011) and the Java Print Service API
- Producer-consumer architecture with a job queue
- PDF/A conversion with Ghostscript
- Two independent validators: PDFBox Preflight and veraPDF
- Support for all seven PDF/A conformance levels
- About twenty classes in five modules, reusable outside FACILE
Context
A first solution chained three command-line tools (pdftoppm, img2pdf, Ghostscript): it was slow, did not solve every case and turned each page into an image, making the text unselectable. A rendering library such as PDFium had also been tried, but it added about ten gigabytes to the Docker image and exhausted the server's memory. My apprenticeship supervisor then asked me to design a correction tool that works "by printing".
What I did
- Analyzed the alternatives (improving the existing chain, relying on PDFium, implementing a print service) and chose IPP, a standardized, OS-independent protocol that needs no proprietary driver.
- Designed and developed the component in sixteen days, from a one-sentence requirement.
- Ran a test campaign on a varied corpus, which revealed hard cases: badly embedded color profiles, transparency, slow validation beyond 500 pages.
- Integrated it into FACILE as part of the PDF correction chain.