PDF Properties -> Metadata fields management

Hi

Need to split a JSON sting with paper information and put it into metadata fields management

Old PDF flow:
There was a text line in the bottom of each pdf page, containing the paper information.
This information was passed to metadata, with a area mapping.

New Workflow:
A JSON string is placed in document properties, with the information.

I another ticket I learned how to read that information with a script and the split it:

Script:
// Script to get metadata from pdf properties
var myPDF = Watch.GetPDFEditObject();
myPDF.open(Watch.GetJobFileName(),false);
var meta = myPDF.GetInfos();
myPDF.Close();

var PDFMetaData = meta.keywords;
Watch.SetVariable(‘PDFMetaData’, PDFMetaData);
Watch.Log (‘META:’ + PDFMetaData, 3);

// Read JSON into variables
if (PDFMetaData) {
var FileMetaJSON = JSON.parse(PDFMetaData);
Watch.Log('JSON: ’ + JSON.stringify(FileMetaJSON), 3);
Watch.SetVariable(‘DocumentID’, FileMetaJSON[‘DocumentId’]);
Watch.SetVariable(‘CountryCode’, FileMetaJSON[‘CountryCode’]);
Watch.SetVariable(‘ZipCode’, FileMetaJSON[‘ZipCode’]);
Watch.SetVariable(‘ReturnEnvelope’, FileMetaJSON[‘ReturnEnvelope’]);
// Watch.SetVariable(‘PaperTypePage1’, FileMetaJSON[‘Pages[0].PageNumber.PaperType’]);

Watch.Log ('PDFMetaData enabled', 3);
Watch.SetVariable ('PDFMetaDataEnabled', 'TRUE');

}
else {
Watch.Log (‘PDFMetaData disabled’, 3);
Watch.SetVariable (‘PDFMetaDataEnabled’, ‘FALSE’);
}

There can be from 1 - 6 pages in a document, how do i read the array of pages telling witch paper to print on and put it into variables I can use in the metadata

The JSON looks like this:
String 1:
{“DocumentId”:110,“CountryCode”:“DK”,“ZipCode”:“2500”,“ReturnEnvelope”:0,“Pages”:[{“PageNumber”:1,“PaperType”:“Blank”},{“PageNumber”:2,“PaperType”:“Blank”},{“PageNumber”:3,“PaperType”:“Blank”}]}

String exampel 2:
{“DocumentId”:200,“CountryCode”:“DK”,“ZipCode”:“2500”,“ReturnEnvelope”:0,“Pages”:[{“PageNumber”:1,“PaperType”:“Blank”},{“PageNumber”:2,“PaperType”:“Blank”},{“PageNumber”:3,“PaperType”:“Blank”},{“PageNumber”:4,“PaperType”:“Advis”}]}

Hi @klaus.soerensen ,

Can you let me know please how the result of the Field information value “Data page;Paper;???” should looks like?

Can you also please explain what you mean by “how do i read the array of pages telling witch paper to print on and put it into variables I can use in the metadata”? I assume that you would like to loop through the “Pages” array and that you would like to add the result of this loop to the marked Field information?

Data page;Paper;??? ” shoud be the corresponding papertype for the given page in the JSON file.

if this was the JSOn file:
{“DocumentId”:110,“CountryCode”:“DK”,“ZipCode”:“2500”,“ReturnEnvelope”:0,“Pages”:[{“PageNumber”:1,“PaperType”:“White”},{“PageNumber”:2,“PaperType”:“Red”},{“PageNumber”:3,“PaperType”:“Yellow”}]}

So it should look like this in metadata:
for page 1 : Data page;Paper;White
for page 2 : Data page;Paper;Red
for page 3 : Data page;Paper;Yellow

Hope it makes sense