Thanks,
Yes I tried that example (and didnt want to hijack that thread) originally and
could not get it to work at all, so I went down this road.
Can you help me to get that example to work? This is what I tried:
protected void onSubmit()
{
downloadPdf(getRequestCycle(), pdfReq);
...
public void downloadPdf(RequestCycle requestCycle, PDFRequest pdfReq)
{
//returns stamped pdf as a ByteArrayOutputStream
ByteArrayOutputStream pdfout = PDFgenerate.generatePDF(pdfReq);
final String pdfToString = pdfout.toString();
final WebResponse webResponse = (WebResponse) requestCycle.getResponse();
webResponse.setContentType("APPLICATION/PDF");
webResponse.setHeader("Content-Disposition", "inline; filename=\"" +
"test.pdf" + "\"");
requestCycle.setRequestTarget(new IRequestTarget() {
public void respond(RequestCycle requestCycle) {
try {
OutputStream stream = webResponse.getOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(stream,
"ISO-8859-1");
writer.write("hellooooooo");
writer.flush();
writer.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
public void detach(RequestCycle requestCycle) {
}
});
When I try the above the pdf does not render and I get the error:
File does not begin with '%PDF-'
Date: Mon, 18 Jul 2011 12:48:42 -0700
From: [email protected]
To: [email protected]
Subject: Re: Open PDF in a new window
Look in the mail archives. This has been discussed two weeks ago
On Mon, Jul 18, 2011 at 9:55 PM, Fred <[hidden email]> wrote:
> Hello,
> I am trying to open this pdf in a new window with no sucess.
>
>
> protected void onSubmit()
> {
> final ByteArrayOutputStream pdfout = PDFHelper.genPDF();
> final Response response = getRequestCycle().getResponse();
> response.setContentType("application/pdf");
> response.setContentLength(pdfout.size());
> getRequestCycle().setRequestTarget(new IRequestTarget();
> {
> public void detach(RequestCycle requestCycle) { }
> public void respond(RequestCycle requestCycle)
> {
> try
> {
> OutputStream stream = response.getOutputStream();
> stream.write(pdfout.toByteArray());
> stream.flush();
> pdfout.close();
> }
> catch(IOException ex)
> .....
>
> I am totally new to wicket (and java) and could really use some help with
> this.
>
> Thanks
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Open-PDF-in-a-new-window-tp3676139p3676139.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
If you reply to this email, your message will be added to the discussion
below:http://apache-wicket.1842946.n4.nabble.com/Open-PDF-in-a-new-window-tp3676139p3676253.html
To unsubscribe from Open PDF in a new window, click here.
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Open-PDF-in-a-new-window-tp3676139p3676349.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]