ExifTool Forum

ExifTool => The Image::ExifTool API => Topic started by: roux2 on August 24, 2011, 06:04:48 AM

Title: PDF Set values
Post by: roux2 on August 24, 2011, 06:04:48 AM
From my perl scripts i'd like to be able to write PDF metadata.
My understanding from the chart on the website is that it is possible now.

My test case is simple
$dri = new Image::ExifTool;
$dri->SetNewValue(Title => $oj{'Title'}) or die($!);
# $dri->SaveNewValues();
$dri->WriteInfo($fila,$fila.'.pdf','XMP','Info') or die($!);

I've been trying many combinations with the 8.624 version i'm using but no success yet in writing a title in the PDF metadatas.
I must be missing something ((
Title: Re: PDF Set values
Post by: Phil Harvey on August 24, 2011, 07:22:23 AM
What you have done will write an XMP Title to your pdf file.  (Although the 2 last arguments in your WriteInfo call are unnecessary).  I tested it here and it works fine with the t/images/PDF.pdf sample file.

Why do you say the title isn't written?

- Phil
Title: Re: PDF Set values
Post by: roux2 on August 25, 2011, 02:50:47 AM
When i open the file with Acrobat i can still see the old title.

I can see the right title in the XMP XML segment but not in the value i'll grab with ->GetValue('Title')

It seems to me all the layers of metadata are not synchronized.

- Stéphane.
Title: Re: PDF Set values
Post by: Phil Harvey on August 25, 2011, 07:27:58 AM
Hi Stéphane,

This problem is related to FAQ number 3 (https://exiftool.org/faq.html#Q3).

The "Title" tag exists in both XMP and PDF metadata in PDF files.  However, ExifTool should be writing both locations if you don't specify a group when writing the tag.  Use -a -G1 as per the FAQ when extracting to see where it was written.  If the values in the different locations disagree, I'm not sure which one Acrobat will display.

In case it is useful, there are two exiftool argument files included in the full exiftool distribution for synchronizing the PDF and XMP tags: pdf2xmp.args and xmp2pdf.args.

- Phil