IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#57659 - 09/01/20 05:17 PM Count occurrence of "FirstPG" in PDF
dstauder Offline
OL User

Registered: 06/28/02
Posts: 78
Loc: St. Louis, Missouri USA
I am looking to create a document that counts total number of pages in the PDF and returning the count of the occurrences of "FirstPG" in the upper left corner of the page.

Metadata takes care of the total number of pages in the document but I cannot seem to count the number of "FirstPG" occurrences in the document in the upper left corner.

Thank you in advance for your assistance.

Dan

Top
#57660 - 09/02/20 08:28 AM Re: Count occurrence of "FirstPG" in PDF [Re: dstauder]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
Still use the metadata.

In your form:
- Add a metadata field, at the document level
- Everytime you see a FirstPG, you increment the metadata field by 1 using GetMeta() and Definemeta()


Edited by Jean-Cédric (09/02/20 08:29 AM)
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#57673 - 09/10/20 11:12 AM Re: Count occurrence of "FirstPG" in PDF [Re: Jean-Cédric]
dstauder Offline
OL User

Registered: 06/28/02
Posts: 78
Loc: St. Louis, Missouri USA
I have defined the FirstPG Metadata field as follows:

TalkID = FirstPG
Level = Document
Field Value = FirstPG
Condition = Blank
Create action = Append Value

I am not sure how to use the Definemeta function.

This returns all of the FirstPG values it finds and appends them together i.e. FirstPGFirstPGFirstPGFirstPG

How do I use Definemeta to get the count?

Top
#57674 - 09/10/20 12:03 PM Re: Count occurrence of "FirstPG" in PDF [Re: dstauder]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
The metadata field will contain a number which indicates how many time FirstPG has been found.

When you create it:
Code:
PlanetPress Talk ID: <your field name>
Level              : Document
Fields             : Value        : 0, 
                     Condition    : =true
                     Create Action: Add value


On the Press Talk Before of a form page that always execute, add the following Press Talk code:

Code:
if(regionline(0.24,4.05,1.19,4.27) = ' Page 1 of')
        definemeta('NbFirstPGOccurences',inttostr(strtoint(GetMeta('NbFirstPGOccurences',10,'Job.Group.Document'))+1),0,'Job.Group.Document')
endif()


regionline() need to be replaced by your own data selection in your PDF for FirstPG.
' Page 1 of' need to be replaced by 'FirstPG'
NbFirstPGOccurence need to be replaced by your own metadata field

Basically, everytime that the string you are looking for is found, definemeta changes the value that it got from getmeta(), incremented by 1.
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#57675 - 09/10/20 12:55 PM Re: Count occurrence of "FirstPG" in PDF [Re: dstauder]
dstauder Offline
OL User

Registered: 06/28/02
Posts: 78
Loc: St. Louis, Missouri USA
I created a condition for FirstPG and then went to the Document and created a document marker to look at the FirstPG condition.

I am then using that to count the number of occurrences.
I only need a 1 page report for the PDF data file. An example is 27 documents and 156 total pages.

When I create the report, I am getting 156 pages. I only need one. Is there a way to suppress pages 2 to 156?

Top
#57676 - 09/10/20 01:05 PM Re: Count occurrence of "FirstPG" in PDF [Re: dstauder]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
Setup a condition for your report form page to only be executed on datapage 1.

Make sure that your counter of FirstPG isn't on that form page.
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top