Hi,
I am trying to have a variable footer size for my first page based on certain conditions. This does work but since I must set the bottom margin in a post pagination script it does this for the entire document and I am unable to do this for only the first page.
I tried to be smart and create a tfoot section for my order table. I created a post pagination script to handle everything:
let curpage = 0, count = 0;
let tmpVal;
let result;
let prodcode = record.tables.ORDER[0].tables.ORDPROD[0].fields.prodcode;
/* For some reason it is not possible to rely on the value returned for the margins so I give it an initial size here */
//merge.section.margins.bottom = "2.6in";
// Get the total number of pages
count = merge.context.query("body").info().pageCount;
// Target the table footer for each individual page
merge.context.query("tfoot").each(function() {
// It seems a paginate activates my disabled segments again so I will just start with a placeholder instead of filling it already with my whole bottom table
if (this.info().pageNo == 1) {
result = loadhtml("snippets/DGDSeeRiderPage.html");
results.find("@SeeRiderPage@").html(result);
result = loadhtml("snippets/DGDSubFooter.html");
results.find("@tbldgdfooter@").html(result);
//query(".SeeRiderPage", this).replaceWith(result);
} else {
results.find("@SeeRiderPage@").html("");
results.find("@tbldgdfooter@").html("");
}
// A See Rider Page text should only appear on the first page when there are more than 1 pages
if ((this.info().pageNo > 1) && (count > 1)) {
query(".SeeRiderPage", this).hide();
}
// Do some extra validation for page one. The rest of the pages should not even have the footer at all
if (this.info().pageNo == 1) {
/* Check if we need to adjust the margin to fit the product info block */
if ((prodcode != "EMPTY/DIRTY" && !record.fields.sameORDPROD) || (prodcode == "EMPTY/DIRTY" && !record.fields.samePREVPROD)) {
}
} else {
logger.warn("Current page: " + this.info().pageNo);
this.hide();
}
});
// And do a paginate after the layout is correct
//merge.section.paginate();
/* There seems to be a bug in the system where it shows the placeholders in the first row after a paginate so I have to find and replace them all with an empty string */
results.find('@DGD1_Col1@').text("");
results.find('@DGD1_Col2@').text("");
results.find('@DGD1_Col3@').text("");
results.find('@DGD1_Col4@').text("");
results.find('@DGD1_Col5@').text("");
results.find('@DGD1_Col6@').text("");
Without the paginate everything just overflows to the next page but at least it will skip my details footer block as it is supposed to do.
When I enable paginate it overflows nicely but my footer block is displayed on the second page (third is disabled since I only show the footer on a page break):
Why does this happen with a paginate even though I specifically told it that I do not want this block on any page but the first one?
I have also tried to add the blocks to my print context and the show/hide div sections or a tr based on the page. But then paginate just leaves the places where there was a block (which now is hidden) blank and does not reorganize the rest of the page. So I get a lot of empty blocks.
Is it possible to make this work like I want to?
Note that I already tried several different options:
- dynamically changing the margins (doesn’t work since this is applied over all pages)
- creating a second print context with the correct layout (doesn’t work since the orders table stays within a single print context and cannot span multiple print context)
- doing a paginate for each page (doesn’t work since this seems to stop the rest of the pages from being processed and then I’m missing a lot of order lines)
- and now this attempt
Any help would be appreciated.