使用DOCX4J转换为PDF时,页面编号会丢失
IM构建一个API,使用DOCX4J LIBARY在Word文件(.DOCX)和PDF中转换XHTML文件。 此时,该应用程序几乎可以很好地处理一些格式的问题。
我使用此代码段将CTSimpleFields添加到我的Word文档中:
CTSimpleField currentPageNumber = factory.createCTSimpleField();
currentPageNumber.setInstr(" PAGE \\* Arabic \\* MERGEFORMAT ");
CTSimpleField totalPageCount = factory.createCTSimpleField();
totalPageCount.setInstr("NUMPAGES \\* Arabic \\* MERGEFORMAT");
如果将文档保存为DOCX
wordZipFile.save(getOutputStream());
但是,当我尝试使用此片段将WordMlPackage转换为PDF时:
FieldUpdater updater = new FieldUpdater(this.wordZipFile);
updater.update(true);
Docx4J.toPDF(this.wordZipFile,this.getOutputStream());
输出PDF文件中缺少页码。
是否有人想知道如何解决这个问题?
Im Building a API to convert XHtml Files in Word files (.docx) and in PDF, using the Docx4j Libary.
At this Moment the Application works almost well with a few little (i think) formatting issues.
I add CTSimpleFields to my Word document using this code snippet:
CTSimpleField currentPageNumber = factory.createCTSimpleField();
currentPageNumber.setInstr(" PAGE \\* Arabic \\* MERGEFORMAT ");
CTSimpleField totalPageCount = factory.createCTSimpleField();
totalPageCount.setInstr("NUMPAGES \\* Arabic \\* MERGEFORMAT");
This works well if the document is saved as docx
wordZipFile.save(getOutputStream());
But when i try to convert the WordMLPackage to PDF using this snippet:
FieldUpdater updater = new FieldUpdater(this.wordZipFile);
updater.update(true);
Docx4J.toPDF(this.wordZipFile,this.getOutputStream());
The page numbering is missing in the output PDF file.
Has somebody an idea how to workaround for this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论