aspose file tools*
The moose likes Other Open Source Projects and the fly likes Java API to convert from Excel to PDF? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Java API to convert from Excel to PDF?" Watch "Java API to convert from Excel to PDF?" New topic
Author

Java API to convert from Excel to PDF?

M Burke
Ranch Hand

Joined: Jun 25, 2004
Posts: 388
I need a Java API where I can feed an existing Excel spreadsheet file to a method and have it create a PDF version. The Excel was generated using POI.

I looked at a few commercial API's., most notable Adobe. But Adobe appears to use a Session Bean, which I cannot use since no EJB server is available in my environment. I need a plain POJO implementation, not calling any outside service.

I also looked at iText. They talk about converting from PDF to Excel, but not the other way around. Maybe it does, but I can�t find any reference to it.

Any ideas?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42612
    
  65
I don't know of any library that does this, apart from OpenOffice - it can open XLS files, create PDF files, and has a Java API that you could use to drive this process. That has a steep learning curve, though.

I'd probably create the PDF at the same as the XLS file, using the iText API. Or, if it's not feasible to do it at the same time, use POI to open it later, and then use iText to create the PDF.

(By the way, can you point to where the iText docs talk about PDF-to-XLS conversion? I'd be interested in that.)


Ping & DNS - my free Android networking tools app
M Burke
Ranch Hand

Joined: Jun 25, 2004
Posts: 388
I saw it on a forum, but now I can't find it. But I do remember people suggesting using Apache POI rather than iText to generate Excel.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42612
    
  65
Ah, OK. I've used iText extensively, and have never encountered anything that suggests it might be useful for creating XLS files.
zett ucu
Greenhorn

Joined: Jan 15, 2009
Posts: 4
a team in my comp is using this on a project:

import officetools.OfficeFile;
...
FileInputStream fis = new FileInputStream(new File("test.xls"));
FileOutputStream fos = new FileOutputStream(new File("test.pdf"));
OfficeFile f = new OfficeFile(fis,"localhost","8100", true);
f.convert(fos,"pdf");

All possible convertions:
xls --> pdf, html, csv
doc --> pdf, html, txt, rtf
ppt --> pdf, swf
html --> pdf
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42612
    
  65
Also check out the JODConverter library (which uses OpenOffice behind the scenes).
 
 
subject: Java API to convert from Excel to PDF?