Created attachment 37494 [details] Headers not coming once landscape page come while generating dynamic document HI I am generating dynamic .docx document from another document butheaders for landcape page not coming .Below I have attached .docx file for your reference please find and guide me in stright path
Please provide the minimal java-code that produces the document. The resulting document alone does not help much in analyzing.
(In reply to Dominik Stadler from comment #1) > Please provide the minimal java-code that produces the document. The > resulting document alone does not help much in analyzing. Hi Dominik , Here I have provided method to generate header and Footer code when landscape coming while generating dynamic docx it doesn't support for us private void addHeaderFooter(XWPFDocument document) { try { /** * Header * */ CTSectPr sectPr = document.getDocument().getBody().getSectPr(); if (sectPr == null) sectPr = document.getDocument().getBody().addNewSectPr(); XWPFHeaderFooterPolicy policy = new XWPFHeaderFooterPolicy(document, sectPr); XWPFHeader header = policy.createHeader(XWPFHeaderFooterPolicy.DEFAULT); XWPFParagraph[] parsHeader = new XWPFParagraph[1]; XWPFParagraph paragraph = header.getParagraphArray(0); if (paragraph == null) { paragraph = header.createParagraph(); } paragraph.setAlignment(ParagraphAlignment.LEFT); CTP ctParagraph = paragraph.getCTP(); CTPPr paragraphProperties = ctParagraph.addNewPPr(); CTJc ctJustification = paragraphProperties.addNewJc(); ctJustification.setVal(STJc.LEFT); CTR leftHeader = ctParagraph.addNewR(); CTText leftHeaderText = leftHeader.addNewT(); leftHeaderText.setStringValue(sponsor); CTPTab rightTab = paragraph.createRun().getCTR().addNewPtab(); rightTab.setRelativeTo(STPTabRelativeTo.MARGIN); rightTab.setAlignment(STPTabAlignment.RIGHT); rightTab.setLeader(STPTabLeader.NONE); paragraph.getCTP().addNewR().addNewT().setStringValue(protocol); parsHeader[0] = paragraph; document = paragraph.getDocument(); int pos = document.getPosOfParagraph(paragraph); document.removeBodyElement(pos); /** * Footer * */ Date date = new Date(); String footerText = "Confidential";// "Created " + new SimpleDateFormat("yyyy-MM-dd").format(date); XWPFFooter footer = policy.createFooter(XWPFHeaderFooterPolicy.DEFAULT); XWPFParagraph footerParagraph = footer.getParagraphArray(0); if (footerParagraph == null) { footerParagraph = footer.createParagraph(); } footerParagraph.setAlignment(ParagraphAlignment.LEFT); ctParagraph = footerParagraph.getCTP(); paragraphProperties = ctParagraph.addNewPPr(); ctJustification = paragraphProperties.addNewJc(); ctJustification.setVal(STJc.LEFT); CTR leftFooter = ctParagraph.addNewR(); CTText leftFooterText = leftFooter.addNewT(); leftFooterText.setStringValue(footerText); rightTab = footerParagraph.createRun().getCTR().addNewPtab(); rightTab.setRelativeTo(STPTabRelativeTo.MARGIN); rightTab.setAlignment(STPTabAlignment.RIGHT); rightTab.setLeader(STPTabLeader.NONE); footerParagraph.getCTP().addNewFldSimple().setInstr("PAGE \\* MERGEFORMAT"); footerParagraph.createRun().setText(" of "); footerParagraph.getCTP().addNewFldSimple().setInstr("NUMPAGES \\* MERGEFORMAT"); XWPFParagraph[] parsFooter = new XWPFParagraph[1]; parsFooter[0] = footerParagraph; policy.createFooter(XWPFHeaderFooterPolicy.DEFAULT, parsFooter); } catch (Exception e) { logger.error(e.getMessage(), e); } }