DOCX to good quality PNG conversion using docx4j in java

孤人 提交于 2019-12-24 21:23:19

问题


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

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