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
# install qpdf
apt-get install qpdf
Example of a valid PDF
# run a check on the PDF
qpdf --check 20241108072210-crossdock-labels.pdf
checking 20241108072210-crossdock-labels.pdf
PDF Version: 1.2
File is not encrypted
File is not linearized
No syntax or stream encoding errors found; the file may still contain
errors that qpdf cannot detect
Example of a corrupted PDF
qpdf --check 20241108070512-crossdock-labels.pdf
WARNING: 20241108070512-crossdock-labels.pdf: file is damaged
WARNING: 20241108070512-crossdock-labels.pdf (offset 27574): xref not found
WARNING: 20241108070512-crossdock-labels.pdf: Attempting to reconstruct cross-reference table
checking 20241108070512-crossdock-labels.pdf
PDF Version: 1.5
File is not encrypted
File is not linearized
WARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4096): unknown token while reading object; treating as string
WARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4103): unknown token while reading object; treating as string
WARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4105): unknown token while reading object; treating as string
WARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4107): unknown token while reading object; treating as string
WARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4116): unknown token while reading object; treating as string
WARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4123): unknown token while reading object; treating as string
WARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4123): too many errors; giving up on reading object
WARNING: 20241108070512-crossdock-labels.pdf (object 15 0, offset 4125): expected endobj
WARNING: object 15 0: operation for dictionary attempted on object of type null: returning false for a key containment request
WARNING: object 15 0: operation for dictionary attempted on object of type null: returning null for attempted key retrieval
WARNING: object 15 0: kid 3 (from 0) MediaBox is undefined; setting to letter / ANSI A
WARNING: object 15 0: operation for dictionary attempted on object of type null: ignoring key replacement request
WARNING: object 15 0: /Type key should be /Page but is not; overriding
WARNING: object 15 0: operation for dictionary attempted on object of type null: ignoring key replacement request
WARNING: object 31 0: operation for dictionary attempted on object of type null: returning false for a key containment request
WARNING: object 31 0: operation for dictionary attempted on object of type null: returning null for attempted key retrieval
WARNING: object 31 0: kid 7 (from 0) MediaBox is undefined; setting to letter / ANSI A
WARNING: object 31 0: operation for dictionary attempted on object of type null: ignoring key replacement request
WARNING: object 31 0: /Type key should be /Page but is not; overriding
WARNING: object 31 0: operation for dictionary attempted on object of type null: ignoring key replacement request
WARNING: object 15 0: operation for dictionary attempted on object of type null: returning null for attempted key retrieval
WARNING: object 31 0: operation for dictionary attempted on object of type null: returning null for attempted key retrieval
WARNING: 20241108070512-crossdock-labels.pdf (object 50 0, offset 15212): expected endobj
WARNING: 20241108070512-crossdock-labels.pdf (object 66 0, offset 20861): expected endstream
WARNING: 20241108070512-crossdock-labels.pdf (object 66 0, offset 20253): attempting to recover stream length
WARNING: 20241108070512-crossdock-labels.pdf (object 66 0, offset 20253): recovered stream length: 975
WARNING: object 15 0: operation for dictionary attempted on object of type null: returning null for attempted key retrieval
WARNING: object 31 0: operation for dictionary attempted on object of type null: returning null for attempted key retrieval
WARNING: 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 null
WARNING: 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 object
WARNING: 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 token
qpdf: operation succeeded with warnings
0 Comments