What tool for printing Invoices and similar documents in Java Swing? - java

I'm looking for a good tool for printing Invoices, Receipts and similar documents in Java Swing. I have tried JasperReports but it is pretty hard to get a dynamic layout and it is designing for reports.
A requirement that I have is that the document should be sent directly to the printer and must not be saved to a file. So some tools that first creates an Office Document or a PDF document isn't a solution for me.
Any recommendations?

You might want to give Docmosis a go. You can create dynamic documents in various formats with the advantage that layout is specified in a template (being a simple doc or odt file) and content can be dynamically managed based on data. The type of layout your link refers to is pretty easy to achieve by using Docmosis conditional fields or by adjusting your input data.
In terms of printing only, Docmosis lets you stream the resulting output document anywhere. You could stream it to code that will send it to a printer directly.

I recommend to use DynamicReports, an open source and based on JasperReports.
You can send report directly to the printer.

Printing in Java revolves around a fairly simple but powerful API that provides you with a canvas. Fromthere you can easily paint any information using the Java2D API in the same way you would override a paintComponent() function.

Related

How to generate a PDF output from a template PDF using something other than iText?

I'm working on a small Scala/Java prototype where I have several PDF templates i.e. they have text and image placeholders and the placeholders should be replaced with some content. Some sections are also multiple i.e. the actual number of occurrences or repetitions depends on the input. Then finally I need to generate and append an extra PDF page.
I'm aware that these use-cases can be covered using iText. My question is whether I can use an alternative solution for this (and how to do it). I'd prefer to avoid commercial solutions for the time being.
UPDATE: I'd like my PDF templates to be created by professional designers. They will know where the placeholders will be but should have full control on the design aspects. This requirement discards solutions based solely on XML inputs or others where the PDF is created fully programmatically.
Jasper - It's sofrware designed for crating dynamic reports connected with database inputs, but I think it can be utilized in the way you want. Has a graphical designer (either iReport or JaspersoftStudio based on your preferences), supports passing multiple variables with content or even images. Long static formatted texts may be a problem, but you will have to judge that for yourself.
JODReports + JODConverter - those two tools will allow your designers to work in pure ODT (OpenOffice format) files putting in dynamic data as variables that you will be able to substitute to your hearts desires from your Java code and print the output in PDF format. More than that, thanks to Java UNO API you can seize full control over the way your template looks and behaves if your inserted texts are really complex (though admittedly it's not intuitive to use).

Adding buttons, textfields, checkboxes etc. to an OpenOffice textdocument usind UNO with Java

I am trying to create a OpenOffice document using the UNO-API with Java.
I am already able to create a simple document and put some simple text into it.
What I want to do, i.e. need to do, is add also Forms (TextFields, CheckButtons, Push(Click)Buttons) into it.
The idea is to create a form in openoffice which in the end can be transformed to a PDF with interactive pdf-forms.
I am able of creating these with iText and manually with OpenOffice.
But I have not found a (simple or any) Example of creating such objects with the UNO-API.
So any help, hints or links (not that I haven't tried to find something via google, but maybe I just used the wrong key-words) is appreciated.
An alternative for you might be to use the ODF Toolkit, with its Java APIs for manipulating ODF documents, the native format of OpenOffice.org and its descendants.
I don't know if ODF Toolkit supports the features you are interested in though. Check at http://incubator.apache.org/odftoolkit/

JasperReports as a generic document generation tool

I need some input if this is possible.
I guess most of you who have used JasperReports use it to - obviously - generate reports.
My question is, can you use it to generate generic documents? Ergo, documents that AREN'T reports. Say, for example, an automated letter of authority with fields you can just populate at run time. Or a company form that is filled up by your app then generates a pdf using JasperReports.
The only other solution that came up was iText, which I believe is far more capable of achieving the desired output.
Any inputs would be appreciated. Thanks.
You could, but I wouldn't--IMO you're better off using raw iText, or one of the dynamic languge PDF generators. IIRC iText can fill in PDF forms, too, so if you have someone else creating the PDFs, they can just be populated via iText.
OTOH, if they're relatively simple, it probably doesn't matter very much--you can pass non-tabular data to JR, I'm just not sure it's any easier that way.
I do all kinds of elaborate reports with iReport. It is an amazing designer for JasperReports. It allows to drag and drop components and connect to your DB or JavaBean Datasources with wizards. A very mature application that gives you all sorts of report exporting capabilities.
With iText you can do anything. But it is a programming API and so you either have to create your own design tool or construct the reports in code. For something simple or that will rarely change, it works well.
If you want a full-blown docgen solution, you need a product like Document Science, Thunderhead, or Windward Docgen (disclaimer, I'm the CTO at Windward). The beauty of these solutions is you design templates (in the case of Windward you design in Word) that are then passed to the system so it does not require programming to create/revise a document. And they output to pretty much any format.

populate data from java to pdf

I am currently looking for a solution to populate a PDF file from the java code, Is there any APi for that, I googled it and found JustformsPDF does the trick, but it works only for some pdf and not all + its a old API without recent developments/support.
Basically I have an existing PDF (and do not want to build it) I just need to populate my java data inside that pdf.
any suggestions ?
These two should be able to do the job (these are the ones I know, there may be more):
Apache PDFBox
iText
You can use our product PDFOne (for Java). It has a document component that can also fill form fields in existing PDF documents. Viewer and printer components are also available.

Design PDF template and populate data at runtime using java,xml etc

well i have been looking for a java based PDF solutions...we dont have a clean way i guess-still.. all solutions are primitive and kind of workarounds... No easy solution for this requirement -
1. Designing a PDF template using a IDE (eg. Livecycle designer ..which is not free)
2. Then at runtime using java, populate data into this PDF template...either using xml or other datasources...
such a simple requirement and NONE has a good "open-source and free" solution yet ! Is anyone aware of any ? I have been searching for since 3-4 years now..for a clean way out...
Eclipse BIRT comes close.. but does not handle Barcode elements ..OOB.
Jasper - ireport is also good but that tool does not have a table concept and is kind of annoying ! Also barcode support is not good.
XSL-FO has not free IDE for design .
Looking for a better answer .. got one ?
If it's a "simple requirement", you could create a report designer around iText and release it as FOSS yourself.
What are your key requirements? Does your input have to be a PDF? If so, you'll be probably working uphill for a long time still. Obviously you want to inject data and output a PDF.
If your templates can be something other than PDF, you could try using the OpenOffice API to get OpenOffice to do manipulate documents and produce a PDF. JODReports or Docmosis would be better ways of interacting with OpenOffice and Docmosis allows you to treat documents (doc and odt) as templates.
You can create a PDF file with AcroField through iText API AcroField values can be populated.
Note: Using OpenOffice you can create PDF document with FormFields.
http://blog.rubypdf.com/2007/08/01/freely-fill-pdf-form-with-the-help-of-itext-or-itextsharp/
You could use OpenOffice's UNO API. It looks rather heavyweight but at least you get something full-featured.
Have a look at XDocReport. You create your templates in word .docx or OpenOffice .odt files, then turn them into populated PDF files with Java code.

Categories