Topic Options
#57999 - 05/18/21 10:00 AM filtering data region from PDF emulation
tadams1 Offline
OL Newbie

Registered: 05/17/21
Posts: 7
I’m working with a PDF data file in which I have used the data selection tool to define a region of the PDF file that contains the name and address area of the recipient. My problem is that there are 4 lines of text within the region where the first line is the person’s name; 2nd line is personal information that I do not want to print; 3rd line is the address line of text and the 4th line is the city state and zip code.

Because the selection is a data region from PDF emulation and not actual fields, I’m having trouble coming up with PressTalk that will do the selection and elimination of what I want. The personal line that will be eliminated will also have to be defined as a blank line that is removed to allow the name to be moved closer to the address lines.

Can anyone help with this? Thanks!

Top
#58001 - 05/18/21 10:28 AM Re: filtering data region from PDF emulation [Re: tadams1]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 650
Loc: Québec, Canada
Can you display an example, in text in this forum, of what it does look like in your PDF?
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#58002 - 05/18/21 10:48 AM Re: filtering data region from PDF emulation [Re: tadams1]
tadams1 Offline
OL Newbie

Registered: 05/17/21
Posts: 7
DOE, JOHN
CARD ID : X12VX34YD43
123 MAIN STREET
ANYTOWN, PA 99999


It is a "bill to" address shown in the upper left corner of the PDF document. My preference for output in PlanetPress would be to also reverse the first and last names to read normally as "JOHN DOE" but that is not an absolute necessity.

Top
#58004 - 05/18/21 10:56 AM Re: filtering data region from PDF emulation [Re: tadams1]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 650
Loc: Québec, Canada
Are your data lines fix in position? Is the address and customer name moving up and down or are they always at the exact same position?
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#58005 - 05/18/21 11:04 AM Re: filtering data region from PDF emulation [Re: tadams1]
tadams1 Offline
OL Newbie

Registered: 05/17/21
Posts: 7
As far as I know, they are always in a fixed position:
The upper left corner of data area would be about 30mm from the left of the page and 16mm down from the top. The upper right corner of the data area would be about 30mm down from the top and 10mm from the left. The bottom of the data area would be 38mm down from the top of the page and the left and right corners of the bottom would be 30mm and 100mm respectively.

Top
#58006 - 05/18/21 11:24 AM Re: filtering data region from PDF emulation [Re: tadams1]
tadams1 Offline
OL Newbie

Registered: 05/17/21
Posts: 7
At this point, I'm also fairly certain that it will always be four lines of data, not really moving anything up or down. We haven't received any large amounts to process yet... only a couple of pages of sampling data. If there would be an additional (2nd address line) I would assume that it would extend the bottom of the area because the top is located right below a static "BILL TO:" printed line.

Top
#58008 - 05/18/21 11:57 AM Re: filtering data region from PDF emulation [Re: tadams1]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 650
Loc: Québec, Canada
Assuming the following:
  • Address is always at the same position
  • Sometime, a second line of address could appear, pushing city, state and zip further down
  • The format for the city line is: <city>, <state> <zip>


I would create 4 global variables:
  • RecipientName
  • addr1
  • addr2
  • cityStateZip


Then inside a PressTalk object
Code:
define(&line1,string,'')
define(&line2,string,'')
define(&line3,string,'')
define(&line4,string,'')
define(&commaPos,integer,0)

%Where the recipient name is
&line1 := regionline(0.74,9.28,3.54,9.52)

%Where the first line of address is
&line2 := regionline(0.76,9.53,3.56,9.74)

%Where the second line of address or the city, state zip one is
&line3 := regionline(0.76,9.72,3.51,9.94)

%Where the city, state zip line is (or empty line)
&line4 := regionline(0.76,9.93,3.52,10.13)

&commaPos := pos(',',&line1)

%reverse the first and last name
&RecipientName := right(&line1,length(&line1)-&commaPos)+' '+left(&line1,&commaPos-1)

&addr1 := &line2

if(pos(',',&line3) > 0)
        &addr2 := ''
        &cityStateZip := &line3
else
        &addr2 := &line3
        &cityStateZip := &line4
endif


That should get you started


Edited by Jean-Cédric (05/18/21 11:58 AM)
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#58009 - 05/18/21 12:56 PM Re: filtering data region from PDF emulation [Re: Jean-Cédric]
tadams1 Offline
OL Newbie

Registered: 05/17/21
Posts: 7
Thank you. Does it matter if I gave you the region definition in metric and I'm working in imperial? I created the global variables and PressTalk object, but nothing displays.

Top
#58010 - 05/18/21 01:02 PM Re: filtering data region from PDF emulation [Re: tadams1]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 650
Loc: Québec, Canada
Simply right-click from the PressTalk editor and choose Data selection. You won't have to worry about such things.
I suggest you zoom to 150% in order to easily select each line.
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top