Java calls OpenOffice to convert office series documents into PDF
Leading:
Java is often used to convert office series documents into PDF in the process of distribution. Generally, OpenOffice + jodconverter provided by Microsoft is used to convert documents.
OpenOffice has both windows and Linux versions. Don't worry, the production environment is Linux.
1. OpenOffice relies on jar. Take Maven as an example:
2. To directly up convert code, you need to listen to port 8100 of OpenOffice application.
3. Note: jodconverter is converted to XXX after version 2007 The docx document will report an error because everyone knows the 03 suffix XXX Doc 07 later version XXX docx
Check the source code of jodconverter and find that documentformat does not support XXX Docx format the default support for public documentformat getformatbyfileextension (string extension) in basicdocumentformatregistry is doc format
Source code of basicdocumentformatregistry class
The file formats supported in the default implementation class defaultdocumentformatregistry of basicdocumentformatregistry are as follows
Solution: override the public documentformat getformatbyfileextension (string extension) method in the basicdocumentformatregistry class. As long as the suffix contains doc, the document format of DOC will be used
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.