Render docx file in a browser

懵懂的女人 提交于 2019-12-12 02:09:06

问题


I'm using docx4j to convert a microsoft word document into a pdf then displaying it in a browser http://www.docx4java.org/trac/docx4j and it works well for a preview. The problem I'm facing is that this conversion loses most of the microsoft word document formatting. Page breaks and fonts don't transfer into the PDF format properly and even though I'm using standard font types docx4j doesn't come with them. In a Linux Tomcat hosted scenario fonts are not found and throw exceptions as it falls back to sans serif or other generic types.

I have found this Microsoft tool to make documents render online, but I'm behind a firewall so I cannot include this tool as an option: https://products.office.com/en-us/office-online/view-office-documents-online

I'm open to suggestion on displaying a docx file as a preview and print option from within a browser. Pdf conversion appears to be the most promising, but I run into formatting issues.

Any ideas are welcome!


回答1:


Have a play with http://converter-eval.plutext.com/viewer.html

Consider it an alpha level preview. We haven't quite released it yet, but you will be able to host it behind a firewall.

It isn't open source, I'm afraid, and we're still working out pricing (and whether/how there could be a free edition).




回答2:


If you only need to render a docx document in a browser, u can use Google Documents Viewer for this as :

<iframe src="http://docs.google.com/gview?url=pathOfDocx&embedded=true" />


来源:https://stackoverflow.com/questions/36090927/render-docx-file-in-a-browser

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