Skip to content

Fix to PDFio-based pdftopdf filter bugs#124

Merged
tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
uddhavphatak:master
Jun 15, 2026
Merged

Fix to PDFio-based pdftopdf filter bugs#124
tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
uddhavphatak:master

Conversation

@uddhavphatak

Copy link
Copy Markdown
Contributor

Fixes #113 ,

Test 1 and Test 2 (No Change in libcupsfilters)
File 1: 4 - Transparency PDF test - Designer.pdf
File 2: TransparencyTest.pdf
Issue: Bug in Ghostscript (https://bugs.ghostscript.com/show_bug.cgi?id=709017)
Fix : https://cgit.ghostscript.com/cgi-bin/cgit.cgi/ghostpdl.git/commit/?id=d4ac828eba87f53077339dd5acd6f8f022bad745

Test 3 and Test 4 (Updated the dependency of libcupsfilters to PDFio1.6.2)
File 3: Niere2025a.pdf
File 4: Wendzel2025a.pdf
Issue : michaelrsweet/pdfio#146
Fix : Updated the dependency of libcupsfilters to PDFio 1.6.2

Test 5 (changed the Operator from || to &&)
File: Tai2025a.pdf
Issue: entire document is missing pictures.
Fix : libcupsfilters implementation used "if (p.has_form || p.has_annotations)" which was wrong, for flattening the operator to be used should be "&&", which has been changed

Comment thread cupsfilters/pdftopdf.c Outdated
}

if (p.has_form || p.has_annotations)
if (p.has_form && p.has_annotations)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not really understand this change. For me it looks wrong, as we need flattening when there is a form and we need also flattening when there are annotations. We do not only need flattening when there is BOTH a form AND annotations.

Did you also test whether the filter behaves correctly with a PDF which ONLY contains a (filled) form or ONLY contains annotations? Does filled in text or annotations get printed?

Why does this change make the images in the test file being shown?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the files in the testing suite, and they have passed.
But I will test through more files as you have told, specifically with the pdf which only contains a (filled) form or only annotations.

Yes, this change does make the images in the test files being shown.

@tillkamppeter

Copy link
Copy Markdown
Member

The commit "fill the PDF file with annotations for proper tests" is a change on a binary file. How did you do the change? To fulfill the requirements of open source this needs to be documented or, even better, a script being provided with applies the changes to the original file.

@uddhavphatak

Copy link
Copy Markdown
Contributor Author

The pdf file didn't have the fields filled, thus I filled those , and saved it; overwriting the pdf binary

@tillkamppeter

Copy link
Copy Markdown
Member

The pdf file didn't have the fields filled, thus I filled those , and saved it; overwriting the pdf binary

How did you exactly fill them, with which software?

Is there a non-interactive way to fill the forms, for example with PDFio? You could perhaps compare the PDF files with empty form, and with differently filled fields, to find out what gets added to the original PDF when filling the form.

@uddhavphatak

Copy link
Copy Markdown
Contributor Author

I filled the form using the ubuntu default (Evince).

there is a way to fill the forms using PDFio by writing a C program which will rewrite the Full PDF with the filled details.
The other way with which I have done is by opening the PDF file using "vim", and went to the annot obj, changing the respective values in it

@tillkamppeter

Copy link
Copy Markdown
Member

I filled the form using the ubuntu default (Evince).

there is a way to fill the forms using PDFio by writing a C program which will rewrite the Full PDF with the filled details. The other way with which I have done is by opening the PDF file using "vim", and went to the annot obj, changing the respective values in it

Could you create such C program which generates the PDF with filled form? This way we can have more well-definbed test files, and also an easier way to control what binary test files contains (remember the "xz" attack).

Comment thread cupsfilters/pdftopdf.c Fixed
Comment thread cupsfilters/pdftopdf.c Fixed
@uddhavphatak

Copy link
Copy Markdown
Contributor Author

Hi @tillkamppeter ,
you were correct, the past fix:
if (p.has_form || p.has_annotations) to if (p.has_form && p.has_annotations)

was wrong. the correct fix was a NULL content string in special_annotation string.

Apart from this added a function in bannertopdf.c to fill PDF forms.

@tillkamppeter

Copy link
Copy Markdown
Member

Thanks.

But could you explain what all you did in your commit with the message "hi"? It would be great if you used more useful commit messages.

@uddhavphatak

Copy link
Copy Markdown
Contributor Author

I accidentally squashed the wrong commit I think, I didn't notice it. Letme rectify it right away!

Comment thread cupsfilters/pdftopdf.c Outdated
@uddhavphatak uddhavphatak force-pushed the master branch 2 times, most recently from 1fdb0c3 to b1aed3c Compare June 15, 2026 07:55
@tillkamppeter tillkamppeter merged commit d701523 into OpenPrinting:master Jun 15, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDFio-based pdftopdf filter bugs

3 participants