If you've streamed the pdf to the client and the pdfbox print method is
generating a print dialog on the server, what you need to try is
creating a PrinterJob on the client.  print() should not be called
directly.  The print() method in the PDDocument class is called
automatically if you pass the PDDocument (Pageable) object into
PrinterJob and call it's print method.  PrinterJob can create a print
dialog, or assign the printer if you already know the name.
http://download.oracle.com/javase/6/docs/api/java/awt/print/PrinterJob.h
tml

 

-----Original Message-----
From: stephen smith [mailto:[email protected]] 
Sent: Monday, July 18, 2011 12:08 PM
To: [email protected]
Subject: RE: pdDocument.print(); prints to server not browser


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. 
> 
                                          

Reply via email to