Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

How to realize a pdf export?

Marcel Hallmann
1 decade ago Apr 05, 2011 1:44pm
Marko Grönroos
1 decade ago Apr 05, 2011 3:50pm

I think there are many solutions to your question, which is a very common one. I'd probably try formatting the output with XSL FO and then using a FO processor, such as XEP or Apache FOP, to generate the PDF.

FOP at least has a Java API, so you should be able to run the processor totally dynamically in-memory with streams. The docs for XEP tell only of command-line use, although it is a Java application, but I don't know if it has a Java API as well.

Then, have a Link in the user interface to a StreamResource, which generates the PDF document. The browser launches a PDF reader to display the document (unless it blocks popups). You could also embed the PDF in an iframe.

If you're a Pro Account subscriber, please see #130: How to display a PDF document in Vaadin application?.

Marko Grönroos
1 decade ago Apr 05, 2011 3:57pm

Another way is to generate an OpenDocument document and then run OpenOffice as a background process to convert it to PDF. JODConverter is a widely used Java tool to run the conversion.

Charles Anthony
1 decade ago Apr 06, 2011 6:57am
Marcel Hallmann
1 decade ago Apr 11, 2011 6:12am
Marko Grönroos
1 decade ago Apr 11, 2011 12:24pm

There's a new example for generating PDFs dynamically with Apache FOP.

There's a quite a lot of work to get the "what you see" part though...

If you're a Pro Account subscriber, please see #291: How do I generate a PDF file?. It's more about the generation, while #130 is about displaying.

David Wall
1 decade ago Apr 11, 2011 10:13pm
Jean-François Lamy
1 decade ago Apr 12, 2011 1:58am
Michel Jung
1 decade ago Apr 12, 2011 5:50am
Jean-François Lamy
1 decade ago Apr 12, 2011 12:10pm
Marko Grönroos
1 decade ago Apr 12, 2011 1:29pm
Jean-François Lamy
1 decade ago Apr 12, 2011 4:47pm
David Wall
1 decade ago Apr 12, 2011 6:39pm
Michel Jung
1 decade ago Apr 13, 2011 7:25am
Marko Grönroos
1 decade ago Apr 13, 2011 7:33am
Marko Grönroos
1 decade ago Apr 13, 2011 8:07am
Michel Jung
1 decade ago Apr 13, 2011 2:49pm
Marko Grönroos
1 decade ago Apr 13, 2011 3:46pm
Jean-François Lamy
1 decade ago Apr 13, 2011 7:47pm
Marko Grönroos
1 decade ago Apr 13, 2011 9:43pm
Jean-François Lamy
1 decade ago Apr 13, 2011 11:42pm
Marko Grönroos
1 decade ago Apr 14, 2011 12:23am
Charles Anthony
1 decade ago Apr 14, 2011 6:23am
Marko Grönroos
1 decade ago Apr 14, 2011 2:52pm
Jean-François Lamy
1 decade ago Apr 14, 2011 5:09pm
Hugo Hanisch
1 decade ago Apr 11, 2012 10:55pm
Zsolt Veraszto
1 decade ago May 01, 2012 10:40am
santiago cotto
10 years ago Feb 01, 2013 1:06am
Damir Demirovic
6 years ago Feb 08, 2017 10:21am