jQuery in Action, 3rd edition
The moose likes JSP and the fly likes JSp Output to PDF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSp Output to PDF " Watch "JSp Output to PDF " New topic

JSp Output to PDF

sunilkumar ssuparasmul
Ranch Hand

Joined: Dec 13, 2000
Posts: 142
Hi ,

I am trying to open the output of a JSP in a PDF , but it does nt open ..
What i am trying is , get all jsp output in a string and then write the string to output stream

i have some thing below in my code , but it doesnot work .

response.setHeader("Content-disposition","attachment; filename=Sample.pdf");
o = response.getOutputStream();



I tried converting my string into byte array and then write , still it doesnt work .

It says that file is not pdf supported and when i view the file source it is in HTML (the format which i wrote it) . DO i have to do anything in addition to convert into PDF . Please clarify as it is very critical.

With the same above steps and contecnt type as "application/word" , i coudl open the word document.

thanks in advance.


"Winners don't do different things<br /> They do things differently"
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

If you are telling the browser that you are sending PDF, then you have to send PDF format. You can't send HTML and expect the browser to magically convert it.

[Asking smart questions] [About Bear] [Books by Bear]
sunilkumar ssuparasmul
Ranch Hand

Joined: Dec 13, 2000
Posts: 142
Hi Bear Bibeault

I infact realsied that and i used ITEXT API to send my text to the API but whne i use Itext api , i am not able to oprn the file at runtime as it says Permission Denied , when i tried to open the file

has any one implemented a better solution to convert from HTML to RTF and PDF , if not atleast with simple text (no htm) to create a RTF and PDF thru java

Thanks is Advance.

I agree. Here's the link: http://aspose.com/file-tools
subject: JSp Output to PDF
It's not a secret anymore!