简体   繁体   中英

How to generate a downloadable PDF with iText?

How do I make a PDF file downloadable?

I'm have my web application in Tapestry 4.0.2, Spring and hibernate. when the user clicks in a "Save as PDF" link a PDF should be available to be downloaded.

So far I've a working code that generates the PDF file, but the file is saved on my desktop and what I want to do is that when the user clicks on the link the pdf file should be downloadable instead of being stored in the app. I'm using iText library for this.

You'll use a StreamResponse to render the binary and ComponentResources.createEventLink(...) to generate a link to the PDF event.

Take a look at my PDFLink component here which uses Apache FOP to render the PDF binary

* EDIT * I just read the fine print (ie Tapestry 4.0.2). I'm unfamiliar with Tapestry 4. I'll leave this answer here as some of it may be compatible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM