Question
How to capture the Header and Footer elements of the multipage document if the only unique elements are "Page 1 of X" on the first page and "Page X of X" on the last page?
Answer
In the Header group, create a "Static Text" element with the value of "Page 1 of", with either an Absoulte search area constraints or Nearest to the Page bottom edge relation.
The following components should be used in the footer section of the layout, feel free to change the names but remember to do the same in the script reference. Feel free to adjust the relations between each element to fit the respective document template.
-
stPage:
A static text element looking for the "Page" text. -
csPageOf:
A character string field using the regular expression N{1-}"of"N{1-}. It will be extracting the "x of n" part on the page. Should be found to the right of stPage.
-
stPageOf:
A static text field looking for “of” inside the region defined by csPageOf. -
csPageR:
A character string field (alphabet 0123456789). It is to the right of (and closest to) stPageOf, using the csPageOf element to define the search area. -
csPageL:
A character string field (alphabet 0123456789) to the left of (and closest to) stPageOf, using csPageOf element to define the search area. Should be a Required element.
To make sure the footer is found on the last page of the document, the following code is added to the Advanced post-search relations for csPageL (it compares csPageL and csPageR numbers whether they are the same):
if not IsNull and (not csPageR.IsNull) then
{
string PageTotal;
PageTotal = csPageR.Value;
string PageCount;
PageCount = value;
if PageCount != PageTotal then Quality: 0;
}
By doing this, even if a file with multiple documents is used, the sample will be separated by the presence of Page 1 of X in the Header, and Page X of X in the Footer.
Comments
0 comments
Please sign in to leave a comment.