Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Problem - I want to print Current Output of Pdf file and should print once.I get print dialog box but it is not working

Reply
Thread Tools

Problem - I want to print Current Output of Pdf file and should print once.I get print dialog box but it is not working

 
 
keto
Guest
Posts: n/a
 
      05-30-2007
# application server - JbossServer-4.0.4.
# OS: windowsXP
# IDE: Eclipse
# Problem - I want to print Current Output of Pdf file and should
print once.I get print dialog box but it is not working
properly.


public void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {

String strId="QI0001";
ByteArrayOutputStream baosPDF = generatePDFDocumentBytes(strId);
response.setContentType("application/pdf");
response.setContentLength(baosPDF.size());
ServletOutputStream out = response.getOutputStream();
baosPDF.writeTo(out);
out.flush();
try {
if (showPrintDialog){
if (printJob.printDialog()){
printJob.print();
}
}
} catch (Exception PrintException) {
PrintException.printStackTrace();
}
protected ByteArrayOutputStream generatePDFDocumentBytes(String
strId )
throws DocumentException{

Document doc = new Document(PageSize.A4, 60, 30, 80, 50);
ByteArrayOutputStream baosPDF = new ByteArrayOutputStream();
PdfWriter docWriter=PdfWriter.getInstance(doc, baosPDF);
docWriter.setViewerPreferences( PdfWriter.HideMenubar |
PdfWriter.HideToolbar | PdfWriter.HideWindowUI );
Graphic grx = new Graphic();
grx.setHorizontalLine(0f, 100f);
doc.open();
doc.add(---some tables---);
doc.close();
return baosPDF;
}

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
repeating dialog box problem - "Do you want to open or save this f Shalom ASP General 3 05-29-2008 05:08 PM
PDF::Writer, create pdf and insert in other pdf file. Ricardo Pog Ruby 1 03-26-2008 08:24 PM
Re: Problem - I want to print Current Output of Pdf file and shouldprint once.I get print dialog box but it is not working Lew Java 0 05-30-2007 01:31 PM
Want to call jscript "confirm" box from VB.NET, but NOT from a but =?Utf-8?B?SlQ=?= ASP .Net 0 03-21-2006 12:14 AM
display print preview dialog, not print dialog Matt Javascript 1 11-20-2004 01:18 AM



Advertisments