How to extract CC Mailing Address from a letter

Dear All,

My input data file is a batch PDF file (as per attached sample). It is a mail-merge letter and I would need to extract the Mailing Addresses which fall under <c.c.> sections (under the paragraph of “This letter is computer generated; no signature is required.”), so that I able to perform grouping and sorting according to the 1st <c.c.> Mailing Address and also the 2nd <c.c.> Mailing Address.

I’m facing issue when trying to extract the 1st <c.c.> Mailing Address as field A, then extract the 2nd <c.c.> Mailing Address as field B.

Appreciate if anyone can help to enlighten me. Thank You so much.

bills.pdf (76.1 KB)

The attached file demonstrates how to do it.

In a nutshell, it uses the Goto step, specifying Next occurrence of as the Target type. The expression to look for is "c.c. : ". It also specifies to look for that expression in a narrow column on the left hand side of the page, instead of the entire page width.
Then it extracts the first field.

Finally, it duplicates both steps to extract the second field.


1 Like

My colleague @hamelj quite rightly noticed that my solution doesn’t work if the height of the addresses vary on each record.

So I adjusted the DM config to take that into account.

After the first Goto, it no longer extracts anything. It simply records the current vertical position to a variable.

Then, it does the second Goto, and from there, it first extracts up (using a negative vertical offset that’s the difference between the current vertical position and the one recorded in the variable). And then it extracts the second address as before.

I had already described this technique elsewhere on these forums to extract item descriptions of varying heights in detail tables.


Here’s another approach…
Each c.c. addresses is in a detail table

bills_Loop_If.OL-datamapper (76.3 KB)

Thank You @Phil and @hamelj, both approach is works for me!!

Hi @Phil and @hamelj,

I am facing error at Workflow side while execute the DataMapper.

I actually combine the cc1 data into 1 single field using script (as per below).

But I encounter below error at Workflow side:

[0022] W3001 : Error while executing plugin: HTTP/1.1 500 An unspecified error occurred which was caused by LoggedApplicationException: There was an error running the data mapping process caused by ApplicationException: Error executing DM configuration: Error running script (TypeError: Cannot read property “length” from undefined) (DME000019) (DM1000031) (SRV000012) (SRV000001)

[0022] Execute Data Mapping: W1603 : Plugin failed - 10:56:30 (elapsed time: 00:00:00.204)

For your information, the DataMapper is working fine when I validate all the records at DataMapper.

Appreciate if you can help me. Thank You.

Hi @Phil and @hamelj,

I found that the above Workflow error only occur for Second C.C. Kindly advise.

A option you can consider to resolve the error message is to is to change the first two lines of the applied JavaScript code from:

var totalline = record.tables.cc2.length;
var text = "";


var totalline = 0;
var text = "";

if ("cc2" in record.tables) {
    totalline = record.tables.cc2.length;

or to:

var totalline = "cc2" in record.tables ? record.tables.cc2.length : 0;
var text = "";

By doing so you are first checking if the detail table cc2 does exist before assigning it’s .length value to the variable totalline.

Hi @Marten,

I did the same script for botch cc1 and cc2,

BUT, both value of cc1 and cc2 assigned into the 1st field only in workflow.

I tested it here, after having modified @hamelj’s template, and everything works as expected. I ran the template both in the DataMapper itself and from Workflow.

So there’s probably something else in your DM that’s causing the issue.

Here’s the modified config. Try to see if that works on your end : bills_Loop_If.OL-datamapper

Thanks @Phil,

The DM is working fine. The issue I facing on Workflow was due to I used the wrong input data file (which the second c.c. do not have the label of c.c.).

Sorry for the confusion and Thank You so much for your help.