操作word文档在页脚插入图片
操作wod文档在页脚插入图片
public static void main(String[] args) { try { if (!getLicense()) { } } catch (Exception e) { e.printStackTrace(); } String path = "D:\\charu1.docx"; String imageFileName = "D:\\4fa94058-de6d-47c8-a8a0-77b07c739e98.png"; try { Document doc = new Document(path); DocumentBuilder builder = new DocumentBuilder(doc); // Create footer for pages builder.moveToHeaderFooter(HeaderFooterType.FOOTER_PRIMARY); // Insert image builder.insertImage(imageFileName); // Align this text to the right. builder.getCurrentParagraph().getParagraphFormat().setAlignment(ParagraphAlignment.RIGHT); // Save the resulting document. doc.save(path); // for (Section section : doc.getSections()) { //// Up to three different footers are possible in a section (for first, even and odd pages). //// We check and delete all of them. // HeaderFooter footer; // // footer = section.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_FIRST); // if (footer != null){ // footer.remove(); // } // //// Primary footer is the footer used for odd pages. // footer = section.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_PRIMARY); // if (footer != null){ // footer.remove(); // } // footer = section.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_EVEN); // if (footer != null){ // footer.remove(); // } // } doc.save(path); }catch (Exception e) { } }

浙公网安备 33010602011771号