Re: Returning a PDF file
Re: Returning a PDF file
- Subject: Re: Returning a PDF file
- From: "Daniele Corti" <email@hidden>
- Date: Wed, 28 Mar 2007 14:48:49 +0200
2007/3/28, Johann Werner <email@hidden>:
Hi,
I have some trouble returning a PDF file that I am creating on the
fly to a browser. I set the header information as noted on the
wikibooks website to:
public void appendToResponse(WOResponse aResponse, WOContext aContext) {
super.appendToResponse(aResponse, aContext);
if you call super.appendToResponse you generate the page with the default header, simply don't call it. I hope this work!
aResponse.setHeader("application/pdf", "Content-Type");
aResponse.setHeader("inline; attachment; filename=\"MyPDF.pdf\"",
"Content-Disposition");
aResponse.setHeader("" + aktPDF.length(), "Content-Length");
aResponse.setContent(aktPDF);
}
where aktPDF is of type NSData. When I click on the link to return
the PDF I get a blank page in Safari. When I look at the page source
I can see that the data has been loaded. In order to see the PDF I
have to save the page and change the file extension to pdf prior to
being able to open it in Preview.
Firefox displays all the ASCII text in the browser window instead of
a blank page.
By changing the second header information from "inline; attachment;"
to "application;" Firefox ask to download the pdf file. Safari
behaves as in the first case.
try use "attachment;" Safari will download it too!
How can I get that to work? Could it be related to the fact, that I
am setting the default encoding to UTF8 and setting header
information in the applications appendToResponse?
public Application() {
super();
System.out.println("Welcome to " + this.name() + "!");
/* ** Put your application initialization code here ** */
WOMessage.setDefaultEncoding("UTF8");
}
public void appendToResponse(WOResponse response, WOContext
wocontext) {
super.appendToResponse(response, wocontext);
if (_NSUtilities.UTF8StringEncoding.equals(
response.contentEncoding
()))
response.setHeader("text/html; charset=UTF-8", "Content-Type");
}
But if I call super first and then set the header to "application/
pdf" there should be no problem?
mmm I'm not sure, don't call is tha best policy
Johann
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden
This email sent to email@hidden
--
Daniele Corti
AIM: S0CR4TE5
Messenger:
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden