Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is quite a hard task, ever harder if you want perfect results (impossible without using Word) as such the number of APIs that just do it all for you in pure Java and are open source is zero I believe (<em>Update: I am wrong, see below</em>).</p> <p>Your basic options are as follows:</p> <ol> <li>Using JNI/a C# web service/etc script MS Office (only option for 100% perfect results)</li> <li>Using the available APIs script Open Office (90+% perfect)</li> <li>Use Apache POI &amp; iText (very large job, will never be perfect).</li> </ol> <p><strong>Update - 2016-02-11</strong> Here is a cut down copy of my blog post on this subject which outlines existing products that support Word-to-PDF in Java.</p> <p><strong><a href="http://ihaztehcodez.michael-lloyd-lee.me.uk/2010/10/converting-microsoft-office-word-excel.html" rel="noreferrer">Converting Microsoft Office (Word, Excel) documents to PDFs in Java</a></strong></p> <p>Three products that I know of can render Office documents:</p> <p><a href="https://github.com/yeokm1/docs-to-pdf-converter" rel="noreferrer">yeokm1/docs-to-pdf-converter</a> <em>Irregularly maintained, Pure Java, Open Source</em> Ties together a number of libraries to perform the conversion.</p> <p><a href="https://github.com/opensagres/xdocreport" rel="noreferrer">xdocreport</a> <em>Actively developed, Pure Java, Open Source</em> It's Java API to merge XML document created with MS Office (docx) or OpenOffice (odt), LibreOffice (odt) with a Java model to generate report and convert it if you need to another format (PDF, XHTML...).</p> <p><a href="http://www.snowbound.com/format/word.html" rel="noreferrer">Snowbound Imaging SDK</a> <em>Closed Source, Pure Java</em> Snowbound appears to be a 100% Java solution and costs over $2,500. It contains samples describing how to convert documents in the evaluation download.</p> <p><a href="http://api.openoffice.org/" rel="noreferrer">OpenOffice</a> API <em>Open Source, Not Pure Java - Requires Open Office installed</em> OpenOffice is a native Office suite which supports a Java API. This supports reading Office documents and writing PDF documents. The SDK contains an example in document conversion (examples/java/DocumentHandling/DocumentConverter.java). To write PDFs you need to pass the "writer_pdf_Export" writer rather than the "MS Word 97" one. Or you can use the wrapper API <a href="http://www.artofsolving.com/opensource/jodconverter" rel="noreferrer">JODConverter</a>. </p> <p><a href="http://www.maxstocker.com/jdoctopdf/" rel="noreferrer">JDocToPdf</a> - <em>Dead as of 2016-02-11</em> Uses Apache POI to read the Word document and iText to write the PDF. Completely free, 100% Java but has some <a href="http://www.maxstocker.com/jdoctopdf/issues.php" rel="noreferrer">limitations</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload