I have written a java program to create math questions for my son, and I would like to print the questions off as a worksheet, in a nice big font. So a few (like 5) rows and a few (like 3) columns of questions per page, nice and easy to read and work with. The computer I program on doesn't have access to a printer, so I would like to save them to a file and then later print them off.
I don't believe a standard text file will allow changing the font size.
I'd like to use a free, open source library.
I'm not sure what will be the easiest way to go: pdf, OpenDocument, HTML, something else?
First I started looking at generating pdf files, but without much early success I decided to try OpenDocument format. I installed the apache odfdo-java-0.8.11-incubating.jar and the xercesimpl.jar, but I am now getting java.lang.NoClassDefFoundError: net/rootdev/javardfa/StatementSink errors. I can't seem to figure that out and have spent a few hours trying to sort it out.
So I am taking a step back and wondering if there is a better way.
Any help will be appreciated. I am using IntelliJ Community Edition on Ubuntu with java 1.8.
Visit http://community.jaspersoft.com/project/jasperreports-library. The license is LGPL. This is a library for Java. You can to generate rtf, pdf, csv documents.
For design the report you can use iReport. Visit https://sourceforge.net/projects/ireport/files/iReport/iReport-5.6.0/. This is a powerful tool that you must to use with JasperReport.
Good luck
i am searching for a server side java chart api. i already played with jfreechart but it produces ugly charts and finetuning the look seem to be complicated.
now i am looking at the free bi tools. the problem with all of them (birt, jasper, pentaho, ?) is that the documentation is focusing on WYSIWYG Reporting.
My perspective is different. i have webapp(gwt) and data (pojo, representing pivot tables that are published as html and pdf) in place and want output nice looking charts (svg,png, svg with js?). It would be nice if the chart layout/look could be adjusted by a wysiwyg tool afterwards - but this is not a must have.
So what tool creates nice looking charts out of the box? and has a good documented api to integrate on server side (a get started tutorial would be nice)?
The first problem i have to solve is to make "reports" out from my pojos ("table").
Clarification: as the topic implies i need a java based solution on server side (the charts are also published as pdf/png in documents to be exported). at the moment the only suggestion remains jfreechart?
What about the charting api contained in bi solutions like birt/jasper/pentaho...?
JFreeChart is one of the most popular charting engines for Java applications. If you didn't like its output, I am not sure you will like any output.
Another thing to note is that JasperReports is using the same JFreeChart for rendering its charts. I am not sure about this, but I think Pentaho does the same.
If you only need charts and not full reports, I would suggest you use JFreeChart. If you learn it well, you will definitely get nice looking results.
The last question in the JFreeChart FAQ page provides a full list of other Java based charting libraries. You may want to take a look at that.
I recommend using jqPlot. I has very good looking and powerful apis to render charts in browser using svg and can give you jpg outputs too.
Primefaces has also wrappers around jqPlot and jFreeChart so you can use it to render charts easily but will not have flexibility like using pure jqPlot. Using Primefaces can fit exactly with your requirement to render charts from POJOs.
Fore more info see Primefaces demo.
I think it is possible yet very hard to make JFreeCharts look good. I guess it is the most advanced PNG-outputing chart lib for Java. Most of charting libraries are now JavaScript based either non-free amCharts or free jqPlot. I'd recommend using jqplot if you can show charts in browser only and don't need to generate PDG server-side (I'm not sure if it is possible with jqplot).
You may want to try some new libs. These look promising:
charts4j
easycharts - see licensing for this one
As for reporting platforms I was evaluating BIRT, Jasper and Pentaho and I found BIRT the easiest and most promissing. You can implement your own datasource for BIRT (it doesn't need to be SQL) and build reports from POJOS.
ok i got started thx to links i got here:
http://www.birt-exchange.org/org/devshare/designing-birt-reports/463-birt-chart-engine-api-webinar-examples/ - contains a ppt presentation and many easy example
http://wiki.eclipse.org/BIRT/FAQ/Charts2.2 - good overview
At first sight my hope has fullfilled:
the charts out of the box looking better
the api/ architecture seems more flexible/ better organized (e.g. chart layout/colors could be specified as xml)
overall better feeling on using open source eclipse stuff (don't ask why)
much better svg rendering - interactive with javascript!
Does anyone know a decent Java API that could be used to plot data? (I'd say it should be 'almost' as good as Excel)
If not, any way to integrate a Java program into Excel?
Currently, I have to write the output of my java program to text files, then write a macro to load the data into the Excel spread sheets and do the plotting there.
Thanks much!
You can try JFreeChart. It's pretty good, open source and pretty actively devoloped. It can also be integrated with other tools such as JasperReports (if you want to output HTML and/or PDF files).
jXLS
It supports:
Complex object graph export
Dynamic grouping of data
Charts, Macros and many other Excel features in XLS template
and many more...
Example at Basic Chart Sample
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I have a new app I'll be working on where I have to generate a Word document that contains tables, graphs, a table of contents and text. What's a good API to use for this? How sure are you that it supports graphs, ToCs, and tables? What are some hidden gotcha's in using them?
Some clarifications:
I can't output a PDF, they want a Word doc.
They're using MS Word 2003 (or 2007), not OpenOffice
Application is running on *nix app-server
It'd be nice if I could start with a template doc and just fill in some spaces with tables, graphs, etc.
Edit: Several good answers below, each with their own faults as far as my current situation. Hard to pick a "final answer" from them. Think I'll leave it open, and hope for better solutions to be created.
Edit: The OpenOffice UNO project does seem to be closest to what I asked for. While POI is certainly more mainstream, it's too immature for what I want.
In 2007 my project successfully used OpenOffice.org's Universal Network Objects (UNO) interface to programmatically generate MS-Word compatible documents (*.doc), as well as corresponding PDF documents, from a Java Web application (a Struts/JSP framework).
OpenOffice UNO also lets you build MS-Office-compatible charts, spreadsheets, presentations, etc. We were able to dynamically build sophisticated Word documents, including charts and tables.
We simplified the process by using template MS-Word documents with bookmark inserts into which the software inserted content, however, you can build documents completely from scratch. The goal was to have the software generate report documents that could be shared and further tweaked by end-users before converting them to PDF for final delivery and archival.
You can optionally produce documents in OpenOffice formats if you want users to use OpenOffice instead of MS-Office. In our case the users want to use MS-Office tools.
UNO is included within the OpenOffice suite. We simply linked our Java app to UNO-related libraries within the suite. An OpenOffice Software Development Kit (SDK) is available containing example applications and the UNO Developer's Guide.
I have not investigated whether the latest OpenOffice UNO can generate MS-Office 2007 Open XML document formats.
The important things about OpenOffice UNO are:
It is freeware
It supports multiple languages (e.g. Visual Basic, Java, C++, and others).
It is platform-independent (Windows, Linux, Unix, etc.).
Here are some useful web sites:
Open Office home
Open Office UNO Developer's Guide
OpenOffice Developer's Forum (especially the "Macros and API" and "Code Snippets" forums).
I think Apache POI can do the job. A possible problem depending on the usage your aiming to may be caused by the fact that HWPF is still in early development.
HWPF
is the set of APIs for reading and
writing Microsoft Word 97(-XP)
documents using (only) Java.
You could use this:
http://code.google.com/p/java2word
I implemented this API called Java2Word. with a few lines of code, you can generate one Microsoft Word Document.
Eg.:
IDocument myDoc = new Document2004();
myDoc.getBody().addEle(new Heading1("Heading01"));
myDoc.getBody().addEle(new Paragraph("This is a paragraph...")
There is some examples how to use. Basically you will need one jar file.
Let me know if you need any further information how to set it up.
*I wrote this because we had one real necessity in a project. More in my blog:
http ://leonardo-pinho.blogspot.com/2010/07/java2word-word-document-generator-from.html
*
cheers
Leonardo
Edit : Project in link moved to https://github.com/leonardoanalista/java2word
Try Aspose.Words for Java, it runs on any OS where Java is installed.
It will output the document to DOC, DOCX or RTF if you need an MS Word output format. All are supported equally well.
Using this API you can create a document from scratch, literally from nodes and set their formatting properties. You can also use a DocumentBuilder which provides higher level methods such as create a table row, insert a field etc. Or you can copy/join/move portions between existing pre created document, say you want to assemble a contract, just grab and copy pieces from several documents and Aspose.Words will merge styles, list formatting etc properly in the resulting document.
You will be able to insert a TOC field using Aspose.Words, but as of today, the TOC field will require a field update when the document is opened in Microsoft Word. However, we are going to release full support for TOC fields early in 2010. E.g. it will build complete TOC as MS Word does it.
I'm on the Aspose.Words team.
It was mentioned only briefly once, so I'd like to call out the docx4j library, as I've had more success with docx4j than anything else. Apache POI's support for Word documents isn't very good. Also, unlike Aspose.Words, docx4j is an open source library.
The only drawback is with docx4j you have to create Office Open XML (docx) format documents rather than OLE2-based (doc) format documents. This is the default format for Word 2007, but Word 2003 and earlier users will need to install a compatibility pack.
Try Aspose.Words for java.
Aspose.Words for Java is an advanced (commercial) class library for Java that enables you to perform a great range of document processing tasks directly within your Java applications.
Aspose.Words for Java supports DOC, OOXML, RTF, HTML and OpenDocument formats. With Aspose.Words you can generate, modify, and convert documents without using Microsoft Word.
I've used Aspose.Words to do mail merge in .NET. I believe that they also have a Java version.
You can use a Java COM bridge like JACOB. If it is from client side, another option would be to use Javascript.
There's a tool called JODConverter which hooks into open office to expose it's file format converters, there's versions available as a webapp (sits in tomcat) which you post to and a command line tool. I've been firing html at it and converting to .doc and pdf succesfully it's in a fairly big project, haven't gone live yet but I think I'm going to be using it.
http://sourceforge.net/projects/jodconverter/
docx4j or poi, both of which are ASL v2
#wondersofcomputing: iText is actually free and open source
iText is really easy to use.
If you requiere doc files you can call abiword (free lightweigh multi-os text procesor) from the command line, it has several conversion format convert options.
After a little more research, I came across iText, a PDF and RTF-file creation API. I think I can use the RTF generation to create a Doc-readable file that can then be edited using Doc and re-saved.
Anyone have any experience with iText, used in this fashion?
Bill, the POI and iText API are very similar from a programming perspective. I've worked with both in the past and found them both easy to use and well documented.
With iText you gain the advantage of being able to switch between formats (RTF and PDF) with minor change to the code. If I remember correctly the content is laid out using the same calls and then set as PDF or RTF using a few lines of code.
However I believe the formatting in RTF is limited compared to DOC. I don't know if you'll be able to implement the advanced features you are looking for (tables, inline images) without a decent amount of hassle, if at all.
Given what you said that about HWPF not having enough functionality for your needs (I've only dealt with the Excel side of POI) your best bet may be to convince the powers that be that PDF is the best technology for the job.
I have developed pure XML based word files in the past. I used .NET, but the language should not matter since it's truely XML. It was not the easiest thing to do (had a project that required it a couple years ago.) These do only work in Word 2007 or above - but all you need is Microsoft's white paper that describe what each tag does. You can accomplish all you want with the tags the same way as if you were using Word (of course a little more painful initially.)
Yet another possibility, since this is a web app.
I was able to render an HTML page with the MIME type set to "application/msword", which caused the browser to spawn Word which imported the html just fine, allowing edits and saving just as if I'd output a real Word doc.
Tables work fine, but images I hadn't gotten working yet. It may be as easy as just an tag in the HTML, or I may have to stream a separate part of the response containing the image data in binary, or some other method I haven't come up with yet. :)
Even though this is much later than the request, it might help others. Docmosis provides a Java API for creating documents in doc,pdf,odt format using documents as templates. It uses OpenOffice as the engine to perform the format conversions. Document manipulation and population is performed by Docmosis itself.
After a little more research, I came across iText, a PDF and RTF-file creation API. I think I can use the RTF generation to create a Doc-readable file that can then be edited using Doc and re-saved.
Anyone have any experience with iText, used in this fashion?
I am looking to take a PDF and extract any text from it. I then want to make it available using ColdFusion's available Verity search to search the contents.
Are there any libraries out there that do this quite well already? I am including Java or .NET (Java prefered) libraries in the scope since they can be called from CF.
Any insights or experiences would be greatly appreciated... thanks!
Edit: Indexing PDF files works when the text is embedded in the PDF as far as I know with CF. The PDFs I'm having to deal with have the text scanned as an image.
If you have the ability to run your own software (i.e. Dedicated/VPS) then you could investigate using Tesseract OCR with cfexecute to convert the PDFs to text?
Verity should be able to index PDF files by default:
http://livedocs.adobe.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/indexSearch2.htm#1142322
Ray Camden has an eight-part series on working with PDFs in ColdFusion 8.
Part 7 of the series covers using DDX to get text out of a PDF.
Not sure this will work with your OCR needs though, but may still be worth looking at.
On a semi related note, I found a very neat post about encoding and reading 2D Matrix barcodes in coldfusion.
http://www.stillnetstudios.com/2007/12/15/2d-barcodes-coldfusion/
This might solve some of my issues in needing to extract encoded information, but I am still after the body of the text.
Regarding tessnet, found a .net version too. http://www.pixel-technology.com/freeware/tessnet2/ If I could natively feed in PDF's instead of TIFFs.. :)