In your projects you may need to convert DOC files to PDF.

The presentation below will try to guide you how to do it.

If you want to contribute with another solution, please feel free to contact me.

DOC to PDF with Java

You can use OpenOffice.org(must be available on the same computer or in your network) for document conversion.

Besides DOC to PDF, there are also possible other conversions:
doc --> pdf, html, txt, rtf
xls --> pdf, html, csv
ppt --> pdf, swf
html --> pdf

Code example

import officetools.OfficeFile; // this is my package, officetools.jar // uses streams for I/O FileInputStream fis = new FileInputStream(new File("test.doc")); FileOutputStream fos = new FileOutputStream(new File("test.pdf")); // suppose OpenOffice.org runs on localhost, port 8100 OfficeFile f = new OfficeFile(fis,"localhost","8100", false); // optional feature: can be used to replace a string in .doc, .odt or .sxw files // thus can be used to populate templates f.replaceAll("aaa","bbb"); // convert to pdf f.convert(fos,"pdf");


How to obtain this solution

officetools.jar is not free(in order to sustain future developments), but it has a very reasonable price.
Available: as jar or as jar+sourcecode. In both cases you get project details, javadoc, setup instructions, examples.
If you want to use this solution in your projects, please contact me for a price quotation:
Contact