Hi
Hi
Graham,
An empty page can be caused by unnecessary empty paragraphs at the end. You can try removing all empty paragraphs from the end of the document. by using the following code:
while (!doc.LastSection.Body.LastParagraph.HasChildNodes)
doc.LastSection.Body.LastParagraph.Remove();
Thanks Awais
The last line of code that adds items to my document is often
builder.InsertBreak(BreakType.PageBreak);
so my docuement ends with a PageBreak and a final Paragraph mark.
I need to remove that PageBreak.
I might also need to set the font size of the last paragraph to 1point as well (a technique I often use to 'encourage' training paragraphs onto the previous page)
typo - ‘trailing’ not ‘training’
(didn’t see the edit button) doh!
Hi Graham,
foreach (Run run in runs)
{
if (run.Text.EndsWith("\f"))
run.Text = run.Text.Replace("\f", "");
}
Thanks Awis
That removed all of my page breaks!
I have combined the two you gave me, although I think it could be improved, I'm not sure what a 'run' is, but I suspect I don't really need the foreach as I will be in the last paragraph
This works :)...
private void RemoveTrailingPageBreaks(Document doc) {
NodeCollection runs = doc.LastSection.Body.LastParagraph.GetChildNodes(NodeType.Run, true);
foreach(Run run in runs) {
if(run.Text.EndsWith("\f"))
run.Text = run.Text.Replace("\f", "");
}
}
Hi Graham,