Print Dialog in JSP

Dear All,
This my problem. From JSP on clicking a Button , a Print Dialog Box has to appear. On Clicking Print it has to print a Dynamically Generated HTML Page. My Architecture Goes LIke this. Jsp --> Servlet --> In servlet a HTML is generated.
When Clicking the Button in JSP, The page should not refresh again. It has to straight away display the Print Dialog Button. I can do this for displaying open-dialog box. now the requirement is to display the print dialog box.
this is the snap shot code i used in servlet to open the html. But Now Requirement is to Open a Print Dialog Box Instead of Open Dialog Box.
Can any one help me out in this regard.
public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
PrintWriter pw = response.getWriter();
response.setContentType("text/html");
response.setHeader("Content-disposition","attachment;filename=report.html");
pw.print(generateHTMLContent());
pw.close();
Post reply here / mail me @ [email protected]

If you don't mind restricting yourself to the newer browsers you can use the LINK tag to designate the servlet as an alternate html page that will be printed when a JavaScript function does a document.print.
Here is a link that may help:
http://www.htmlhelp.com/reference/html40/head/link.html
I have used this for intranet applications where I knew that all users would be using IE 5+ but I don't have an example readily available.

Similar Messages

  • Printing document in jsp

    Hello,
    I'm developing a web app which deals with invoices, delivery notes and that sort
    of things and i need to print the documents i create and show in the screen but
    just a part of the jsp page as i don't want the menu of the app to appear in the
    document to be printed. what can i do to print just a part of the jsp?
    so i have to send the information to pdf? what do u recommend?
    Thanks for your help

    You could implement a "printer friendly" version of your invoices which opens in a popup and then you can use window.print() to initiate the print dialog. This way you don't have to put any HTML controls on the page to be printed. You should advise users to turn off any headers in the browser which will also get printed, such as filename and pagenumber, this cannot be disabled automatically.

  • How to view the print dialog

    Hello,
    Does anyone know how I can view the print dialog on the client's screen instead of the server screen. I use java.awt.print classes.
    Frame f = new Frame("test");
    f.pack();
    PrintJob pj = f.getToolkit().getPrintJob(f,"PRINTING NCN", new Properties());
    Paper paper = new Paper();
    paper.setImageableArea(0,10,74,105);
    PageFormat pageFormat = new PageFormat();
    pageFormat.setPaper(paper);
    if (pj != null) {
         Graphics g = pj.getGraphics();
    Thx.

    if what you want, it is to print what it is seen in the server in the client, you must follow these steps:
    1. server: make an screen capture in a JSP page and send the image to the client in jpg format
    2. client: show the jpg image in a hidden frame or window and use javascript to show the print dialog
    3. client: the javascript code is parent.print();
    This works. I sure.
    Good luck.

  • Printer dialog fine in english, busted in swedish...

    Ok, this is very annoying, and I'd appreciate any help I can on this one.
    Coming from an all-Windows corporation, with only me having minor experience with OS X, I'm a bit stumped as to how to solve this. The thing is, our business is digital printing, and although I can stumble along as it is, it's annoying enough to warrant some time spent on finding a solution. Whether this forum is the right place to go, I don't know yet.
    At our office, we have an HP Color Laserjet 9500hdn. Nothing really fancy there, has worked for years and years with no problems via Windows. This spring however, we acquired a Mac Pro to replace an ageing XP Pro machine.
    At first, there was some problems with getting the printer to stay connected properly, it timed out for some reason, and with big print jobs, we could not have it that way. This was with the original driver included with 10.5. I looked for updated drivers on HP's site, and found both a firmware and drivers for the printer. All said and done, the firmware was installed along with the HP driver.
    Big mistake I guess. Should've gone with only the firmware to start with, that might actually have sufficed. But the driver was installed as well, and here we are now.
    What is the actual problem then? Well, the printer now works as it is supposed to, that is all fine and dandy. However, the printer dialog windows are busted when they are displayed in Swedish. They work fine in their English counterparts (as portrayed by the following screenshots from the English version of Firefox alongside the Swedish version of InDesign).
    http://www.zugzug.eu/CLJ9500-driver-swe-1.jpg
    http://www.zugzug.eu/CLJ9500-driver-swe-2.jpg
    http://www.zugzug.eu/CLJ9500-driver-swe-3.jpg
    http://www.zugzug.eu/CLJ9500-driver-swe-4.jpg
    This behaviour is duplicated on all apps. Works fine in Pages (English version) for example, while the Swedish version of Photoshop displays it incorrectly.
    Now, what can be done about this? I have a few alternatives:
    1. Somehow force ALL printer dialogs to display in English. Is this at all possible?
    2. Somehow remove the HP driver (there is no uninstall utility that I have found) and reinstate the original driver. How to do this is beyond me.
    I've tried reinstalling the printer driver, I have tried removing and installing the printer, but nothing helps. It still works in English, but displays incorrectly in Swedish.
    Very annoying, to be honest, and any help here is appreciated. I'm not afraid to go into the terminal and play if needed, just as long as you tell me what to do
    Here are the versions and links to HP's drivers/firmware I've installed:
    *HP LaserJet Mac OS X Installer Print Only Software Solution for v10.2, v10.3.x, v10.4.x, v10.5*
    Version: 7.8.0.761 (28 Jan 2008)
    http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareDescription.jsp?lang=en &cc=se&prodTypeId=18972&prodSeriesId=85318&swItem=lj-57300-1&prodNameId=85323&sw EnvOID=219&swLang=36&taskId=135&mode=3
    *HP Color LaserJet 9500 Firmware for Single/Multiple Printers - Mac Operating System*
    Version: 05.011.2 (4 jun 2008)
    http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareDescription.jsp?lang=en &cc=se&prodTypeId=18972&prodSeriesId=85318&swItem=lj-18003-9&prodNameId=85323&sw EnvOID=219&swLang=36&taskId=135&mode=3
    Appreciate any help!
    - Peter

    Problem solved! Short recipe: Uninstall everything HP, then reinstall HP printer drivers from Mac OS X 10.5 DVD.
    Instructions from HPs hardware support person (complete with comments from support person 2):
    Unplug the printer.
    Uninstall the printer - He says he does not have HP uninstaller under Go and Applications. He didn't have HP Laserjet either
    Uninstall any HP printer SW that has been installed.
    Remove the following files (if available)
    HD/Library/Printers/hp/laserjet/P2015series (Not sure of the name)
    HD/Library/Receipts/hp Laserjet P2015.pkg (Not sure of the name here either) - Cust found this (he thinks)
    HD/Library/Frameworks/libZJBIG.dylib (This file may not even exist but if it does: remove it) - He also found this and removed it
    Empty the recycle bin!
    Insert Mac OS Leopard installation CD, choose click Optional Installs - Seems like cust hasn't tried that at all before so he will do that now and call back
    I really didn't think they would be able to find a solution this fast. Hats off for HP!

  • How to print data using JSP

    I have a jsp/html page. Which has some data and I want to print the data of that page using jsp.Means I want to display the page and an option which will ask whether user wants to print the page or not. And if the user select print option then it will print the displayed page using printer.
    Please help me how I can proceed.
    Regards,
    Sundeep Mohanty

    Yes
    window.print will print the current displayed page
    also...it wuill not print directly...but will open the print dialog box of ur default printer i guess.

  • Adobe PS CS3 has major flaws in Print Dialog. Beware!

    System Specs:
    OSX Leopard 10.5.2
    MacPro 3.2ghz with 32GB of ram 1.5GB Video
    Epson 11880 Printer
    Samsung XL20 LED monitors calibrated using EyeOne Pro 6500k 2.2 and 120c/d
    I have been trying to build a custom profile for my new Epson 11880. However, my results have been unsuccessful. All my prints came out super dark. The color is all off except for the grey scale.
    After talking to Epson for hours I found out that the new Beta driver for the printers have a problem, so rolled back to v3.89. This fixed all printer problems. So printer is fine now. This also applies to the Epson 3800.
    Spoke to Apple about their color management and Leopard issues? No fault found on the OS.
    Ran a test using preview, iPhoto, EyeOneMatch, Photoshop CS, and CS3. I couldn't find my CS2 disk so I didn't get a chance to test that. preview, iPhoto, CS, and EyeOneMatch all came out with same results when printing a 9.18 target without PCM. However, CS3 printed the image dark and off color with the exact same settings. Problem has been persistent and I would like to conclude that CS3 needs to fix this bug in their software. It is ridiculous to be printing using another software because CS3 can't do a simple task as print.

    viewing conditions are fine.
    I have the whole room outfitted with GTI D50 lights. What can I say I am anal. No matter where you stand the light will hit 5000k. I change the bulbs out every 1500 hours although they tell me I can wait until 2000 hours.
    My monitor is also calibrated properly. I am using the Samsung XL20 and XL30 monitors, which surpass the Eizo or any other LCD's on the market. I've owned the Eizo, NEC, Artisan, and any other monitors you can name. I also made sure my Spectrometer is fine and it is.
    When printing targets with the setting set to NO Color Management in Photoshop it should yield the same results as the other applications. The only thing you are technically utilizing then is the printer driver and dialog box. Yes the printer dialog is always same and set properly also. PCM is set to no color management. I've tested this with other applications and it is CS3 that is giving me all the problems.

  • Suppress the Print dialog box in Air /Flex

    Hello,
    I am trying to print the pdf files(which is located in my system) directly in the printer without showing print dialog box .
    I tried to print the screen without displaying print dialog box using flash.printJob.start2().
    but am not able to print pdf files in the printer its printing dark screen only also it just printing the UIcomponent size only. its not printing all d pages available inside pdf file.
    Can you please help me to resolve this issue.

    Hi
    I tried to open a new bug report , that screen itself not displaying properly and I couldnt able to enter any comments there ,I can see only the option buttons.
    and I am trying to print the documents which is having mutiple pages using flash printJob . the following code I have used . here i am trying to Print Textfield .
    Could you please me how can I add document/pdf file/text file instead of TextField.
    va txt:TextField = new TextField();
    txt.text = "Hello Test" ;
    var sheet:Sprite = new Sprite();
    sheet.addChile(txt);
    and in printing
    If(PrintJob.start2(null,false))
    PrintJob.addPage(sheet);
    PrintJob.send();

  • Print Dialog doesn't retain settings

    I am using kPrintActionCmdBoss to print several times from the same document (different layers each time). I want to put up the print dialog the first time, and then keep the user's settings for the subsequent prints. I can see that the settings are remembered by the document:
    IDocument* iDoc = Utils<ILayoutUIUtils>()->GetFrontDocument();
    InterfacePtr<IPrintData> docPrintData(iDoc->GetDocWorkSpace(), UseDefaultIID());
    bool16 debug1 = docPrintData->GetPrintBlankPages();
    debug1 is kTrue if I ticked the 'Print Blank Pages' box in the dialog.
    I try setting the print command's print data:
    InterfacePtr<ICommand> printActionCmd(CmdUtils::CreateCommand(kPrintActionCmdBoss));
    InterfacePtr<IPrintCmdData> printActionCmdData(printActionCmd, UseDefaultIID());
    printActionCmdData->SetPrintData(docPrintData);
    but the print command seems to pay no attention to the settings.
    Does anyone know what I'm doing wrong?
    Thanks,
    Charles

    I also wonder why there is no "print preview" option in the Firefox print dialog box. I don't want a "workaround"—I simply want a print preview option the same way every other Mac application provides it in the print dialog box.
    Where did this go??

  • Print dialog not displaying when trying to print PDF document

    Hello All,
    I am using below code to print a pdf file. And the same code working fine when i am using with simple java class. and if i am using the same code with my jsf backing bean action method it was not working.
    Code here:
    Document document = new Document();
    FileOutputStream combinedOutput = new FileOutputStream(bulkBarcodes);
    PdfWriter.getInstance(document, combinedOutput);
    document.open();
    String barCodeNum = filetrakcode.getBarCodeID().toString();
    Barcode bc = new Barcode(barCodeNum, DEFAULT_CONFIG_FILE);
    document.add(new Paragraph("\n"));
    document.add(new Paragraph("\n"));
    Image image = Image.getInstance(bc.generateBarcodeBytes(bc.getBarcode()));
    document.add(image);
    combinedOutput.flush();
    document.close();
    combinedOutput.close();
    File f = new File(bulkBarcodes.getAbsolutePath());
    FileInputStream fis = new FileInputStream(f);
    FileChannel fc = fis.getChannel();
    ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
    PDFFile pdfFile = new PDFFile(bb); // Create PDF Print Page
    PDFPrintPage pages = new PDFPrintPage(pdfFile);
    PrinterJob printJob = PrinterJob.getPrinterJob();
    PageFormat pf = PrinterJob.getPrinterJob().defaultPage();
    printJob.setJobName(f.getName());
    Book book = new Book();
    book.append(pages, pf, pdfFile.getNumPages());
    printJob.setPageable(book);
    //Send print job to default printer
    if(printJob.printDialog())
    printJob.print();
    When i am calling my action method (method contains above code) it was creating pdf file and writing the data init success fully but when i have not used "if(printJob.printDialog())" it was printing document directely successfully but when i am calling "if(printJob.printDialog())" it was not opening print dialog box and it was showing me like process is going on and it was not proceeding further
    what's the problem
    Please help me.
    Thanks In advance,
    Indira.

    Hi Kavi,
    just have a look into the driver-program. I'm pretty sure someone has programmed a loop.
    IF it is a NAST-driver program, check if your specific user has a printer SU03. That sounds a lot like this mistake
    ~Florian

  • Print dialog options in case sensitive file system

    Since changing the file system running Lion and Mountain Lion from Mac OS Extended (Journaled) to Mac OS Extended (Case-sensitive, Journaled), certain features in print dialogs have disappeared.
    Particularly the option to print notes with slides in Microsoft Powerpoint are gone. Also, when choosing to print only 1 (or more, but not all) of multiple pages in Microsoft Word, the printer will nevertheless print all pages.
    This problem occurs on printers of different brands, i.e. HP, Lexmark, Brother.
    I was able to determine this problem by reproducing the issue on a cleanly installed Macbook Pro with OS X 10.8 formatted as Mac OS Extended (Case-sensitive, Journaled) vs a cleanly installed Macbook Pro with OS X 10.8 formatted as Mac OS Extended (Journaled), not Case-sensitive.
    Has anyone else had the same problem and maybe a solution?

    I just fixed this on my Mac. It is a bug in Microsoft Office... the Printer Dialog Extension (PDE) for Powerpoint is located in a directory named "Plugins", but PowerPoint is looking for it in "PlugIns". This obviously does not work in a case-sensitive filesystem.
    Here are the steps to fix the issue:
    http://apple.stackexchange.com/a/119974/69562

  • Newbie:  In printing dialog, "Scale to" size options are greyed out

    I am in the initial stages of figuring out how to use Aperture (v1.5). I am currently trying to make a 5x7 print of a photo.
    In the print dialog, "Scale to" 4x6, 5x7, 8x10 size options are greyed out (only "fit image" and "fill entire page" are available).
    I've tried searching through the forums, but to no avail...
    Thanks!

    Click the Arrange button on the toolbar and select the desired option.

  • Printing a report and using the print dialog for it

    i already have the print dialog vi from NI. I am using the normal report generation toolkit for printing reports. But I want to give the user an option to choose the number of pages and landscape/portrait options. But how do I integrate the 2 so that before printing the user can select these features.

    There is an activeX control that will set these settings. It is called IAS Helper COM Component 1.0 Type Library. It operates the Windows printer configuration program. Since another company wrote the code, I do not have the resources to help you use the control, but the attached example program should get you started.
    Jeremy Braden
    National Instruments
    Attachments:
    Print_Window_Example_v61.llb ‏59 KB
    Print_Window_Example.llb ‏59 KB

  • "Quality and Media" not displaying in Print dialog.

    I am using Mac OS X 10.6 Snow Leopard on a Macbook Pro with a Canon MB5220 Multifunction printer over WiFi. I have installed the Canon Drivers and can print to the printer but the "Quality and Media" menu choice does not display in the print dialog so I can't set any of the quality settings or the color settings for the printer.
    I installed and re-installed the drivers. Tried with several applications such as TextEdit and preview. Only menu choices are Layout, Color Matching, Paper Handling, Cover Page, Scheduler.
    Is there anything that would keep Quality and Media from dispaying?

    It's not just the Quality & Media menu that appears to be missing. There are three other Canon menus you should see like below;
    These menu items are supported by the plugins bundle installed in /Library/Printers/Canon/BJPrinter/PDEs, which supports a number of Canon inkjet printers. Since reinstalling the driver for the MG5220 has not helped then I would try a reset of the printing system and then adding the printer again. To reset the printing system, open Print & Fax, move the mouse over the Printers list and Control-click. The reset popup will appear. Select it and authenticate if prompted and then restart the Mac. Please note that this action will remove all printer and scanner queues from Print & Fax, but not the associated drivers so just the queues will need to be added again.
    If this action does not resolve the problem then try running the Canon Driver Update v2.6.

  • Print html file without seeing a print dialog box

    i need to script an action that would allow a user to print a sparcly formated html file to a printer while bypassing the normal print dialog box.
    the unix lpr command seems like it might work, but the man page only mentions PS and txt files.
    Ultimately i'd want to trigger the print action from a php script, but it could be a folder action also.
    Does anyone have any suggestions or point me in the right direction.

    lp is the right command to use but you may need to convert the html file in PDF format before printing it. Just test it. Also type man lp to see more options.
    enscript is a nice utility that may help you. man enscript for more.
    Mihalis.

  • How to print specific pages of a pdf from a vb 2013 program using a print dialog

    Hi.  I am using the acrobat sdk to display pdfs from within a vb 2013 program, because the pdfs are large and we have developed indexes on certain columns.  The indexes are stored in SQL tables.  My program has a search window which allows the user to search for a value and displays all the pages on which this value appears in the indexed column in a listbox.  By double-clicking on the desired value in the listbox, the user can go to the selected page and column.  However, the user also needs to be able to highlight one or more of the pages in the listbox and print these pages.  I could do this silently using AcroExchAVDoc.PrintPages, but the user also needs to have a print dialog displayed in order to possibly select a watermark to be printed on the pages.  I also need to default the orientation of the pages depending on the document.
    I have reviewed the sdk documentation and also searched in Google and on this site but have not found a way to do this.  Does anyone have a suggestion?  Thanks for any help you can provide.
    Mary

    Hi.
    I did try using the printParams feature and it worked, but since I need to be able to print sets of non-consecutive pages,  I end up having to bring up the print dialogue multiple times and have the user set watermarks each time. 
    I decided to just create a new pdf in a temp directory containing the selected pages and open this document in a new window.  This works well and allows them to use the print button on the window to print, bringing up the print dialogue just once.  However, since I need to open the document in a way that shows the print button, I am using OpenInWindowEx, with AV_DOC_VIEW, and the option PDUseBookmarks or PDUseThumbs, rather than PDUseNone.  This displays a toolbar which also includes icons for creating a new pdf, deleting pages, etc.  I do not really want to include these icons on the toolbar.  Is there a way to remove unwanted icons from the toolbar, or make them invisible?
    Hope this makes sense.  Thanks for your help.
    Mary

Maybe you are looking for