Question
ESTK - Adding a blank page at the end of the document
For previous documents, there was a requirement for the document to end with Page X/(Y Blank).
I have a script that @Russ Ward helped me with to accomplish this. The script:
- Goes through Pages 2 to the end of the document and removes any custom master pages.
- Checks the last page of the document and determines if it is odd or even. If it is odd, it applies an X/Y Blank Master page and updates the page numbers in the footer.
The script works fine, but I have a new requirement to add a blank page after the X/Y Blank page. (A totally blank page, not an empty page with the header, footer, and page number.)
So I need two things added to the script:
- If the doc ends on an odd page, I need to add the blank page. To do that, I thought I needed to add a paragraph at the end of the document, have it start that on an right-hand page, and set the page background to none. I added this code, but it doesn't seem to be working (doc is previously defined as app.ActiveDoc):
var pgf = doc.FirstPgfInDoc;
while (pgf.ObjectValid()) {
pgf = pgf.NextPgfInDoc;
}
// Add New Paragraph
var pgf2 = doc.NewSeriesObject(Constants.FO_Pgf, pgf);
pgf = doc.LastPgfInDoc;
var props = pgf2.GetProps();
pgf2.SetProps(props);
pgf2.Start = Constants.FV_PGF_TOP_OF_RIGHT_PAGE;
var bodyPage = doc.LastBodyPageInDoc;
bodyPage.PageBackground = Constants.FV_BGD_NONE;
There is an anchored frame at the end of the document with "THE END" inside it, so I need the last paragraph in Flow A - which might be why my script doesn't seem to be working.
- At the start of the script, I need to check for and remove empty paragraphs at the end of the document (From times the script was previously run). I'm not sure how to do this. I have a function that checks for disconnected flow pages, but this is not a disconnected flow page, nor technically an empty page - it has a paragraph on it, just no text in the paragraph.
Thanks in advance!
