Thanks for not giving up on me yet.
I can generate the pdf and render it to a browser with this code:
final ByteArrayOutputStream pdfout = PDFHelper.generatePDF();
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){
throw new RuntimeException(ex);
}
}
});
Thanks
> Subject: RE: pdDocument.print(); prints to server not browser
> Date: Mon, 18 Jul 2011 09:51:34 -0400
> From: [email protected]
> To: [email protected]
>
> I don't know wicket but it sounds like you're missing a step.
> How does it normally communicate, like to generate a file on the server
> and save it to the client?
>
>
> -----Original Message-----
> From: stephen smith [mailto:[email protected]]
> Sent: Monday, July 18, 2011 9:43 AM
> To: [email protected]
> Subject: RE: pdDocument.print(); prints to server not browser
>
>
> Hello and thanks.
>
> I am using wicket to "serve" the pdf to the printer. My code is like
> this:
>
> //component
> public class BPPdfGeneration extends Panel {
> public BPPdfGeneration(String id) throws IOException,
> DocumentException, PrinterException
> {
> super(id);
> PDDocument pdDocument;
> pdDocument = PDDocument.load(PDFGen.generatePDF());
> pdDocument.print();
>
> //I assume that the pdDocument.print(); should be added to the html
> somehow such as:
> // add(new ?("pdf", pdDocument.print());
> }
> }
>
> Help would be greatly appreciated
>
>
>
> > Subject: RE: pdDocument.print(); prints to server not browser
> > Date: Mon, 18 Jul 2011 09:21:20 -0400
> > From: [email protected]
> > To: [email protected]
> >
> > If your document is on the server it sounds like it does what it's
> > supposed to.
> > How is your server talking to your client?
> > Try streaming the pdf to the client first?
> >
> >
> > -----Original Message-----
> > From: stephen smith [mailto:[email protected]]
> > Sent: Friday, July 15, 2011 5:51 PM
> > To: [email protected]
> > Subject: pdDocument.print(); prints to server not browser
> >
> >
> > Hello,
> >
> > When we use:
> > pdDocument.print();
> > it actually opens up the print dialog box on the server, not the
> client.
> >
> > Has anyone seen this before?
> >
> > Thanks.
>