This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JSP and the fly likes Export JSP to PDF format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Export JSP to PDF format" Watch "Export JSP to PDF format" New topic
Author

Export JSP to PDF format

Megha Rajeevan
Greenhorn

Joined: Mar 22, 2006
Posts: 24
Hello Ranchers..
I'm doing a project in JSP and Oracle..
Here in my project there are two types of department..
Accounts and Sales..
Accounts department is able to download some pages to Excel format and it is working properly..

now in the sales they have to download in pdf format.. then only it is possible to send to the HO..
now what they are doing is downloading the JSP page in excel format and converting to pdf manually using the Acrobat Printer..

is that possible to change to pdf format..

for converting to excel format.. i'm just using 2 lines
and it is here


<%@ page language="java" session="true" import="java.sql.*" import="java.lang.*" contentType="application/vnd.ms-excel" %>
<%
response.setHeader("Content-Disposition","attachment;filename=test.xls");
%>

in the filename side i chaged to test.pdf..
and in the contentType i changed to Acrobat reader
and it is downloading but cannot view the conten..

please help me ranchers.. to solve this problem..

thanks in advance..

regads
Megha Rajeev
Mandar Max
Ranch Hand

Joined: Mar 14, 2006
Posts: 38
The content type should be a valid MIME type. Try setting "application/pdf" as contentType.


"The trouble with doing something right the first time is that nobody appreciates how difficult it was!"
Manesh Kumar
Ranch Hand

Joined: Mar 21, 2006
Posts: 94
Changing content type doesnt change its contents.

You need to create pdf file using third party like iText.
[ May 24, 2006: Message edited by: Dilip Kumar Jain ]

Manesh
Mandar Max
Ranch Hand

Joined: Mar 14, 2006
Posts: 38
I think when Megha says she changed the file name to test.pdf I would assume that the change is being made to the JSP file and there would be a valid pdf file with that name. By common sense, I would not assume that she is renaming test.xls to test.pdf and hoping it to be opened by acrobat reader. But if my assumption is wrong, probably you should consider professional tools for publishing content in pdf.
Megha Rajeevan
Greenhorn

Joined: Mar 22, 2006
Posts: 24
thanks for the reply..
but it is not working properly..

the acrobat reader is opening.. with a message box..

this is the content of the message box
" Adobe Reader couldnot open the file test[1].pdf because it is not either a supported file type or because the file has been damaged.(for example, it was sent and email attachment and wasn't correctly decoded)"

this is the error message i'm getting..
so what to do now..
the page contains table format and all..
i've give the code like this

<%@ page language="java" session="true" import="java.sql.*" import="java.lang.*" contentType="application/pdf" %>
<%
response.setHeader("Content-Disposition","attachment;filename=test.pdf");
%>


please help me for fixing the problem

thanks in advance

regards
Megha
Mandar Max
Ranch Hand

Joined: Mar 14, 2006
Posts: 38
Are you sure that test.pdf is a valid pdf file?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Export JSP to PDF format
 
Similar Threads
download to excel in a zip file
Converting Html to PDF
Download PDF
JSP to OpenOffice
Drawing Graphs in JSP