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”}]}