I have 3 snippets in my template, a header, main article then finally a footer.
The main article has a border and may have a few or many lines of content. When it only has a couple of lines I want the height to be automatically resized so it takes up any whitespace on the page without creating a new one (Pushing the footer to the bottom of the final page)
Basically automatically creating the whitespace area marked green in the examples below
Basically you should create 4 master pages (single,first,middle,last):
Single master page: This master page Will contains your header and footer you should set the margin so for example 50mm (header) and 50mm (footer) that means that in that page the content will be placed on between the footer and the header, you will use this master page when you have one single page your document.
To define the margins you must right click on the master page that you wants modify, select properties and then you can set the values.
First master page: You will set the margin but just for the header section like 50mm same as for the single page, you will use this master page when you have multiple pages on your document.
Middle master page: This master page will be use when the content is bigger than 2 pages.
Last master page: You will set the margin but just for the footer section like 50mm same as for the single page, you will use this master page when you have multiple pages on your document.
Understand the idea and Master page options but have a couple of questions.
Firstly, the header and footer sections will be different heights depending on the data so how do I allow for that? Can the margin amount be automatic based on the content?
Secondly, all the content has borders around it. So the for content in the middle (in blue below) I need to either add the white space or resize the article height automatically so the blue border runs all the way to the footer. What is the best way to do this? The default behaviour is the image in the right and I need the one on the left.
It’s not possible to actually control the master page margins programatically - we’ve never had this kind of request before. Headers and footers are generally “static” in their size, but can be different between master pages (aka, your “middle” page could have a smaller version of your header with only the invoice number and pagination, for example). Your control at this point is that you can have up to 4 separate master page “positions” in the sheet configuration, and each of those can have different header and footers of different sizes.
As for the border, the only solution I would see would be to simply add that border to the master pages themselves, and not to the content in the section. If you always want that border to be like Image 1, then you basically want it as a static design element, which is what Master Pages are all about. You’d need to modify your margins in the master pages so that your content actually starts within the boundaries of that box (so, say, 65mm instead of 50mm if we follow Juan’s example above).
When you are using master pages you must to define the configuration of your sheets, rigth click on your print section and select “Sheet Configuration…”, then uncheck the “same for all positions” checkbox like on the images below:
It is complicated as I have a number of sections that appear conditionally on the data and are different heights so it is not possible to use something like Master pages for layout, borders etc.
I can do everything I need to do currently except whitespace management for the key section in blue. I can manually achieve the desired result by adding <br> or empty <p> elements but need a way to script this.
I was thinking a script could check the number of pages in the current document and then add a <br> in the blue section. Then check if the number of pages has increased, if number of pages increased the <br> is deleted and the script ends. If the number of pages hasn’t increased then the loop continues and adds another <br>, recheck pages again etc
Is it possible to check how many pages are in the document via the Scripts/API?
“same for all positions” is already unchecked but unfortunately the size of the margin I would need in the Master Pages is variable based on the data so it would not be practical to use master pages here.
I think this goes somewhat beyond the scope of the forum, as the addition of “more than one section” turns this issue into scripting and possibly professional services territory, way beyond what can be simply shown here on the forums, and probably beyond what Technical Support can help you with, also. Perhaps someone smarter than me can help you out here, though.