dealfonso / sapp

Simple and Agnostic PDF Document Parser in PHP - sign PDF docs using PHP
GNU Lesser General Public License v3.0
118 stars 31 forks source link

Some signed documents can't be signed again #73

Open Daviid-P opened 3 months ago

Daviid-P commented 3 months ago

Hi, I have some signed PDFs that can not be signed again with this tool.

Error info at C:\\xampp7\\htdocs\\webapp\\htdocs\\custom\\vendor\\ddn\\sapp\\src\\PDFUtilFnc.php:637: object is not valid: 18
Warning info at C:\\xampp7\\htdocs\\webapp\\htdocs\\custom\\vendor\\ddn\\sapp\\src\\PDFDoc.php:972: root object does not exist, so cannot get information about pages
Error info at C:\\xampp7\\htdocs\\webapp\\htdocs\\custom\\vendor\\ddn\\sapp\\src\\PDFUtilFnc.php:637: object is not valid: 18
Error info at C:\\xampp7\\htdocs\\webapp\\htdocs\\custom\\vendor\\ddn\\sapp\\src\\PDFDoc.php:546: invalid root object
Error info at C:\\xampp7\\htdocs\\webapp\\htdocs\\custom\\vendor\\ddn\\sapp\\src\\PDFUtilFnc.php:637: object is not valid: 18
Error info at C:\\xampp7\\htdocs\\webapp\\htdocs\\custom\\vendor\\ddn\\sapp\\src\\PDFDoc.php:367: invalid root object
Error info at C:\\xampp7\\htdocs\\webapp\\htdocs\\custom\\vendor\\ddn\\sapp\\src\\PDFDoc.php:714: could not generate the signed document

Here's the PDF's cat, I deleted everything between >>stream XXXXXX endstream

%PDF-1.3
1 0 obj
[/PDF /Text /ImageB /ImageC /ImageI]
endobj
8 0 obj
<< /Length 2924 /Filter /FlateDecode 
endobj
2 0 obj
<< /Type /Page /Parent 9 0 R /MediaBox [0 0 595.276 841.89] /Contents 8 0 R /Resources << /ProcSet 1 0 R /XObject << /Im7 7 0 R >> /Font << /F3 3 0 R /F4 4 0 R /F5 5 0 R /F6 6 0 R >> >> >>
endobj
7 0 obj
<< /Type /XObject /Subtype /Image /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /FlateDecode  /Width 176 /Height 63 /Length 4356 
endobj
10 0 obj
<< /Filter /FlateDecode  /Length 76495 /Length1 350844 
endobj
11 0 obj
<< /Filter /FlateDecode  /Length 246 /Length1 402 
endobj
12 0 obj
<< /Filter /FlateDecode  /Length 100604 /Length1 393196 
endobj
13 0 obj
<< /Filter /FlateDecode  /Length 279 /Length1 492 
endobj
3 0 obj
<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>
endobj
4 0 obj
<< /Type /Font /Subtype /Type0 /BaseFont /ABCDEE+Arial,Bold /Encoding /Identity-H /DescendantFonts [14 0 R] /ToUnicode 11 0 R >>
endobj
14 0 obj
<< /Type /Font /Subtype /CIDFontType2 /BaseFont /ABCDEE+Arial,Bold /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >> /W [3 [277.832] 29 [333.008] 36 [722.168] 38 [722.168] 39 [722.168] 54 [666.992] 68 [556.152] 70 [556.152] 71 [610.84] 72 [556.152] 76 [277.832] 79 [277.832] 81 [610.84] 82 [610.84] 83 [610.84] 85 [389.16] 86 [556.152] 87 [333.008] 89 [556.152] 121 [610.84] ] /FontDescriptor 15 0 R >>
endobj
15 0 obj
<< /Type /FontDescriptor /Ascent 728 /CapHeight 0 /Descent -210 /Flags 32 /FontBBox [ -628 -376 2000 1056 ] /FontName /ABCDEE+Arial,Bold /ItalicAngle 0 /StemV 0  /FontFile2 10 0 R >>
endobj
5 0 obj
<< /Type /Font /Subtype /Type0 /BaseFont /ABCDEE+Arial /Encoding /Identity-H /DescendantFonts [16 0 R] /ToUnicode 13 0 R >>
endobj
16 0 obj
<< /Type /Font /Subtype /CIDFontType2 /BaseFont /ABCDEE+Arial /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >> /W [3 [277.832] 11 [333.008] 12 [333.008] 15 [277.832] 16 [333.008] 17 [277.832] 18 [277.832] 19 [556.152] 20 [556.152] 21 [556.152] 22 [556.152] 23 [556.152] 24 [556.152] 25 [556.152] 26 [556.152] 27 [556.152] 28 [556.152] 36 [666.992] 37 [666.992] 38 [722.168] 39 [722.168] 40 [666.992] 41 [610.84] 43 [722.168] 44 [277.832] 45 [500] 47 [556.152] 48 [833.008] 49 [722.168] 50 [777.832] 51 [666.992] 53 [722.168] 54 [666.992] 55 [610.84] 56 [722.168] 57 [666.992] 68 [556.152] 69 [556.152] 70 [500] 71 [556.152] 72 [556.152] 74 [556.152] 75 [556.152] 76 [222.168] 77 [222.168] 79 [222.168] 80 [833.008] 81 [556.152] 82 [556.152] 83 [556.152] 84 [556.152] 85 [333.008] 86 [500] 87 [277.832] 88 [556.152] 89 [500] 91 [500] 92 [500] 93 [500] 105 [556.152] 116 [277.832] 121 [556.152] 157 [370.117] 158 [365.234] 172 [666.992] 257 [333.008] ] /FontDescriptor 17 0 R >>
endobj
17 0 obj
<< /Type /FontDescriptor /Ascent 728 /CapHeight 0 /Descent -210 /Flags 32 /FontBBox [ -665 -325 2000 1040 ] /FontName /ABCDEE+Arial /ItalicAngle 0 /StemV 0  /FontFile2 12 0 R >>
endobj
6 0 obj
<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>
endobj
9 0 obj
<< /Type /Pages /Kids [ 2 0 R ] /Count 1 >>
endobj
18 0 obj
<< /Type /Catalog /Pages 9 0 R >>
endobj
19 0 obj
<< /Title <>
/Author <>
/Subject <>
/Creator (Microsoft Reporting Services 15.0.0.0)
/Producer (Microsoft Reporting Services PDF Rendering Extension 15.0.0.0)
/CreationDate (D:20240530144215Z00'00')
>>
endobj
xref
0 20
0000000000 65535 f
0000000010 00000 n
0000003067 00000 n
0000185813 00000 n
0000185918 00000 n
0000186713 00000 n
0000188073 00000 n
0000003274 00000 n
0000000065 00000 n
0000188173 00000 n
0000007806 00000 n
0000084399 00000 n
0000084738 00000 n
0000185441 00000 n
0000186065 00000 n
0000186511 00000 n
0000186855 00000 n
0000187876 00000 n
0000188235 00000 n
0000188288 00000 n
trailer << /Size 20 /Root 18 0 R /Info 19 0 R >>
startxref
188515
%%EOF
21 0 obj<</F 132/V 20 0 R/T(Signature1)/Type/Annot/Rect[0 0 0 0]/FT/Sig/P 2 0 R/Subtype/Widget>>
endobj
20 0 obj<</Location(C/ Direccion)/Reason(EMPRESA, S.L.)/Contents <30821c5f06092a864886f70 [OMITTED] c6297fca64f326ea79b71eefb0d063875e1290a537d9336f299e8e5878ac0a6cee7c5974ea531efc1ba6f9276ffc0b8a0ceaafb6a7942bbd6ccf33a79b8106a4100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000>/Type/Sig/ByteRange [0 189214 203878 3959 ]                                                         /SubFilter/adbe.pkcs7.sha1/Filter/Adobe.PPKMS/M(D:20240530144215+00'00')/ContactInfo(Cristina)/Name(EMPRESA S.L.)>>
endobj
22 0 obj <</Type/Metadata/Subtype/XML/Length 2907>>stream
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d' ?>
<x:xmpmeta xmlns:x='adobe:ns:meta/'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<rdf:Description rdf:about='' xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:creator><rdf:Seq><rdf:li></rdf:li></rdf:Seq></dc:creator><dc:title></dc:title><dc:format>application/pdf</dc:format><dc:subject><rdf:Bag><rdf:li></rdf:li></rdf:Bag></dc:subject></rdf:Description>
<rdf:Description rdf:about='' xmlns:pdf="http://ns.adobe.com/pdf/1.3/"><pdf:Producer>Microsoft Reporting Services PDF Rendering Extension 15.0.0.0</pdf:Producer></rdf:Description>
<rdf:Description rdf:about='' xmlns:xmp="http://ns.adobe.com/xap/1.0/"><xmp:CreateDate>2024-05-30&apos;T&apos;14:42:15.000&apos;+00:00&apos;</xmp:CreateDate><xmp:CreatorTool>Microsoft Reporting Services 15.0.0.0</xmp:CreatorTool></rdf:Description>
</rdf:RDF></x:xmpmeta>

<?xpacket ends='w' ?>
endstream
endobj
18 0 obj<</Type/Catalog/Metadata 22 0 R/Pages 9 0 R/AcroForm<</SigFlags 3/Fields[21 0 R]>>>>
endobj
2 0 obj<</Type/Page/Contents 8 0 R/Resources<</XObject<</Im7 7 0 R>>/ProcSet 1 0 R/Font<</F4 4 0 R/F3 3 0 R/F6 6 0 R/F5 5 0 R>>>>/Parent 9 0 R/MediaBox[0 0 595.276 841.89]/Annots[21 0 R]>>
endobj
19 0 obj<</Title()/Creator(Microsoft Reporting Services 15.0.0.0)/Producer(Microsoft Reporting Services PDF Rendering Extension 15.0.0.0)/CreationDate(D:20240530144215Z00'00')/Author()/Subject()>>
endobj
xref
0 1
0000000000 65535 f 
2 1
0000207199 00000 n 
18 5
0000207099 00000 n 
0000207395 00000 n 
0000189106 00000 n 
0000189002 00000 n 
0000204116 00000 n 
trailer
<</Size 23/Info 19 0 R/Prev 188515/Root 18 0 R>>
startxref
207599
%%EOF

The PDF is an invoice so I can't upload it here.

parallels999 commented 2 months ago

You will have to upload the file, because if you paste only a text the PDF cannot be generated, bytes may be lost