ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: jluix on February 16, 2022, 04:31:22 AM

Title: Error when inserting xmp data to certain pdf files
Post by: jluix on February 16, 2022, 04:31:22 AM
Hi there!

I'm having troubles when inserting XMP data to certain pdf files, while the same data (it's inside a file) is added without problem inside other pdfs. All the used pdfs are valid ones.

The message I get with the error is: Can't use string ("84") as a SCALAR ref while "strict refs" in use at /usr/local/share/perl/5.20.2/Image/ExifTool/WritePDF.pl line 398, <EXIFTOOL_FILE2> line 33.

I'm using debian 8 and esiftool version 12.4 (at first I run 9.74 version as it was the installed with my debian version, but upgraded to be sure it wasn't a solved bug) under perl 5.20.

Any help would be appreciated as I don't have experience in perl programming nor debugging.

Thanks in advance.
Title: Re: Error when inserting xmp data to certain pdf files
Post by: jluix on February 17, 2022, 03:34:52 AM
When I comment the line #14 in WritePDF.pl (use strict;), exitool works as expected and adds the XMP data to the pdf file without problem.

Although I'll use this as a workaround, it's obvious that it's not the best solution to this problem.

I haven't had much time to investigate futher but it seems that the string "84" referred in the error references to the object number inside the pdf file where the XMP data is going to be added (or replaced):

84 0 obj
<<
/Type /Metadata
/Subtype /XML
/Length 1494
>>
stream

...

endstream
endobj

I hope this helps to fix this error.
Title: Re: Error when inserting xmp data to certain pdf files
Post by: Phil Harvey on February 17, 2022, 07:23:49 AM
Could you send me the PDF so I can test this?  My email is philharvey66 at gmail.com

- Phil
Title: Re: Error when inserting xmp data to certain pdf files
Post by: Jan.Steinman on February 19, 2025, 12:17:26 PM
I'm getting a similar message just now. Any clues?

0> exiftool  -overwrite_original '-Description<=/tmp/x.txt' '-Keywords=global warming, climate change, emergency, disaster, climate breakdown, bleak picture, calamitous wildfires, ruinous floods, drought' Hothouse\ Earth\,\ An\ Inhabitant's\ Guide_Bill\ McGuire_2022_363.73874_9781785789205_.pdf
Can't use string ("null") as a SCALAR ref while "strict refs" in use at /usr/local/Cellar/exiftool/13.10/libexec/lib/Image/ExifTool/WritePDF.pl line 557, <EXIFTOOL_FILE2> line 364.
255> exiftool -ver
13.10
0>

Thanks!
Title: Re: Error when inserting xmp data to certain pdf files
Post by: Jan.Steinman on February 19, 2025, 12:27:06 PM
When I commented out the line as suggested by @jluix above, I get a different error:

0> exiftool  -overwrite_original '-Description<=/tmp/x.txt' '-Keywords=global warming, climate change, emergency, disaster, climate breakdown, bleak picture, calamitous wildfires, ruinous floods, drought' Hothouse\ Earth\,\ An\ Inhabitant's\ Guide_Bill\ McGuire_2022_363.73874_9781785789205_.pdf
Error: Error writing output file - Hothouse Earth, An Inhabitant's Guide_Bill McGuire_2022_363.73874_9781785789205_.pdf
    0 image files updated
    1 files weren't updated due to errors
1> ls -l@ Hothouse\ Earth\,\ An\ Inhabitant's\ Guide_Bill\ McGuire_2022_363.73874_9781785789205_.pdf
-rw-r--r--@ 1 jan  staff  926188 19 Feb 08:49 Hothouse Earth, An Inhabitant's Guide_Bill McGuire_2022_363.73874_9781785789205_.pdf
com.apple.metadata:kMDItemWhereFroms    429
com.apple.quarantine     58
0>

I get the same after removing the sometime-troublesome "quarantine" XATTR.

I have used your excellent tool on literally thousands of PDFs, and this is the first time I've seen this!

Thanks for producing and supporting such an awesome tool!
Title: Re: Error when inserting xmp data to certain pdf files
Post by: Phil Harvey on February 19, 2025, 12:30:21 PM
Could you send me the PDF so I can test this?  My email is philharvey66 at gmail.com

- Phil