Is there a way to convert a xls file into a pdf?
I want to make a dynamical report directly to pdf file, but didn't find a way to make dynamic columns on iReport, so I've made a method on Java that exports to xls dynamically.
So I was wondering if is there a way to convert this file to pdf, but it need to be on a method from my code. Or if you have a better idea, it can be used too.
Maybe there's a way to make this pdf file from my code as I did with xls. Please help me out.
Thanks.
Try using iText http://itextpdf.com/ - I've used it to create PDFs with columnar structure.
In addition to using iText directly, there are a couple report engines that sit on top of it:
Eclipse BIRT (using 2.1.7, the last MPL/LGPL version)
Jasper Reports (which uses a Very Old version, 1.3.1 IIRC)
This is a commercial solution:
http://www.dancrintea.ro/xls-to-pdf/
If you want open source try jakarta POI.
Try using the Muhimbi PDF Converter Services. It comes with a Java compatible Web Services based interface and sample code. It does other things as well.
I worked on this application, so the usual disclaimer applies.
Related
I want to be able to generate .docx files through either Java or Python based off of a template .docx file. I need to be able to insert in simple text, some bullets and a table or two.
I would like suggestions on specific libraries/modules for either Python or Java that would allow me to load a template, insert basic text and tables and then save it.
I have been looking into JACOB for Java and docx for Python. Any alternatives? Or will one of these be able to do what I need?
Thanks in advance
If you want to generate a docx, than you might like docxtemplater, which is a library I maintain which does docx generation from a template (much like Mustache for HTML).
It runs on node but has a command line interface so you can use it from any language.
DocxTemplater Library
Demo Site
Give docx4j as a choice, it's based on Apache POI but with better documentation
Did you look at Aapache POI (the Java API for Microsoft Documents) project?
http://poi.apache.org/
Good luck!
[Background Info]
We had a solution in place to use Word automation serverside to convert HTM documents into Docx, PDF or Print documents. This solution broke in the latest version of Windows Server 2012. We learned that MS does not intend on Word working in this manner and after trouble shooting with MS support Engineers we have come to the conclusion that it will never work.
[Currently]
I am currently researching potential technologies and tools that my company can use to regain this functionality. We need to be able to create Docx, PDF and print files to a local printer.
I have looked into a number of tool already and I am currently leaning towards Apache FOP this seems to handle PDF and Printing for us.
However, I'm looking for some advice and suggested tools that we could use to implement a pure Java approach. Currently our application creates HTM files with all the required information. So ideally we would like to take these HTM files and "Convert" them into Docx/XLS-FO format.
[Question]
So my question that I'm hoping you will be able to help me with.
What is the best tools that I can use to get from
HTM to Docx
HTM to PDF
Or what would be the best process for achieving this? has anyone had success finding a solution for this in the past?
Thank You
It depends on the level of control and the complexity of the source HTML. There are HTML to FO stylesheets but you might find them wanting for your specific need.
So you could use the Jericho parser to read the HTML and generate FO. Or you generate the target format directly using Apache PDFBox and Apache POI
It all boils down to the level of control you want/need
docx4j-ImportXHTML will get you from XHTML to docx. From there, you can use docx4j (or some other solution eg LibreOffice/OpenOffice) to do docx to PDF.
docx4j supports docx to XSL FO, and by default uses FOP.
I have some PDF template (with header and footer). I want to generate documents that are based on that template.
Is there any way to do that with iText? Thank you
P.S. Right now I am generate a document on-fly i.e. every time I generate header, footer and the context itself.
UPDATE: I have found incredible library called PD4ML. It's not free, but not such expensive, BUT it has really cool features such as HTML2PDF conversion on fly, supports a lot of HTML-CSS tags and has even its own jsp tags library! So I really suggest it when you need something instead of heavy and memory-eating JasperReports.
You can use JasperReports library and the iReport visual designer.
JasperReports use iText to produce PDFs from "jasper" templates, that are XML files (following the jrxml DTD) compiled in java classes, but allows you to use the template for generating MS Office files (with POI), html, etc.
Im not sure with iText, but you can use BIRT for this purpose. http://www.eclipse.org/birt/ Its too much using it just for PDF creation, you can do a lot (more than you can imagine) with it.
If you can choose your template format. I would go with JODReport and JODConverter.
JODReport use an ODT template and fill the mapping in the template with your java code.
JODConverter use LibreOffice to convert such template in PDF or whatever fortmat LibreOffice can handle to export.
You have to be able to use LibreOffice as a service installed remotely on a machine.
I used it back in 2012 but not sure if the project is still active
I want to convert .doc/.xls file into PDF through my java application. Now, I know there have been some discussions on this topic. I also know that JODConverter is one option, but the problem with this is dependency on OpenOffice. Whoever wants to use my app will first need to install OpenOffice on his/her host. I want to avoid this. Do we have any new solution through which I can do this conversion in my app without having dependencies on any other applications.
You could use POI for reading XLS and DOC, and use iText for generating the PDF.
POI project:
http://jakarta.apache.org/poi/
iText project:
http://www.lowagie.com/iText
I am very new to java. I am trying to fetch some data from a database and the result set is displayed in excel. I am able to inetract with database. But how should I go ahead for inserting data into excel sheet.Its simple Java program and in future I would like to generate files in other format say PDF, doc etc.
I am looking for an approach with lesser load on CPU, faster.
thanks in advance for help.
Just spit out a CSV file. It's lightweight and portable. You can grab a csv writer from Apache commons I think but spending the 10 min it would take to write one might be a good learning exercise as well.
If you want a real solution where you want different outputs (eg excel, pdf, rich text etc) then use a reporting tool. There are plenty of opensource tools like ireport which will let you create a template then write a simple java app that renders that to pdf, excel etc. Otherwise you will end up doing it by hand. It's a bit heavyweight but anything more than trival tabular output will be easier.
Apache POI is for you in this case, but you will find it a little bit overwhelmed if you just need to write/read data from an excel file.
Try jExcel instead, the API is simple and straightforward, you can also manipulate sheets within an excel workbook.
The easiest and standard way of doing this is to use POI library:
http://poi.apache.org/spreadsheet/quick-guide.html
The new xlsx format is based on Open-XML and would provide a method of generating these files without any dependency on Microsoft-office COM libraries -- the same could done for docx and pptx formats later, as well as other open-Xml formats like EPUB.
The Apache POI project looks like it might provide one possible solution. There's also an article on the MSDN interop blog that discusses this in some detail.
The key words you should google for are OLE and DDE.
Though, Java is not the best language for interface Microsoft's software.
for generating excel i think you should try simreport in jsimreport.com. in my opinion, it's quite simple to make an excel report, it uses the excel sheet to generate report so easy to config and visually