ABBYY Flexi Layout - How to use footer to determine number of pages

  • Last Post 16 May 2018
  • Topic Is Solved
CSL_ posted this 08 May 2018

I have a multi-page document with min = 1 and max = 2.

If only page 1 exists, I will use footer from page 1. This is fine. If page 2 exists, I want to use footer from page 2. But, I cannot differentiate both scenario, since footer will always start searching from min to max, so it will only capture footer in page 1 as the only page in my document. 

How can I design the layout to cater both scenario ?

Order By: Standard | Newest | Votes
AlexeyEfremov posted this 11 May 2018


Without specific documents it would be hard to propose the solution, but here is somewhat general recommendation:

lets say you have 2 pages:

On the first page there is a text "Start of page 1" on the top and text "End of page 1" on the bottom

On the second page is a text "Start of page 2" on the top and text "End of page 2" on the bottom

You create 2 elements, first that looks for "End of page 1" text and the second that looks for "End of page 2" text. Let's name them "possibleFooter1" and "possibleFooter2". You place BOTH of the elements in the footer.

Than you create a static text element SecondHeader2 that searches for "Start of page 2" text. Do not place this element in the footer of header.

Then in the Advanced Presearch relations in the properties of possibleFooter1 you paste this script:

if SecondHeader2.isFound then DontFind;

In the Advanced Presearch relations in the properties of possibleFooter2 you paste this script:

if not SecondHeader2.isFound then DontFind;

This way your footer will match the first page if the start of the second page is not found and it will match the end of the second page if it exists.

If this does not help you, please send us a few samples and let us know your exact FC version. (Project setup station > Help > About)





CSL_ posted this 14 May 2018

Are both header and footer elements set to required ? Do you mean Header only has one element which is Header1 in first page, Footer has two elements which is possibleFooter1 and possibleFooter2, then SecondHeader2 is a static text does not belong to Header or Footer ?

But I can't set the properties in the Advanced Presearch relations since the footer elements always come first before other static text elements. 

If I put SecondHeader2 under Header, it is not correct too as it will always fail to recognize on the second page. 

CSL_ posted this 14 May 2018

I get what you mean finally, to illustrate

Header (Required)

   - Header1 (Required)

Footer  (Optional)

   - Header2 (Required)

   - Footer1 (Required)

   - Footer2 (Required)

Footer1 and Footer2 add condition as what you mentioned earlier, find based on Header2. 

I am using Build

AlexeyEfremov posted this 14 May 2018

Yes! I'm sorry for my clumsy explanation.

Do you steel need a sample project? I have started it just now. Should I finish and send it to you?

CSL_ posted this 14 May 2018

Yes sure, thanks for your help. This will help me to understand clearly.

AlexeyEfremov posted this 14 May 2018

Hello, while making the sample (link is below), I have encountered the issue.

When the pages are out of order, for example:

- first page

- some appendix page

- second page

In this case the document will contain first page and appendix.

There could be 2 workaround for this issue:

1. Create 2 flexilayouts for the first and second page and add them as sections to the FC definition. Configure assembling rules.

2. If the first workaround does not work in your case, You can:

a) create 3 definitions: 1 - first page only, 2 - second page footer only and 3 - both pages.

b) set all 3 definitions in order 1-2-3 and set "Use first acceptable flexilayout"

c) on a recognition stage allow only definitions 1 and 2.

d) after the recognition stage in a batch processing script check if there are cases where 2 goes in order after 1 immediately. Form a new document from this 2. Set the document status to Excluded from automatic assembly in script.

e) place a second recognition stage after  a batch processing stage and apply the 3rd definition whenever necessary.

The last workaround should work unconditionaly.





CSL_ posted this 15 May 2018

Hi, I notice in the sample, footer is disabled. In this case I would not be able to determine the end of my document ?

What if my pages are like :

- first page

- second page

- annex page

My maximum pages are 3, so it will take up annex page as well, right ?








AlexeyEfremov posted this 15 May 2018


I have sent you another version :), please check the link again to find the right one.

But the version you have already seen is also a working one. Please have a look at the SubHeader2222222222 elements search constraints: It could be only located on the last page only.

So SubHeader2222222222 element is basically a footer, but outside of the special "Footer" element.

To your second question the answer is no, because you have already set up a restriction on a number of pages in the definition:



CSL_ posted this 16 May 2018

I think my problem is that if my document is only one page, it will still take up the second page as defined in the Maximum number of pages. Because footer is not used. 



AlexeyEfremov posted this 16 May 2018

Well, in that case, you can use the 2 workaround i proposed earlier.