Converting multiple pages of a Docx into multiple PNG files

我只是一个虾纸丫 提交于 2020-01-25 07:37:11

问题


I am trying to convert a .docx document into a .png file using Docx4j in java, and achieved the conversion using the piece of code below.

The generated image is for the first page only, while I want to have multiple png files, one for each page of the docx document. I could not find any way to put this thing in a loop or extract the document pagewise.

WordprocessingMLPackage wordMLPckg = Docx4J.load(theFile);

OutputStream os = new FileOutputStream(outFile);
FOSettings settings = Docx4J.createFOSettings();
settings.setWmlPackage(wordMLPckg);
settings.setApacheFopMime(MimeConstants.MIME_PNG);

Docx4J.toFO(settings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);
os.close();

If need be, I can opt for using another conversion library, as long as its free to use.

I have a separate question related to the conversion quality of PNG file here.

来源:https://stackoverflow.com/questions/59405179/converting-multiple-pages-of-a-docx-into-multiple-png-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!