Smart Preflight: check colors

Post Reply
nna
Member
Posts: 30
Joined: Tue Jul 21, 2020 9:57 am

Smart Preflight: check colors

Post by nna »

Hi all!

I've been playing around with Smart Preflight in PitStop Server and Switch and I came to a little roadblock. I'd like to compare colors of a PDF to the ones in an XML. The XML file is attached as metadata and the color part looks like this:

Code: Select all

<Order>
...other stuff
   <Colors>
      <FrontColors>
         <Color>Key</Color>
         <Color>Cyan</Color>
         <Color>Magenta</Color>
         <Color>Yellow</Color>
      </FrontColors>
      <BackColors>
         <Color>Key</Color>
         <Color>Cyan</Color>
         <Color>Magenta</Color>
         <Color>Yellow</Color>
      </BackColors>
   </Colors>
</Order>
Now, I'd like to check if any of the Color-elements contain Pantone colors. If wrote an XPath

Code: Select all

//FrontColors/*[not(self::Color='Key' or self::Color='Cyan' or self::Color='Yellow' or self::Color='Magenta')]
which works when testing in Visual Studio Code but not in Switch. Switch only collects the first element instead of all of them. I think Switch is only ever able to extract a single element from an XML file.
If this worked I would've written it into a PrivateData field, written that content into a variable which I would then exclude from the check during Preflight. I'd also add a boolean to a PrivateData field to tell the Preflight whether to check for Pantone Colors or not.

Does this make any sense? If so: How can I achieve this? If not: What's a way I could try? Any help is much appreciated!
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: Smart Preflight: check colors

Post by freddyp »

In order to retrieve multiple values from an XML you have to choose the variable type "TextIndexed". You can then use an XPath that returns multiple values and you can pick any value using "Index" or combine all of them into a string with "Separator".

What I suggest in your case is to go for Integer and in the dataset window to choose "XPath expression" and use the XPath function count():

Code: Select all

count(//FrontColors/*[not(self::Color='Key' or self::Color='Cyan' or self::Color='Yellow' or self::Color='Magenta')])
If that is equal to 0 then there are no spot colors in the file.

Caveat: PDF's can contain the spot colors All (this is common) and None (this is rare). You may want to exclude them from the result of your XPath as well.
Post Reply