ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: cm_dheighton on December 08, 2022, 01:10:57 PM

Title: Not a SCALAR reference error on PDF
Post by: cm_dheighton on December 08, 2022, 01:10:57 PM
System: Windows Server, and Windows 10 Pro
Version: 12.52
Command Line:
exiftool.exe -all:all= 2022162220_Monthly_Permit_Log__79_.pdf

Output Error:
Not a SCALAR reference at C:\Users\Daniel\AppData\Local\Temp\par-44616e69656c\cache-exiftool-12.52\inc\lib/Image/ExifTool/WritePDF.pl line 398, <EXIFTOOL_FILE2> line 24.

PDF File:
https://drive.google.com/file/d/1tQ_r6dG_meRcmzOa5WBcKHEreHjyzahN/view?usp=sharing

Would appreciate any insight into this. PDF opens works fine in browser, Adobe, etc. We just want to strip out the metadata.
Title: Re: Not a SCALAR reference error on PDF
Post by: Phil Harvey on December 09, 2022, 07:00:48 AM
I'm heading out on a 1-week vacation today but I'll look into this when I return.

- Phil
Title: Re: Not a SCALAR reference error on PDF
Post by: StarGeek on December 09, 2022, 11:02:13 AM
Quote from: cm_dheighton on December 08, 2022, 01:10:57 PMWould appreciate any insight into this. PDF opens works fine in browser, Adobe, etc.

This isn't necessarily an indication that there isn't a problem with the PDF, as there is a lot of code out there that writes PDFs badly and readers often work around it.  But my quick tests on your example file do not find any problems, so this may be an exiftool bug.  I'm still looking for a good pdf checker.

QuoteWe just want to strip out the metadata.

You should note that exiftool's edits to PDF files are reversible unless the file is re-linearized after editing.  See the PDF Tags page (https://exiftool.org/TagNames/PDF.html).
Title: Re: Not a SCALAR reference error on PDF
Post by: cm_dheighton on December 09, 2022, 03:35:47 PM
Quote from: StarGeek on December 09, 2022, 11:02:13 AMYou should note that exiftool's edits to PDF files are reversible unless the file is re-linearized after editing.  See the PDF Tags page.
Thanks for the heads up. I'll make sure my developer is aware.

Quote from: Phil Harvey on December 09, 2022, 07:00:48 AMI'm heading out on a 1-week vacation today but I'll look into this when I return.

- Phil
Thanks Phil. Looking forward to hearing from you.

Title: Re: Not a SCALAR reference error on PDF
Post by: Phil Harvey on December 21, 2022, 08:43:33 AM
The sample PDF has an Info dictionary which is a direct object.  According to the PDF specification, this must be an indirect object, so the software that wrote this PDF is buggy.

I'll patch ExifTool to check for this rather than issuing a runtime error.

- Phil
Title: Re: Not a SCALAR reference error on PDF
Post by: cm_dheighton on December 21, 2022, 04:38:14 PM
Thanks Phil.

I figured as much, we see a lot of bad PDFs overall. Sadly we have no control or leverage to get this fixed at the source.

Do you have any advice on other PDF tools that can repair/fix these kind of problems? (Applies to my other post as well)
We use mutool to correct some of the invalid PDFs we come across, but it didn't resolve either of these.

I'd prefer our processing tool chain not just let PDFs past if they can't correctly finish a step.
Title: Re: Not a SCALAR reference error on PDF
Post by: Phil Harvey on December 21, 2022, 09:19:14 PM
I don't know much about pdf tools other than using qpdf to linearize pdf files.  You could maybe try that.

- Phil