Reputation: 27
everybody. I am trying to create a PDF with fillable form fields and there is some strange behavior when the PDF is rendered in Chrome. As intended, the input field is empty at first. I can click in, enter a value (for examle a lot of "bbbbbbb") and click away - till this moment everything works fine. However when I click in the field again and start writing, it still shows the original value even as I am writing. For example if I click at the start of the field and add a bunch of "aaaaaaa", I can still see the letters "bbbbbbbb" behind my new value.
This happens only in Chrome though. When the same PDF is displayed in Acrobat reader or Mozilla, it works just fine. Although Acrobat reader crashes when I open this PDF but is seems to crash when I open other PDF files with form too, so that might be unrelated.
I add the source code of the PDF file here:
%PDF-1.4
1 0 obj
<</Type /Catalog /Version /1.4 /Pages 2 0 R /Acroform <</NeedAppearances false /Fields [5 0 R ] >> /Names 8 0 R >>
endobj
2 0 obj
<</Type /Pages /Kids [11 0 R ] /Count 1 >>
endobj
3 0 obj
<</Type /Font /Subtype /Type1 /Encoding /WinAnsiEncoding /BaseFont /Helvetica >>
endobj
4 0 obj
<</Length 57 /Type /XObject /Subtype /Form /BBox [0 0 150 30 ] /Resources <</ProcSet [/PDF /Text /ImageC /ImageB /ImageI ] >> /Matrix [1 0 0 1 0 0 ] >>
stream
/Tx BMC
BT
/Helvetica 11 Tf 0 g
5 5 Td
() Tj
ET
EMC
endstream
endobj
5 0 obj
<</Type /Annot /Subtype /Widget /FT /Tx /Rect [150 395 300 425 ] /T (yourname) /DA (/Helvetica 11 Tf 0 g) /F 4 /Ff 0 /DR <</Font <</Helvetica 3 0 R >> >>
/AP <</N 4 0 R >> /P 11 0 R >>
endobj
6 0 obj
[]
endobj
7 0 obj
<</Names 6 0 R >>
endobj
8 0 obj
<</Dests 10 0 R >>
endobj
9 0 obj
[]
endobj
10 0 obj
<</Names 9 0 R >>
endobj
11 0 obj
<</Type /Page /LastModified (D:20240326234624+01'00') /Resources <</ProcSet [/PDF /Text ] /Font <</F1 13 0 R >> >> /MediaBox [0 0 595 842 ]
/Contents [12 0 R ] /Annots [5 0 R 5 0 R ] /Parent 2 0 R >>
endobj
12 0 obj
<</Length 101 >>
stream
0.8 g
20 20 555 802 re
f
/F1 14 Tf
0 g
BT
40 400 Td
(Fill your name) Tj
ET
1 g
150 395 150 30 re
f
endstream
endobj
13 0 obj
<</Type /Font /Encoding /WinAnsiEncoding /Subtype /Type1 /BaseFont /Helvetica >>
endobj
xref
0 14
0000000000 65535 f
0000000015 00000 n
0000000146 00000 n
0000000205 00000 n
0000000302 00000 n
0000000545 00000 n
0000000747 00000 n
0000000766 00000 n
0000000800 00000 n
0000000835 00000 n
0000000854 00000 n
0000000889 00000 n
0000001107 00000 n
0000001260 00000 n
trailer
<</ID [<36613663383332633536383565333731> <62306330656135306564363564633233> ] /Size 14 /Root 1 0 R >>
startxref
1358
%%EOF
And the final file here for download: https://filetransfer.io/data-package/AqJUA8a1#link (The file is rather empty concept with just one form field at the moment.)
If that is of any interest to you, I am generating that PDF file through old PHP Zend PDF library that I got stuck with at my work.
Do you anybody have any clue on what could be wrong with my code?
Upvotes: 1
Views: 141
Reputation: 11730
There is an error in above code the secondary binary ANSI comment line is missing, initialisation should be:
%PDF-1.4
%âãÏÓ
1 0 ...
Not that it needs to be there, as it's not encoded as ANSI but ASCII binary contents. However, that missing 6 bytes header will throw out all the instructions by 6 places and force a re-compilation of the PDF into binary with the missing comment when closed.
So that is not the main issue, which is, you are calling annotations to be rendered over each other twice. And it seems Chrome is rightly confused. Both files have that construct.
/Annots [5 0 R 5 0 R ]
Before and after change to /Annots [5 0 R ]
:
Upvotes: 1