问题
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.
However, the output png file is not of good quality, the text is quite hazy, especially for the images that were present inside the docx file as a part of the document page. I want to improve the quality of the generated image, for that, I tried using the docx.properties file and increase the DPI, but it did not have any effect.
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 it's free to use.
I have a separate question related to multiple pages of a docx file here.
来源:https://stackoverflow.com/questions/59405096/docx-to-good-quality-png-conversion-using-docx4j-in-java