OL Learn

PDF split - remove new line chars during metadata extraction

I want to use workflow to split one big PDF into multiple separate documents using extracted text which contains document Id.

I extract text identifying the document using using Metatada Fields Management: region(?,0.01041,0.89583,0.72916,2.73958,KeepCase,NoTrim)

Unfortunately this text is spread over several lines:

##12345
6;Cover
Letter

and I cannot use it as a valid output PDF name.

How can I remove new line (ASCII 10) and “##” characters during / after metadata extraction?

A script will let you do that.
Something like this should get you going (you’ll have to adjust, according to your metadata structure):

var myMeta = new ActiveXObject("MetadataLib.MetaFile");
myMeta.LoadFromFile(Watch.GetMetadataFileName());

var myGroup = myMeta.Job().Group(0);
for(var myDocs = new Enumerator(myGroup); !myDocs.atEnd(); myDocs.moveNext()) {
    var myDoc = myDocs.item();
    var myField = myDoc.FieldByName("myField").replace(/##/g,"").replace(/\n/g," ");
    myDoc.Fields.Add("myField",myField);
}
myMeta.SaveToFile(Watch.GetMetadataFileName());

The script removes the ## characters and replaces new line characters with a space.

Thank you very much.