I hope somebody can point me in the right direction. We print and post a number of different letters from pdfs supplied. We use workflow and connect to sort data, extract an account number and insert this on each page and to add marks for the envelope inserter. As there are many small batches I wish to merge these to make bigger batches which will be more efficient. For tracking purposes I need to be able to get the data out from each batch as it is merged - i.e. the original file name, the number of pages and the number of letters as a data file. The next stage would be a unique number which could be read by the inserter.
The DataMapper already receives the Original FileName from Workflow. You can extract it to a field in your datamodel with the following JavaScript code:
automation.properties.OriginalFilename;
As for the number of pages, it is unfortunately not yet available, but it will be in the upcoming 1.3 release as another JS property named steps.totalPages. Until then, you can create a datamodel field to which you assign the default value 0. When calling the DataMapper, that value will therefore be set to 0 for any file it processes. But once the “Execute Data Mapping” task completes, you can use a Workflow Script to count the number of pages in the PDF and store it into the proper field in the metadata retrieved from the data mapping task. For instance, assuming the field in your data model is named PageCount, then you’d use a script like the following in the workflow process:
set mypdf = Watch.GetPDFEditObject;
var myPdf =Watch.GetPDFEditObject();
myPdf.Open(Watch.GetJobFilename(), false);
var myMeta = new ActiveXObject("MetadataLib.MetaFile");
myMeta.LoadFromFile(Watch.GetMetadataFilename());
myMeta.Job().Group(0).Document(0).Fields.Add("_vger_fld_PageCount",myPdf.Pages().Count());
myMeta.SaveToFile(Watch.GetMetadataFilename());
myPdf.Close();
Then, when you perform the Content Creation task, you have to tick the “Update records from metadata” option to ensure the new value is stored back into the database.