Hi,
I have been using exiftool for a while to write a block of job data to a custom namespace which is defined in a config file.
I now have the need to read the InksBook tag and if it is 'none', read the InksName tag and if it follows a certain pattern, write a new value to the InksBook tag.
I have looked at the thread here : https://exiftool.org/forum/index.php/topic,5200.0.html which seems most relevant, as it pertains to writing to tags containing lists in Esko metadata.
This is what the inks look like:
<egGr:inks>
<rdf:Seq>
<rdf:li rdf:parseType="Resource">
<egInk:name>cyan</egInk:name>
<egInk:type>process</egInk:type>
<egInk:book>process</egInk:book>
<egInk:egname>cyan</egInk:egname>
<egInk:frequency>120</egInk:frequency>
<egInk:angle>22.5</egInk:angle>
<egInk:dotshape/>
<egInk:r>0</egInk:r>
<egInk:g>0.622390747</egInk:g>
<egInk:b>0.891891479</egInk:b>
<egInk:attribute>normal</egInk:attribute>
<egInk:printingmethod>unknown</egInk:printingmethod>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInk:name>magenta</egInk:name>
<egInk:type>process</egInk:type>
<egInk:book>process</egInk:book>
<egInk:egname>magenta</egInk:egname>
<egInk:frequency>120</egInk:frequency>
<egInk:angle>52.5</egInk:angle>
<egInk:dotshape/>
<egInk:r>0.900100708</egInk:r>
<egInk:g>0</egInk:g>
<egInk:b>0.492385864</egInk:b>
<egInk:attribute>normal</egInk:attribute>
<egInk:printingmethod>unknown</egInk:printingmethod>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInk:name>Orange 021</egInk:name>
<egInk:type>pantone</egInk:type>
<egInk:book>pms1000c</egInk:book>
<egInk:egname>Orange 021</egInk:egname>
<egInk:frequency>120</egInk:frequency>
<egInk:angle>45</egInk:angle>
<egInk:dotshape/>
<egInk:r>1</egInk:r>
<egInk:g>0.317613095</egInk:g>
<egInk:b>0</egInk:b>
<egInk:attribute>normal</egInk:attribute>
<egInk:printingmethod>unknown</egInk:printingmethod>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<egInk:name>874</egInk:name>
<egInk:type>pantone</egInk:type>
<egInk:book>pms1000c</egInk:book>
<egInk:egname>874</egInk:egname>
<egInk:frequency>120</egInk:frequency>
<egInk:angle>45</egInk:angle>
<egInk:dotshape/>
<egInk:r>0.55217427</egInk:r>
<egInk:g>0.435770005</egInk:g>
<egInk:b>0.304249853</egInk:b>
<egInk:attribute>opaque</egInk:attribute>
<egInk:printingmethod>unknown</egInk:printingmethod>
</rdf:li>
</rdf:Seq>
</egGr:inks>
There can be anything from 1 to 12 inks in the PDF.
I can read the tags no problem using exiftool -G1 -S1 -a -InksBook* test.pdf or just exiftool -G1 -S1 -a -Inks* test.pdf but I cannot seem to write to the book tag. I'm not even sure how I would be targeting the correct one (i.e. #3)
Would I have to read the Inks group, change the bits I need to and re-write the whole group? Do I need to create a config file that enables writing to the Inks?
Any help, guidance, or specific parts of the documentation I should be looking at would be very much appreciated
Ian
Hi Ian,
Yes, you need to create a config file to write these. Dealing with lists of XMP structures can be tricky. See this page (https://exiftool.org/struct.html) for help.
- Phil
Thanks Phil.
The closest I have come to success now is reading the structure of the Inks with exiftool -struct -a -S3 -Inks test.pdf.
This gives me
[{Angle=22.5,Attribute=normal,B=0.891891479,Book=process,Dotshape=,Egname=cyan,Frequency=120,G=0.622390747,Name=cyan,Printingmethod=unknown,R=0,Type=process},{Angle=52.5,Attribute=normal,B=0.492385864,Book=process,Dotshape=,Egname=magenta,Frequency=120,G=0,Name=magenta,Printingmethod=unknown,R=0.900100708,Type=process},{Angle=45,Attribute=normal,B=0,Book=pms1000c,Dotshape=,Egname=Orange 021,Frequency=120,G=0.317613095,Name=Orange 021,Printingmethod=unknown,R=1,Type=pantone},{Angle=45,Attribute=normal,B=0.891891479,Book=none,Dotshape=,Egname=PG 0054,Frequency=120,G=0.622390747,Name=PG 0054,Printingmethod=unknown,R=0,Type=designer},{Angle=45,Attribute=normal,B=0.492385864,Book=none,Dotshape=,Egname=PG 0068,Frequency=120,G=0,Name=PG 0068,Printingmethod=unknown,R=0.900100708,Type=designer},{Angle=45,Attribute=opaque,B=0.304249853,Book=pms1000c,Dotshape=,Egname=874,Frequency=120,G=0.435770005,Name=874,Printingmethod=unknown,R=0.55217427,Type=pantone}]
For now, I'm not using any logic and just replacing 'Book=none' with 'Book=PG2011'
Then I'm writing back to the PDF with exiftool -config eskoConfig.txt -overwrite_original -v2 -xmp:inks='" & theResult & "' test.pdf where theResult is the manipulated structure.
This uses a config file with the following definitions for the egGr namespace and inks struct
%Image::ExifTool::UserDefined::egGr = (
GROUPS => { 0 => 'XMP', 1 => 'XMP-egGr', 2 => 'Image' },
NAMESPACE => { 'egGr' => 'http://ns.esko-graphics.com/grinfo/1.0/' },
WRITABLE => 'string',
# replace "NewXMPxxxTag1" with your own tag name (ie. "MyTag")
inks => { },
# XMP structures are defined as SubDirectory's
inks => {
SubDirectory => { }, # treat as a subdirectory containing other tags
Struct => 'inks', # arbitrary name identifies entry in xmpStruct
List => 'Seq', # structures may also be elements of a list
},
# structure elements must be defined as separate tags. The tag ID's
# are the concatination of the structure tag ID with the ID of each
# structure element in turn. The list flag should be set if the
# parent structure is contained in a list.
NewXMPxxxStructX => { List => 1 },
NewXMPxxxStructY => { List => 1 },
);
# User-defined XMP structures are added to the xmpStruct lookup
%Image::ExifTool::UserDefined::xmpStruct = (
inks => {
NAMESPACE => { 'egGr' => 'http://ns.esko-graphics.com/grinfo/1.0/' },
name => { },
type => { },
book => { },
egname => { },
frequency => { },
angle => { },
dotshape => { },
r => { },
g => { },
b => { },
attribute => { },
printingmethod => { },
},
);
This doesn't write the new values to the existing Inks structure, but appends the metadata in a new structure after %%EOF in a section that starts %BeginExifToolUpdate. Therefore I have 2 inks structures, and the embedded Esko XMP tool doesn't see any info for the inks.
From this, can you see if I am missing something from the config file to associate the egGR:Inks to the correct structure in the PDF, or am I referencing the wrong namespace when writing.
Thanks for all of your help
Ian
Hi Ian,
It sounds like you are doing everything properly. ExifTool writes PDF using the incremental update, so the old information will still exist, but will be ignored by a PDF reader. See the PDF Tags documentation (https://exiftool.org/TagNames/PDF.html) for details.
- Phil
Thanks Phil
Looks like I will have to tackle it a different way
Ian
If you need the old information removed permanently, just run qpdf after exiftool:
qpdf --linearize in.pdf out.pdf
(from this thread (https://exiftool.org/forum/index.php/topic,5385.0.html))
- Phil
The -linearize command seems to tidy the file up nicely, but for some reason, the plugin (and therefore the workflow) no longer sees the inks (attached)
Ian
Hi Ian,
Does ExifTool still see this information? If so, I suggest you compare the full XMP to see what the difference is when compared to one that works for you:
exiftool -xmp -b some.pdf
- Phil
Exiftool sees the new egGr metadata, but comparing the output of the before and after metadata, it is formatted slightly differently (see attached). I'm not sure if this makes it less 'valid' but Esko isn't reading it anymore.
Ian
Hi Ian,
Thanks for posting the XMP. The problem is that you are using the wrong namespace for the structure. It should be egInk, not egGr.
- Phil
That did the trick! I had a feeling I was getting confused with namespaces ;D
Thanks so much for your help
Ian