Using OpenOffice API to generate PDF documents


Based on my previous blog entry, I applied the same technique to programmatically generate PDF documents.

The sample NetBeans project is available for you to download.

This sample does the following :

  • It creates an empty text document (using OO’s writer application)
  • It inserts the content of a template (another document containing text, images, etc …)
  • It searches and replaces occurences of tags (like @name@) with actual data
  • It saves the resuting document as PDF

Using this technique, you can generate professional looking PDF documents from your Java application using only free and open-source softwares.

This was tested on Mac OS X, with Apple’s Java 6 and StarOffice 9 Beta. Enjoy !

As usual, I welcome your comments and feedbacks.

  1. #1 by KAPIL DHAKAD on 04/09/2008 - 07:13

    Hi,

    Your writer to PDF blog looks good. But I need to do some more. We want to do the same thing, but here we have "N" # of data sets available, we would like generate ‘N’ set into the same document.

    Please suggest some solution using open office, I tried mail mereger but it is not working.

  2. #2 by Vanhack on 26/06/2009 - 20:45

    Muy bueno

(will not be published)