ExifTool Forum

ExifTool => Newbies => Topic started by: uvishwakarma on December 12, 2014, 09:01:57 AM

Title: Adding Custom Properties in PDF
Post by: uvishwakarma on December 12, 2014, 09:01:57 AM
Dear All,

I am very new to exiftool. I am trying to add XMP in the PDF from a XMP file but custom tags are not getting displayed in the PDF. My XMP file has below custom tags:

.....
         <pdfx:doi>00.0000/j.xxxx.2014.10.036</pdfx:doi>
         <pdfx:AuthoritativeDomain>
            <rdf:Bag>
               <rdf:li>google.com</rdf:li>
               <rdf:li>yahoo.com</rdf:li>
            </rdf:Bag>
         </pdfx:AuthoritativeDomain>
....

I tried this by creating local config file and succeeded in getting doi but how can I achieve adding AuthoritativeDomain with below structure:

Name                                                       Value
------------                                             ---------------
AuthoritativeDomain[0]                            google.com         
AuthoritativeDomain[1]                            yahoo.com

My config looks like:

%Image::ExifTool::UserDefined = (
  'Image::ExifTool::PDF::Info' => {
     doi => {
         Writable => 'string',
     },
     AuthoritativeDomain => {
         Writable => 'string',
     },
  },
);   
1; # end   


Please help me.

Regards,
Umesh
Title: Re: Adding Custom Properties in PDF
Post by: Phil Harvey on December 12, 2014, 09:25:15 AM
Hi Umesh,

Your config file defines a PDF::Info tag, but you want to write this to XMP::pdfx.  Also, AuthoritativeDomain is a List of type "Bag".  So your config file should look like this:

%Image::ExifTool::UserDefined = (
  'Image::ExifTool::XMP::pdfx' => {
     doi => {
         Writable => 'string',
     },
     AuthoritativeDomain => {
         Writable => 'string',
         List => 'Bag',
     },
  },
);   
1; # end


and the command should look something like this:

exiftool -authoritativedomain=google.com -authoritativedomain=yahoo.com -doi=00.0000/j.xxxx.2014.10.036 FILE

- Phil
Title: Re: Adding Custom Properties in PDF
Post by: uvishwakarma on December 13, 2014, 05:42:28 AM
Hi Phill,

Thanks for your quick reply.

I did tried your way but it is not appearing in the PDF. Now even doi is not coming when I changed PDF::Info to XMP::pdfx in the config file.

Actually, I am trying to embed a XMP file in the PDF which contains some user defined tags. When I open the PDF in any text editor, it does copies the XMP (using XMP::Info) but when I view it in the Acrobat Pro. none of the custom tags are visible in the "Document Properties:Custom:Custom Properties" tab.

For your reference I have attached ZIP file contains my testing files. My command line is:

exiftool -config test.cfg -authoritativedomain=google.com -authoritativedomain=yahoo.com -doi=00.0000/j.xxxx.2014.10.036 article.pdf

Just for my understanding, I would like to know when I am using a complete XMP file then why it is not possible to embed all custom tags in the PDF without any exif config.

Regards,
Umesh

Title: Re: Adding Custom Properties in PDF
Post by: Phil Harvey on December 13, 2014, 07:36:02 AM
Hi Umesh,

You can embed entire XMP in PDF without needing user-defined tags.

I can't see your zip file, but I wouldn't be able to download it now anyway.  It sounds to me as if your problem is explained in FAQ number 3 (https://exiftool.org/faq.html#Q3).

- Phil
Title: Re: Adding Custom Properties in PDF
Post by: uvishwakarma on December 13, 2014, 08:06:22 AM
Hi Phil,

I have checked the FAQ Problem 3 but I think it will not solve my problem. If possible, please check my attached ZIP file which contains below files:

1. test.xmp (My complete XMP file)
2. article.pdf (To be updated with XMP)
3. test.cfg (exif tool config file, if requires)
4. test.sh (my command line batch file)

I am looking to add test.xmp file in to the article.pdf with all custom tags. Custom tags should be visible in Acrobat Pro. "Document Properties:Custom:Custom Properties" tab after adding XMP.

Regards,
Umesh
Title: Re: Adding Custom Properties in PDF
Post by: Phil Harvey on December 13, 2014, 09:12:53 AM
Hi Umesh,

Your shell script worked perfectly to write the custom XMP-pdfx tags.

However, it appears that I misunderstood your intent.  If you just want to write the XMP file as a block (ie. verbatim) into the PDF, you don't need user-defined tags, and the command is:

exiftool "-xmp<=test.xmp" article.pdf

- Phil
Title: Re: Adding Custom Properties in PDF
Post by: uvishwakarma on December 13, 2014, 09:39:59 AM
Hi Phil,

Thanks for your prompt reply!!!

I did tried this but I am sorry it is not appearing in the PDF when I open it in Acrobat Pro. Please see the attached ZIP contains screenshots and a required PDF created using Acrobat Pro. which I am looking for along with my output PDF article.pdf using your suggested command line.

Regards,
Umesh
Title: Re: Adding Custom Properties in PDF
Post by: Phil Harvey on December 13, 2014, 02:41:54 PM
Hi Umesh,

Did you use ExifTool to confirm that the information was written?

I can't help if other software doesn't read information that you have written, other than referring you to FAQ 3.

- Phil
Title: Re: Adding Custom Properties in PDF
Post by: StarGeek on December 13, 2014, 03:07:20 PM
Quote from: uvishwakarma on December 13, 2014, 09:39:59 AM
Please see the attached ZIP

Just pointing out that none of your posts have an attached file.

Maybe try uploading them to something like dropbox or google drive and then linking here?


Ignore me, my bad.
Title: Re: Adding Custom Properties in PDF
Post by: Phil Harvey on December 13, 2014, 03:13:58 PM
Hi StarGeek.  I can see the attachments in the last 2 posts.  But note that you may need to be logged in to see them.

- Phil
Title: Re: Adding Custom Properties in PDF
Post by: StarGeek on December 14, 2014, 12:41:40 AM
Quote from: Phil Harvey on December 13, 2014, 03:13:58 PM
Hi StarGeek.  I can see the attachments in the last 2 posts.  But note that you may need to be logged in to see them.

How interesting, my bad then.

Logged in, I don't see them.  But when I open this page in a private window, they appear.  May be side effect of my new rank?
Title: Re: Adding Custom Properties in PDF
Post by: uvishwakarma on December 14, 2014, 08:09:15 AM
Hi Phil,

It's Adobe Acrobat Pro. where I am checking the PDF, other than custom properties everything appears correctly. When I try adding custom tags using exif config, it does add them and are visible in the "Custom Properties" tab of Acrobat. But just I am not able to achieve array kind of entries which I mentioned earlier. See below for your reference which I am trying to get:

Acrobat Pro.::Document Properties:Custom:Custom Properties:

Name                                                       Value
------------                                             ---------------
AuthoritativeDomain[0]                            google.com         
AuthoritativeDomain[1]                            yahoo.com


When I try in command line, it adds the custom tags but not as a separate entry but separated by comma. See below my command line:

exiftool -config test.cfg -authoritativedomain=google.com -authoritativedomain=yahoo.com -doi=00.0000/j.xxxx.2014.10.036 article.pdf


It appears in the PDF as:

Name                                                       Value
------------                                             ---------------
AuthoritativeDomain                            google.com, yahoo.com


Please help me, it seems to me as if I am missing something here but it can be done through exif tool.

Thanks,
Umesh
Title: Re: Adding Custom Properties in PDF
Post by: Phil Harvey on December 14, 2014, 10:17:49 AM
You can confirm by looking at the XMP that the values are stored as separate items in an XMP Bag:

exiftool -xmp -b article.pdf

If so, then the are stored correctly.  I can't answer about how they are displayed in Acrobat Pro.  That is a question for an Adobe forum.

- Phil
Title: Re: Adding Custom Properties in PDF
Post by: uvishwakarma on December 14, 2014, 10:34:38 AM
Thanks Phil for all your support and listening to my all silly queries.

I tried this and XMP is embedded properly in the PDF but it is not showing in the "Custom Properties" tab of Acrobat. I'll definitely try to open a forum in Adobe but could you please help me if I can create a exif config file that should add custom tags like:

%Image::ExifTool::UserDefined = (
  'Image::ExifTool::PDF::Info' => {
     doi => {
         Writable => 'string',
     },
     AuthoritativeDomain[0] => {
         Writable => 'string',
     },
     AuthoritativeDomain[1] => {
         Writable => 'string',
     },
  },
);   
1; # end   

my command line should look like:

exiftool -config test.cfg -authoritativedomain[0]=google.com -authoritativedomain[1]=yahoo.com -doi=00.0000/j.xxxx.2014.10.036 article.pdf


Regards,
Umesh
Title: Re: Adding Custom Properties in PDF
Post by: Phil Harvey on December 14, 2014, 10:55:10 AM
Hi Umesh,

You keep running me around in circles.  Now we're back to writing PDF Info instead of XMP.  If you post a file with the PDF  information formatted in the way you want, I'll see if I can figure out how to write this with ExifTool.  Writing a custom List-type PDF Info tag is not something I remember anyone wanting to do before.

- Phil
Title: Re: Adding Custom Properties in PDF
Post by: uvishwakarma on December 14, 2014, 11:11:13 AM
I am so sorry Phil for the confusion. I already posted my intended PDF file and again posting the same. You can check in Acrobat application, all custom tags are visible there along with array kind of tags (AuthoritativeDomain):

I did tried XMP::pdfx but it was not showing in the Acrobat custom properties but when I use PDF::Info it does shows custom tags in the Acrobat custom tags list.

Please suggest.

Regards,
Umesh
Title: Re: Adding Custom Properties in PDF
Post by: Phil Harvey on December 14, 2014, 11:25:48 AM
Using the -v3 option you can see what is going on inside this PDF file:

[...]
  + [Info directory with 15 entries]
  | 0)  Author = (Ali Fattahi)
  |     - Tag 'Author', direct object
  | 1)  AuthoritativeDomain_1_ = (yahoo.com)
  |     - Tag 'AuthoritativeDomain#5B1#5D', direct object
  | 2)  AuthoritativeDomain_2_ = (google.com)
  |     - Tag 'AuthoritativeDomain#5B2#5D', direct object
  | 3)  CreateDate = (D:20120824160310+05'30')
  |     - Tag 'CreationDate', direct object
  | 4)  CrossMarkDomains_1_ = (yahoo.com)
  |     - Tag 'CrossMarkDomains#5B1#5D', direct object
  | 5)  CrossMarkDomains_2_ = (google.com)
  |     - Tag 'CrossMarkDomains#5B2#5D', direct object
  | 6)  CrossmarkDomainExclusive = (true)
  |     - Tag 'CrossmarkDomainExclusive', direct object
  | 7)  CrossmarkMajorVersionDate = (2010-04-23)
  |     - Tag 'CrossmarkMajorVersionDate', direct object
  | 8)  ElsevierWebPDFSpecifications = (6.4)
  |     - Tag 'ElsevierWebPDFSpecifications', direct object
  | 9)  Keywords = (Integer programming; Facilities planning and design; U-shaped assem[snip]
  |     - Tag 'Keywords', direct object
  | 10) ModifyDate = (D:20141213200458+05'30')
  |     - Tag 'ModDate', direct object
  | 11) Subject = (Testing)
  |     - Tag 'Subject', direct object
  | 12) Title = (Testing)
  |     - Tag 'Title', direct object
  | 13) Doi = (00.0000/j.xxxx.2014.10.036)
  |     - Tag 'doi', direct object
  | 14) Robots = (noindex)
  |     - Tag 'robots', direct object
[...]


To write these PDF Info AuthoritativeDomain tags, you need a config file like this:

%Image::ExifTool::UserDefined = (
  'Image::ExifTool::PDF::Info' => {
     doi => {
         Writable => 'string',
     },
     'AuthoritativeDomain#5B1#5D' => {
         Name => 'AuthoritativeDomain1',
         Writable => 'string',
     },
     'AuthoritativeDomain#5B2#5D' => {
         Name => 'AuthoritativeDomain2',
         Writable => 'string',
     },
  },
);   
1; # end


and the command is:

exiftool -authoritativedomain1=google.com -authoritativedomain2=yahoo.com FILE

- Phil
Title: Re: Adding Custom Properties in PDF
Post by: uvishwakarma on December 14, 2014, 11:34:48 AM
Spot on!!! Worked perfectly, you are a true champion!!!

Thanks Phill for listening to all my queries, it does requires too much patience, really appreciated.

Regards,
Umesh