问题
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