Just become a first time user of PDFgear and found it exiting with a .NET Runtime Event ID 1026 error when opening a PDF.
The PDF I was trying to load and edit was generated by a web application that in turn generated PDF's using GLabels.
So I needed a way to see if the PDF was the problem or a bug in PDFgear and after a quick Google for "How to check if a PDF is valid on the Linux CLI" I found qpdf
Installation
1 2 | # install qpdfapt-get install qpdf |
Example of a valid PDF
1 2 3 4 5 6 7 8 | # run a check on the PDFqpdf --check 20241108072210-crossdock-labels.pdfchecking 20241108072210-crossdock-labels.pdfPDF Version: 1.2File is not encryptedFile is not linearizedNo syntax or stream encoding errors found; the file may still containerrors that qpdf cannot detect |
Example of a corrupted PDF
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | qpdf --check 20241108070512-crossdock-labels.pdfWARNING: 20241108070512-crossdock-labels.pdf: file is damagedWARNING: 20241108070512-crossdock-labels.pdf (offset 27574): xref not foundWARNING: 20241108070512-crossdock-labels.pdf: Attempting to reconstruct cross-reference tablechecking 20241108070512-crossdock-labels.pdfPDF Version: 1.5File is not encryptedFile is not linearizedWARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4096): unknown token while reading object; treating as stringWARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4103): unknown token while reading object; treating as stringWARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4105): unknown token while reading object; treating as stringWARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4107): unknown token while reading object; treating as stringWARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4116): unknown token while reading object; treating as stringWARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4123): unknown token while reading object; treating as stringWARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4123): too many errors; giving up on reading objectWARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4125): expected endobjWARNING: object 15 0: operation for dictionary attempted on object of type null: returning false for a key containment requestWARNING: object 15 0: operation for dictionary attempted on object of type null: returning null for attempted key retrievalWARNING: object 15 0: kid 3 (from 0) MediaBox is undefined; setting to letter / ANSI AWARNING: object 15 0: operation for dictionary attempted on object of type null: ignoring key replacement requestWARNING: object 15 0: /Type key should be /Page but is not; overridingWARNING: object 15 0: operation for dictionary attempted on object of type null: ignoring key replacement requestWARNING: object 31 0: operation for dictionary attempted on object of type null: returning false for a key containment requestWARNING: object 31 0: operation for dictionary attempted on object of type null: returning null for attempted key retrievalWARNING: object 31 0: kid 7 (from 0) MediaBox is undefined; setting to letter / ANSI AWARNING: object 31 0: operation for dictionary attempted on object of type null: ignoring key replacement requestWARNING: object 31 0: /Type key should be /Page but is not; overridingWARNING: object 31 0: operation for dictionary attempted on object of type null: ignoring key replacement requestWARNING: object 15 0: operation for dictionary attempted on object of type null: returning null for attempted key retrievalWARNING: object 31 0: operation for dictionary attempted on object of type null: returning null for attempted key retrievalWARNING: 20241108070512-crossdock-labels.pdf (object 50 0, offset 15212): expected endobjWARNING: 20241108070512-crossdock-labels.pdf (object 66 0, offset 20861): expected endstreamWARNING: 20241108070512-crossdock-labels.pdf (object 66 0, offset 20253): attempting to recover stream lengthWARNING: 20241108070512-crossdock-labels.pdf (object 66 0, offset 20253): recovered stream length: 975WARNING: object 15 0: operation for dictionary attempted on object of type null: returning null for attempted key retrievalWARNING: object 31 0: operation for dictionary attempted on object of type null: returning null for attempted key retrievalWARNING: page object 63 0 stream 65 0 (content, offset 1031): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1064): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1392): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1413): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1416): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1422): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1424): treating unexpected array close token as nullWARNING: page object 63 0 stream 65 0 (content, offset 1427): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1446): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1450): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1569): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1760): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1784): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1832): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1833): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1839): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1848): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1849): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1855): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1855): too many errors; giving up on reading objectWARNING: page object 63 0 stream 65 0 (content, offset 1860): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1878): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1893): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1899): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1967): unexpected )WARNING: page object 63 0 stream 65 0 (content, offset 1968): EOF while reading tokenqpdf: operation succeeded with warnings |

0 Comments