PDF problem - Help needed
[ This mail is addressed to people from whom I know that they have konwledge on
the inner workings of the PDF file format due to the projects they are working on. ]
Hi,
Uddhav Phatak (CCed) has done a GSoC 2024 project on eliminating C++ in libcupsfilters, mainly by replacing the PDF manipulator QPDF by Mike Sweet's PDFio.
His project report:
https://medium.com/@uddhavphatak/gsoc-2024-final-report-the-refactor-report-a46756e9d6ce
His code as PR #71 on libcupsfilters:
https://github.com/OpenPrinting/libcupsfilters/pull/71
Some parts he did not succeed to complete withing the GSoC time frame due to their complexity.
What is remaining to be completed is flattening filled forms and annotations into static content of the PDF, so that the filled in text is correctly taken into account by doing page manipulations (like N-up) and that it is assured that the text gets printed.
On this step Uddhav ran into a problem:
-----
Hi Till,
I am not able to debug one issue, could you help me where I might be going wrong,
form_english_filled.pdf and needtrue.pdf, both have needAppearances set as true.
form_english_filled.pdf is successfully flattened as shown in test.pdf
but when converting needtrue.pdf into needtrue-test.pdf, even though all the annotation objects are successfully converted to Xobjects and added into the page dict, I am not understanding why aren't they visible.
Can you look through this and tell me where I might be going wrong, and what value is missing from the Xobject Dictionary.
-----
The files mentioned here are all attached.
Anybody has an idea what can be wrong here?
Thanks in advance.
Till
Till,
I don't have a lot of time to look at this right now, but from the standpoint of adding the appearance streams as XObject resources in the page dictionary, you still need to *draw* the objects from the page content stream using the "Do" operator. For example, if the XObject was named "foo" then you'd need to add:
/foo Do
to the content stream.
Quoted 37 lines · Till Kamppeter
[ This mail is addressed to people from whom I know that they have konwledge on
the inner workings of the PDF file format due to the projects they are working on. ]Hi,
Uddhav Phatak (CCed) has done a GSoC 2024 project on eliminating C++ in libcupsfilters, mainly by replacing the PDF manipulator QPDF by Mike Sweet's PDFio.
His project report:
https://medium.com/@uddhavphatak/gsoc-2024-final-report-the-refactor-report-a46756e9d6ce
His code as PR #71 on libcupsfilters:
https://github.com/OpenPrinting/libcupsfilters/pull/71
Some parts he did not succeed to complete withing the GSoC time frame due to their complexity.
What is remaining to be completed is flattening filled forms and annotations into static content of the PDF, so that the filled in text is correctly taken into account by doing page manipulations (like N-up) and that it is assured that the text gets printed.
On this step Uddhav ran into a problem:
-----
Hi Till,
I am not able to debug one issue, could you help me where I might be going wrong,form_english_filled.pdf and needtrue.pdf, both have needAppearances set as true.
form_english_filled.pdf is successfully flattened as shown in test.pdf
but when converting needtrue.pdf into needtrue-test.pdf, even though all the annotation objects are successfully converted to Xobjects and added into the page dict, I am not understanding why aren't they visible.
Can you look through this and tell me where I might be going wrong, and what value is missing from the Xobject Dictionary.
-----
Quoted 8 lines
The files mentioned here are all attached.
Anybody has an idea what can be wrong here?
Thanks in advance.
Till
<test.pdf><needtrue-test.pdf><needtrue.pdf><form_english_filled.pdf>
________________________
Michael Sweet
It might be that the content is being rendered off the page; the example you supply would translate the content up 682.6 points (~241mm) and over 253 points (~89mm). If the content is already located at this offset, that would be enough to move it off the page...
Quoted 65 lines · On Sep 11, 2025, at 2:18 PM, UDDHAV PHATAK 22BCE10731…
Hi Michael,
Thanks for the suggestion. following your suggestion, I realized I wasn’t actually adding the stream into the page’s content stream. After digging deeper into both my code and QPDF’s implementation, I started creating a dedicated content stream for each XObject. For example, for an XObject named Fxo1, I generated the following stream:``` q 1.000000 0.000000 0.000000 1.000000 253.000000 682.600000 cm /Fxo1 Do Q ```The transformation matrix values come directly from the /Rect of the corresponding annotation object. I can now confirm that this stream is indeed being appended to the page content stream. However, the XObject still isn’t rendering or becoming visible in the output.
On Thu, Sep 11, 2025 at 8:32 PM Michael Sweet <[email protected]> wrote:
Till,I don't have a lot of time to look at this right now, but from the standpoint of adding the appearance streams as XObject resources in the page dictionary, you still need to *draw* the objects from the page content stream using the "Do" operator. For example, if the XObject was named "foo" then you'd need to add:
/foo Do
to the content stream.
Quoted 41 lines · Till Kamppeter
[ This mail is addressed to people from whom I know that they have konwledge on
the inner workings of the PDF file format due to the projects they are working on. ]Hi,
Uddhav Phatak (CCed) has done a GSoC 2024 project on eliminating C++ in libcupsfilters, mainly by replacing the PDF manipulator QPDF by Mike Sweet's PDFio.
His project report:
https://medium.com/@uddhavphatak/gsoc-2024-final-report-the-refactor-report-a46756e9d6ce
His code as PR #71 on libcupsfilters:
https://github.com/OpenPrinting/libcupsfilters/pull/71
Some parts he did not succeed to complete withing the GSoC time frame due to their complexity.
What is remaining to be completed is flattening filled forms and annotations into static content of the PDF, so that the filled in text is correctly taken into account by doing page manipulations (like N-up) and that it is assured that the text gets printed.
On this step Uddhav ran into a problem:
-----
Hi Till,
I am not able to debug one issue, could you help me where I might be going wrong,form_english_filled.pdf and needtrue.pdf, both have needAppearances set as true.
form_english_filled.pdf is successfully flattened as shown in test.pdf
but when converting needtrue.pdf into needtrue-test.pdf, even though all the annotation objects are successfully converted to Xobjects and added into the page dict, I am not understanding why aren't they visible.
Can you look through this and tell me where I might be going wrong, and what value is missing from the Xobject Dictionary.
-----The files mentioned here are all attached.
Anybody has an idea what can be wrong here?
Quoted 8 lines
Quoted 4 lines
Thanks in advance.
Till
<test.pdf><needtrue-test.pdf><needtrue.pdf><form_english_filled.pdf>________________________
Michael Sweet
________________________
Michael Sweet
Hello Uddhav,
Your PDF has multiple issues:
1. (Unrelated to the problem at hand:) needtrue-text.pdf ends with just „%EOF“ instead of the correct „%%EOF“
2. Already when opening the file with xpdf / poppler I am greeted with:
$ xpdf needtrue-test.pdf Syntax Error (59908): Unknown operator 'x<9c><d3><0f><a9>Pp<f2>u<e6>*Tp' Syntax Error (59910): Unknown operator '<e1>2P' Syntax Error (59916): Unknown operator '<c1><a2>t<05><fd><a8>D<97>L<05>CC=C<85><90>4.C=<0b><05><10><0e>IQ<d0><b0><d0>T<08><c9><e2>r' Syntax Error (59920): Unknown operator '<e1>' Syntax Error: Unknown operator '<e4>r<05>j<03>' Syntax Error: Unknown operator '<cf><fe><0e><02>' Syntax Error: Unknown operator 'x<9c><d3><0f><a9>Pp<f2>u<e6>r<05>b' Syntax Error: Unknown operator '<14>&<02><d7>' Syntax Error (60377): Unknown operator 'x<9c><d3><0f><a9>Pp<f2>u<e6>*Tp' Syntax Error (60379): Unknown operator '<e1>2P' Syntax Error (60385): Unknown operator '<c1><a2>t<05><fd><a8>D<97>L<05>CC=C<85><90>4.C=<0b><05><10><0e>IQ<d0><b0><d0>T<08><c9><e2>r' Syntax Error (60389): Unknown operator '<e1>' Syntax Error: Unknown operator '<e4>r<05>j<03>' Syntax Error: Unknown operator '<cf><fe><0e><02>' Syntax Error: Unknown operator 'x<9c><d3><0f><a9>Pp<f2>u<e6>r<05>b' Syntax Error: Unknown operator '<14>&<02><d7>' Syntax Error (60846): Unknown operator 'x<9c><d3><0f><a9>Pp<f2>u<e6>*Tp' Syntax Error (60848): Unknown operator '<e1>2P' Syntax Error (60854): Unknown operator '<c1><a2>t<05><fd><a8>D<97>L<05>CC=C<85><90>4.C=<0b><05><10><0e>IQ<d0><b0><d0>T<08><c9><e2>r' Syntax Error (60858): Unknown operator '<e1>' […]
which suggests that there is something very wrong, probably some butchered content streams (operators are usually part of a content stream, and you did not mess with e.g. fonts…).
3. Two fields ARE actually displayed correctly, Gender „Man“ and Height „150“.
4. Although the resource dictionary of the first (only) page contains XObjects /Fxo9 … /Fxo1 /Fxo17 … /Fxo10 only /Fxo9 … /Fxo16 are actually drawn on the page (with /… Do, as Michael Sweet already pointed out)
5. It turns out that „Man“ is /Fxo9 and „150“ is /Fxo10; /Fxo11 … /Fxo16 seem to be the check boxes, which seem to use images in their appearance, and their content stream is broken (dict + hex dump):
<</BBox[ 0 0 11.1 11.1]/Length 18 /Resources<</Font 18 0 R/ProcSet[/PDF/Text/ImageC/ImageI/ImageB]/XObject<</Im4 19 0 R>>>>/Subtype/Form/Type/XObject>>
00000000 78 9c d3 0f a9 50 70 f2 75 e6 72 05 62 00 14 26 x....Pp.u.r.b..& 00000010 02 d7
This looks like random memory (all the other appearance content streams are not compressed, either, which makes a missing /Filter unlikely).
6. The not-drawn XObjects, e.g. /Fxo1 do not seem to have obvious errors.
Quoted 1 line
I can now confirm that this stream is indeed being appended to the page content stream.
This is only true /Fxo9 … /Fxo16, but not for /Fxo1 .. /Fxo8 and /Fxo17 in the file I received from Till.
HTH
Tobias
Quoted 45 lines
Am 11.09.2025 um 16:50 schrieb Till Kamppeter <[email protected]>:
[ This mail is addressed to people from whom I know that they have konwledge on
the inner workings of the PDF file format due to the projects they are working on. ]Hi,
Uddhav Phatak (CCed) has done a GSoC 2024 project on eliminating C++ in libcupsfilters, mainly by replacing the PDF manipulator QPDF by Mike Sweet's PDFio.
His project report:
https://medium.com/@uddhavphatak/gsoc-2024-final-report-the-refactor-report-a46756e9d6ce
His code as PR #71 on libcupsfilters:
https://github.com/OpenPrinting/libcupsfilters/pull/71
Some parts he did not succeed to complete withing the GSoC time frame due to their complexity.
What is remaining to be completed is flattening filled forms and annotations into static content of the PDF, so that the filled in text is correctly taken into account by doing page manipulations (like N-up) and that it is assured that the text gets printed.
On this step Uddhav ran into a problem:
-----
Hi Till,
I am not able to debug one issue, could you help me where I might be going wrong,form_english_filled.pdf and needtrue.pdf, both have needAppearances set as true.
form_english_filled.pdf is successfully flattened as shown in test.pdf
but when converting needtrue.pdf into needtrue-test.pdf, even though all the annotation objects are successfully converted to Xobjects and added into the page dict, I am not understanding why aren't they visible.
Can you look through this and tell me where I might be going wrong, and what value is missing from the Xobject Dictionary.
-----The files mentioned here are all attached.
Anybody has an idea what can be wrong here?
Thanks in advance.
Till
<test.pdf><needtrue-test.pdf><needtrue.pdf><form_english_filled.pdf>
Hi Tobias and Michael,
Thanks so much for the detailed insights.
Status update:
The “unknown operator” errors were occurring when NeedAppearances was set to false. I’ve corrected that; with the current build, opening the file in xpdf no longer shows those errors and the content renders as expected. I’ve attached the resulting fixed.pdf.
The next issue I’m chasing is layout: some flattened text now renders slightly outside its intended boxes. Once I resolve that positioning, I’ll consider the PDFio-based flattening flow complete.(attached:
Fixed.pdf)
Quoted 1 line
On the %%EOF trailer
The %EOF vs %%EOF problem came from printf-style escaping in PDFio (a single %% emits one %). I’ve submitted a PR to PDFio to ensure the trailer writes a literal %%EOF.
Question:
What’s the best way to inspect page content streams to verify what’s actually inside them? For example, I want to check whether /Fxo1 Do ended up in the page content. Right now the streams are Flate-compressed, so I’m looking for a tool/command that will let me view the decompressed content directly.
Thanks again for your pointers, they helped a lott Best,
Uddhav
Quoted 104 lines · Tobias Hoffmann
Hello Uddhav,
Your PDF has multiple issues:
1. (Unrelated to the problem at hand:) needtrue-text.pdf ends with just „%EOF“ instead of the correct „%%EOF“
2. Already when opening the file with xpdf / poppler I am greeted with:
$ xpdf needtrue-test.pdf Syntax Error (59908): Unknown operator 'x<9c><d3><0f><a9>Pp<f2>u<e6>*Tp' Syntax Error (59910): Unknown operator '<e1>2P' Syntax Error (59916): Unknown operator '<c1><a2>t<05><fd><a8>D<97>L<05>CC=C<85><90>4.C=<0b><05><10><0e>IQ<d0><b0><d0>T<08><c9><e2>r' Syntax Error (59920): Unknown operator '<e1>' Syntax Error: Unknown operator '<e4>r<05>j<03>' Syntax Error: Unknown operator '<cf><fe><0e><02>' Syntax Error: Unknown operator 'x<9c><d3><0f><a9>Pp<f2>u<e6>r<05>b' Syntax Error: Unknown operator '<14>&<02><d7>' Syntax Error (60377): Unknown operator 'x<9c><d3><0f><a9>Pp<f2>u<e6>*Tp' Syntax Error (60379): Unknown operator '<e1>2P' Syntax Error (60385): Unknown operator '<c1><a2>t<05><fd><a8>D<97>L<05>CC=C<85><90>4.C=<0b><05><10><0e>IQ<d0><b0><d0>T<08><c9><e2>r' Syntax Error (60389): Unknown operator '<e1>' Syntax Error: Unknown operator '<e4>r<05>j<03>' Syntax Error: Unknown operator '<cf><fe><0e><02>' Syntax Error: Unknown operator 'x<9c><d3><0f><a9>Pp<f2>u<e6>r<05>b' Syntax Error: Unknown operator '<14>&<02><d7>' Syntax Error (60846): Unknown operator 'x<9c><d3><0f><a9>Pp<f2>u<e6>*Tp' Syntax Error (60848): Unknown operator '<e1>2P' Syntax Error (60854): Unknown operator '<c1><a2>t<05><fd><a8>D<97>L<05>CC=C<85><90>4.C=<0b><05><10><0e>IQ<d0><b0><d0>T<08><c9><e2>r' Syntax Error (60858): Unknown operator '<e1>' […]which suggests that there is something very wrong, probably some butchered content streams (operators are usually part of a content stream, and you did not mess with e.g. fonts…).
3. Two fields ARE actually displayed correctly, Gender „Man“ and Height „150“.
4. Although the resource dictionary of the first (only) page contains XObjects /Fxo9 … /Fxo1 /Fxo17 … /Fxo10 only /Fxo9 … /Fxo16 are actually drawn on the page (with /… Do, as Michael Sweet already pointed out)
5. It turns out that „Man“ is /Fxo9 and „150“ is /Fxo10; /Fxo11 … /Fxo16 seem to be the check boxes, which seem to use images in their appearance, and their content stream is broken (dict + hex dump):
<</BBox[ 0 0 11.1 11.1]/Length 18 /Resources<</Font 18 0 R/ProcSet[/PDF/Text/ImageC/ImageI/ImageB]/XObject<</Im4 19 0 R>>>>/Subtype/Form/Type/XObject>>
00000000 78 9c d3 0f a9 50 70 f2 75 e6 72 05 62 00 14 26 x....Pp.u.r.b..& 00000010 02 d7
This looks like random memory (all the other appearance content streams are not compressed, either, which makes a missing /Filter unlikely).
6. The not-drawn XObjects, e.g. /Fxo1 do not seem to have obvious errors.
Quoted 1 line
I can now confirm that this stream is indeed being appended to the page content stream.
This is only true /Fxo9 … /Fxo16, but not for /Fxo1 .. /Fxo8 and /Fxo17 in the file I received from Till.
HTH
TobiasQuoted 45 lines
Am 11.09.2025 um 16:50 schrieb Till Kamppeter <[email protected]>:
[ This mail is addressed to people from whom I know that they have konwledge on
the inner workings of the PDF file format due to the projects they are working on. ]Hi,
Uddhav Phatak (CCed) has done a GSoC 2024 project on eliminating C++ in libcupsfilters, mainly by replacing the PDF manipulator QPDF by Mike Sweet's PDFio.
His project report:
https://medium.com/@uddhavphatak/gsoc-2024-final-report-the-refactor-report-a46756e9d6ce
His code as PR #71 on libcupsfilters:
https://github.com/OpenPrinting/libcupsfilters/pull/71
Some parts he did not succeed to complete withing the GSoC time frame due to their complexity.
What is remaining to be completed is flattening filled forms and annotations into static content of the PDF, so that the filled in text is correctly taken into account by doing page manipulations (like N-up) and that it is assured that the text gets printed.
On this step Uddhav ran into a problem:
-----
Hi Till,
I am not able to debug one issue, could you help me where I might be going wrong,form_english_filled.pdf and needtrue.pdf, both have needAppearances set as true.
form_english_filled.pdf is successfully flattened as shown in test.pdf
but when converting needtrue.pdf into needtrue-test.pdf, even though all the annotation objects are successfully converted to Xobjects and added into the page dict, I am not understanding why aren't they visible.
Can you look through this and tell me where I might be going wrong, and what value is missing from the Xobject Dictionary.
-----The files mentioned here are all attached.
Anybody has an idea what can be wrong here?
Thanks in advance.
Till
<test.pdf><needtrue-test.pdf><needtrue.pdf><form_english_filled.pdf>
Uddhav,
Quoted 8 lines · On Sep 13, 2025, at 10:05 AM, UDDHAV PHATAK 22BCE10731…
...
Question:
What’s the best way to inspect page content streams to verify what’s actually inside them? For example, I want to check whether /Fxo1 Do ended up in the page content. Right now the streams are Flate-compressed, so I’m looking for a tool/command that will let me view the decompressed content directly.
The "testpdfio" program can be used for this. List the objects and dictionaries/values:
testpdfio --verbose FILENAME
Uncompress the stream for an object to stdout:
testpdfio FILENAME OBJECT-NUMBER
________________________
Michael Sweet