Repository navigation
Remove truly empty pages from Calc PDF exports - #414
Conversation
KnifeLemon
left a comment
There was a problem hiding this comment.
Thanks @Perricheno, this is a careful, conservative fix: only pages with no painting operator go, annotations and unreadable pages keep a page, a wholly blank document is left alone, and the file is replaced only after the cleaned copy was saved. CI is green.
Two things before we merge:
- PDF/A. When the preset asks for PDF/A, LibreOffice writes a PDF/A file, and re-saving it with PDFsharp breaks that: PDFsharp writes its own Producer and a new ModDate into the Info dictionary (I checked: after
PdfBlankPages.Removeboth change), while the XMP metadata LibreOffice wrote stays as it was. PDF/A validators flag that mismatch. Please skip the clean-up whenstep.Preset.Document.PdfAis on, with a test. - The comment in
LibreOfficeConvertersays "empty trailing PDF pages", butPdfBlankPages.Removedrops empty pages anywhere in the document. Removing them anywhere is fine for Calc's leftover print tiles (with "down, then over" page order they can sit between real pages), so please just make the comment say what the code does.
Also, where did the 1-5 курс.xlsx report come from? If there is an issue or a discussion, please link it so the reporter hears about the fix.
|
Thanks — addressed in 29072d5.
Focused |
KnifeLemon
left a comment
There was a problem hiding this comment.
Thanks @Perricheno, PDF/A output is left untouched now and the test proves it byte for byte, and the comment matches what the code does. Good to go once CI is green.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LibreOffice Calc can preserve stale Excel print tiles as completely empty PDF pages. This removes only pages with no painting operator at all after a Calc-to-PDF conversion.
The check is deliberately conservative: text, borders, charts, images, annotations, and even white paint keep the page. Unreadable pages and wholly blank documents are left unchanged. PDF/A output is left byte-for-byte as LibreOffice wrote it because re-saving it would invalidate the relationship between its Info dictionary and archival XMP metadata.
Tested with focused unit tests and a locally supplied seven-sheet
1-5 курс.xlsxworkbook through the real LibreOffice converter. The workbook contains personal/academic data, was not uploaded, and has no public issue or discussion.