How to GetValue for custom xmp structure tag ?

Started by jiucenglou, April 01, 2018, 12:59:50 PM

Previous topic - Next topic

jiucenglou

Dear Phil,

I am trying to learn how to use ExifTool as a library to write and read xmp structure to pdf files as instructed from https://exiftool.org/struct.html.

The writing with ExifTool as a library seems fine, which can be verified by opening the file with Adobe Reader, and by running exiftool on the command line.

Nevertheless, I am lost how to read the values back as a structure with ExifTool as a library. Specifically speaking, although -xmp-enw:reference can be used on the command line, GetValue('xmp-enw:reference') returns undef... Furthermore, it seems that GetFoundTags returns the flattened tags.

Could you help to comment how to GetValue for a whole structure first and then read its values ? The exiftool command line script produces good-looking xml or json, but it is really difficult for me to understand the flow and logic...

The config file, perl scripts and sample.pdf (actually can be any file) are attached for your convenience. Many thanks !


$ perl learn_write.pl
$
$ perl learn_read.pl sample_ref.pdf
FileSize
ReferenceAbstract
...
ReferenceLabel
...
why undefined !
$
$ exiftool -struct -j -xmp-enw:reference sample_ref.pdf
[{
  "SourceFile": "sample_ref.pdf",
  "Reference": [{
    "Abstract": "The mechanism ...",
    "Date": "2005/Apr/7",
    "Label": "Pel06",
    "Year": 2006
  },{
    "Label": "Another",
    "Year": 2016
  }]
}]

Phil Harvey

Quote from: jiucenglou on April 01, 2018, 12:59:50 PM
although -xmp-enw:reference can be used on the command line, GetValue('xmp-enw:reference') returns undef...

You need to set the API Struct option.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).