I'm generating a word document using Apache POI XWPF. this document includes a footer with Page number but when I convert this word document into PDF, the page number is not displayed:
XWPFRun run = paragraph.createRun();
XWPFFooter footer = headerFooterPolicy.createFooter(XWPFHeaderFooterPolicy.DEFAULT);
paragraph = footer.createParagraph();
paragraph.setAlignment(ParagraphAlignment.CENTER);
run = paragraph.createRun();
run.setFontSize(8);
run.setItalic(true);
run.setColor(header_color);
run.setText("Page ");
//->Also tried with this function but not displayed when PDF is generated paragraph.getCTP().addNewFldSimple().setInstr("PAGE \\* MERGEFORMAT");
run.getCTR().addNewPgNum();
and the part of my code converting into PDF:
PdfOptions options = PdfOptions.create();
OutputStream outWord = new FileOutputStream(new File(out_pdf));
PdfConverter.getInstance().convert(document, outWord, options);
I tried different ways to insert the page number (correctly inserted in word format) but each time I'm converting the document into PDF I'm losing it...