nice to meet u, i have a question.
how to insert different footer in word last page’s footer?
in this link,can only insert first page,i change HeaderFooterType to FOOTER_EVEN,but no effect in doc.
i change HeaderFooterType to FOOTER_PRIMARY,ever page will be has the same footer.
and i use aspose.word in java.
hope and thx ur helpful reply!
@Hypreix
Please use the following code example to insert different footer for the last page of document. You can use the same approach to insert your desired content into the last page’s footer.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Build document.
// Just for testing add few pages.
for (int i = 0; i < 10; i++)
builder.insertBreak(BreakType.PAGE_BREAK);
// Move DocumentBuilder cursor to the primary footer.
builder.moveToHeaderFooter(HeaderFooterType.FOOTER_PRIMARY);
// There is no direct way to have different headers/footers for the last page.
// However, we can achieve this using IF field.
// In our case, IF field code will look like the following:
// { IF "{PAGE}" = "{NUMPAGES}" "This is last page" "This is primary footer" }
// Insert the first part of the IF field
Field field = builder.insertField("IF \"", null);
// Move DocumentBuilder cursor to the next run after field start.
builder.moveTo(field.getStart().getNextSibling().getNextSibling());
// Insert PAGE field.
builder.insertField("PAGE", null);
// Insert operator.
builder.write("\" = \"");
// Insert NUMPAGES field.
builder.insertField("NUMPAGES", null);
// Insert true/false values.
builder.write("\" \"This is last page\" \"This is primary footer\"");
// Save output document.
doc.save(MyDir + "out.docx");
so,how to insert image(qrcode image,already generated) to last page’s footer,now your code just can insert string.ThanksThanksThanks!
@Hypreix
Please replace the following line of code
builder.write("\" \"This is last page\" \"This is primary footer\"");
with the following code snippet to get the desired output.
builder.write("\" \"");
builder.insertImage(MyDir + "image.jpeg");
builder.write("\"");
builder.write("\"This is primary footer\"");