Problem w/ cross-browser printing, embedded pdf javascript

protected static byte[] exportReportToPdf(JasperPrint jasperPrint)
                                                      throws JRException {
  JRPdfExporter exporter = new JRPdfExporter();      
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
  exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
  exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT,
              "this.print({bUI: true,bSilent: false,bShrinkToFit: true});");
  exporter.exportReport();       
  return baos.toByteArray();
We are using code like this to export a PDF document from a Jasper application.
The line
exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT,
             "this.print({bUI: true,bSilent: false,bShrinkToFit: true});");
adds embedded JavaScript to send the PDF document directly to the printer.
The expected behavior is that a print dialog will come up with a preview of the PDF document.
This works fine most of the time - except I am having problems about one out of every 5-6 times in Internet Explorer 8 and Firefox.
What happens is - the print preview dialog with the PDF document does not appear or it appears with a blank document in the preview window.
-I've tried a number of different JavaScripts (different params to this.print() via exporter.setParameter -I've tried setting different response headers such as
response.setContentType("application/pdf");
response.setHeader("Content-disposition","inline;  filename=\""
                   + reportName
                   + "\"");
response.setContentLength(baos.size());
these did not seem to help
This seems to be an IE and FF issue. Has anyone ever dealt with this problem? I need to get it to work across all browsers 100% of the time. Perhaps a different approach to accomplish the goal of sending the PDF document export directly to the printer? or a third party library that will work across browsers? Thanks for any advice.

You have to be careful when using the ActiveX control to communicate with system functions like printing.  Because it can be embedded in anything that supports ActiveX, some functionality is limited from being called from JavaScript as it may interfere with the host application.
Check out the IAC API Reference (also included with the SDK) and the methods under AxAcroPDFLib.AxAcroPDF.  There are some print functions in there (like PrintAll) that you can call on the ActiveX control directly, as in from your doPrint() method in your HTML page without using the hostContainer.  You would basically just call:
pdfObject = document.getElementById("PDFObj");
pdfObject.PrintAll();
These methods were designed specifically to work with the ActiveX control when embedded in a host application, and can be used to print a PDF embedded in a web page.

Similar Messages

  • Firefox 4.0 support for printing embedded PDF files in iFrames via JavaScript

    I recently upgraded to Firefox 4.0 and can no longer print embedded PDF documents contained in an iFrame.
    My company's web application has several pages which load PDF files from a Servlet into an iFrame. The pages in question all have "Print" buttons which when clicked executes a JavaScript function to obtain reference to the iframe containing the PDF, place it into focus() (e.g., frames['pdfdoc'].focus();), and invoke print() (e.g., frames['pdfdoc'].print();). There are no errors, or exceptions caught when the JavaScript function is invoked, but the "Print" button is no longer operational.
    Does Firefox 4.0 no longer support iFrames? The issue goes away if I revert back to ver 3.6.16

    I have same issue for printing embedded PDF files in iFrames via JavaScript in Firefox 5.0.
    In previous versions it was working fine. But not in Firefox 4.0/5.0.
    Is there any solution for this problem?

  • Cannot Save or Print Embedded PDFs From IE9

    I have a machine that is having difficulty saving or printing embedded PDF’s from web pages. Embedded meaning that the PDF is displayed in a reader window, within a web page. I am able to view the PDF without any problem however if I try and click the Save button, nothing happens. If I try to print the PDF, the browser crashes.
    This is a Windows 7 32-bit machine with IE 9 installed. I am also using Acrobat Pro 10.1.2. I have tried repairing Acrobat without any success, as well as uninstalling/reinstalling without any success. I am able to open PDF documents stored locally as files without any problem, and I am also able to open PDF documents from other websites that are simply links without any problem. I have tried disabling the Display PDF is Browser setting, but that only produces a red X in the placeholder for the embedded PDF. I get the same results if I log into this computer as another user. I have other computers with identical software installed that are working just fine without a problem.
    Anyone else having problems saving embedded PDF documents from websites? I am stumped as to why this happens or how to fix it.

    I am having a similar issue only with ADP pay statements that are embedded.  I have tried to uninstall, reinstall, installed Adobe XI, installed an older version.  When we click print first the reader crashes and then IE9 crashes.  Any help would be greatly appreciated.

  • Problem with colors when print to pdf in FM9

    Hi,
    we have some problems with printing colors to pdf with FM9.
    The FM document contains (1) eps file with a green box and (2) a rectangle created with FM graphic tools, filled with the same green color values (91/0/60/44)
    In FrameMaker the two colors really looks different, but so what, in the PDF both colors (eps) and rectangle got the same correct green color.
    Ok, the were different in creation, so they were CMYK and RGB, but your print shop could manage that.
    Now in FM 9:
    (1) If I do a "save as PDF"  and switch OFF "convert CMYK to RGB" the resulting PDF is the same as from FM8 (correct)
    (2) If I print to PDF via distiller and define the job options to "convert all colors to CMYK" the resulting rectangle green is very  different from the eps green.
    I tried different job options, the best result was "convert all colors to CMYK", other options just very more ugly.
    Does someone of you know a solution for your problem? Help is very appreciated. I could send example files if necessary.
    Thanks in advance.
    PK

    PK-ulm wrote:
    But we want to use the print option, using the distiller.
    Pia,
    this last sentence needs some explanation, I think. Why do you want to use the print option?
    Using the print option, you still go the same route as FrameMaker Win always did, which is using the RGB-only Windows postscript driver. Now, with FM9, you have the option to get CMYK colors directly to PDF, as defined, without any color conversion. And it *does* work, as long as you restrict your documents to either CMYK colors or spot colors coming from the FM libraries.
    So, again: why do you want to use the print option?
    On a sidenote: I'm not sure if I interpret your username correctly, but if you are able to understand German, you'll find some in-depth color tests made with FM9 here: http://www.hilfdirselbst.ch/foren/FM_9_und_Farben_in_PDFs____getestet_P387800.html
    Bernd

  • Browser: Print to PDF does not retain hyperlinks

    Hi,
    I was wondering if someone can give me some guidance.
    I have several html pages that contain numerous hyperlinks throughout the page
    On each page there is a javascript print button (ie. onclick="window.print();returnfalse..........)
    Whenever a user chooses the option from the print dialog box to print the page to Adobe PDF,  the output (pdf) does not retain the hyperlinks.
    Is there a way, feature, or product that will allow external users to print to pdf and still have the hyperlinks work?

    Printing to PDF never includes interactive elements - it is what it says, a digital copy of a printed page. No links on a sheet of paper = no links on a PDF printout.
    To retain interactive content you must save the page as a PDF, for example using the Acrobat plugin for IE or Firefox.

  • CROSS TAB PRINTING IN PDF PROBLEM

    Post Author: peachpx
    CA Forum: General
    Hi,
    My report uses a Cross Tab query with multiple lines for each value. Originally, I only get one line for Total In.  I modified Total In to include three lines Total Into Final, Total Into Initial and Total Out.  It displays fine in the report, but when I try to print from the server it opens PDF file with only one line present Total Into Final and the other two lines are cut off.  Is this a BUG in CRXII or is this can be fixed with correct formatting?
    Please help!

    Hi,
    cross tab is a diagonal report , u have to make query in such a way so that it returns the all field in row and columns way  i.e in diagonal form .
    U have to fetch total in same manner
    Rgds,
    Premraj

  • Problem with very sloooow printing of pdfs in Acrobat 7 Pro and 9 Pro

    Some pdfs print with no problem but others are painfully slow. We find that some that are slow with Adobe 7 Pro print fine with Adobe 9 Pro, while others are slow with Adobe 9 Pro but print fine with Adobe 7 Pro. Still others are slow with both. A huge productivity problem for us. Any suggestions? Thanks.

    when you get to the print screen it looks fine on the page, I've tried all the other options for scaling and when it prints it prints really tiny in the middle of the page. I have the paper set to letter. I did't see any options about shrinking the print.

  • Internet Explorer 8 with Adobe Reader 11 in one package - embedded PDF problem

    Hello,
    I am trying to package Internet Explorer 8 together with Adobe Reader 11 in ThinApp 5 for Windows 7. I am capturing on clean Windows XP with IE6. Of course, I am using "IEShims.dll" for IE8 in order to make it work in ThinApp.
    From the first look everything is ok, both application could be launched, but there are several issues:
    1) When I try to open embedded PDF file, IE hangs and loses response. I have found workaround for this: Adobe Reader should be opened at least 1 time before opening embedded PDF files. But I have found 2nd issue.
    2) Print button does not work. When I try to print embedded PDF from Adobe Reader instance, it does not work. Documents could be printed from virtual IE8 and from separate instance of Adobe Reader.
    What could you advise me? Are there any "small" tricks and tweaks that may help me with this?
    Thank you in advance!

    Have you tried capturing these application in separate packages?  I have been successful in capturing IE8 in one package and Adobe Reader XI in another package and then using the OptionalAppLinks option in the IE8 package to point to the Adobe Reader dat file.  Just make sure that both packages work outside of the applinking.  Also, you can try to install Adobe to the native machine and see if the embedded pdfs work in the virtual IE package. 
    These are just the troubleshooting steps that I would take to narrow down what is causing the issue you are seeing.
    Lance

  • Printing to PDF printer problem

    Since April I have been having a problem printing internet documents to a pdf file. When I print bank transaction documents to a PDF printer the form structure prints correctly but the data that goes in the form is all jumbled up in unreadable characters. I just tried to print a Govenment census confirmation to a PDF file using the PDF Printer in Acrobat 9 and it acted like the Bank printing problem. All other printing of PDF documents works fine. I have the latest updates all installed and the problem still is there. This problem did not exist in the first half of March. Any suggestions?

    Hi, I am having the same problem on multiple computers starting this spring as you reported.  I just bought a new win 7 64-bit (happens on 32 bit too) and installed Adobe 9 Pro.  First time I used it to print from the web on IE 9 the garbage printing happened.  I've started to use other methods of creating PDFs because the Adope PDF printer is too unreliable, sometimes it works, more often it does not.  The problem also occurs when printing a PDF of a word document.  Fortunately, I can use Word to save in PDF format which does work.
    Very Very Aggravating !!

  • Embedded PDF object .postMessage doesn't work with Reader DC on IE

    In our application, we have PDFs embedded in the browser with an object tag such as this:
    <object id="pdfObject" width="100%" height="100%" type="application/pdf" data="#{url}"></object>
    There are HTML/Javascript controls on the page which communicate with the PDF via this syntax:
    document.getElementById("pdfObject").postMessage([arg])
    This has been working great with Adobe Reader versions 10+.  It actually still works with Reader DC on Firefox.  However, there is a problem with Adobe Reader DC on Internet Explorer version 11.
    All I can tell so far is the "postMessage" function isn't appearing.  Using IE dev tools:
    document.getElementById("pdfObject").postMessage
    Object doesn't support this property or method
    Any help with this would be amazing.  It is a critical part of our application here.

    My application has two-way communication between browser and embedded PDF.  Basically a user clicks a button on the browser and via Javascript the embedded PDF form is submitted.  Everything was working before the update to Reader DC, but now it fails in Internet Explorer, but not in Firefox (or Chrome, if the Reader plugin isn't disabled entirely by their new default disable-NPAPI plugin policy...)
    I originally was troubleshooting communication from the browser to the embedded PDF, which is done according to the Javascript for Acrobat API reference (page 358?), in the browser, as follows:  document.getElementById('pdfObject').postMessage([args])
    Whatever is happening, postMessage is not a valid property or method of the PDF object
    Then I found this other thread:
    Adobe Reader DC: hostContainer not worked on IE
    I confirmed that within the embedded PDF, when setting up communication from the PDF to the browser, it is not able to register the hostContainer (again, on IE only)
    I have this script on initialization within the PDF:
    <---
    this.disclosed = true;
    if (this.hostContainer) this.hostContainer.messageHandler.onMessage = onMessageFunc
    this.hostContainer.messageHandler.onDisclose = function() { return true; }; }
    ---->
    Problem is this.hostContainer is null.
    The main point here is all of this was definitely working before updating to Reader DC, and is still working with DC on Firefox, but not on IE.
    To complicate things further, I have now uninstalled DC and downgraded to Reader 11.0.10.32, and am having a new bug, this time hostContainer is detected and communication to and from the PDF works again, but the submitForm action is failing with "Unable to open URL to submit this form" and "External undefined: exec".  Testing the exact same version and script with Firefox works fine

  • Why does my computer freeze when I try and print a pdf?

    I have a new computer with Windows 7 64 bit. It seemed that suddenly i developed this problem when trying to print a pdf file with Adobe X. Everything would look like it was going fine, but when the print download screen popped up, it would not download the pdf file and my computer froze. I have to manually shut down my computer to unfreeze it. I have tried to print using an earlier version of Adobe (Adobe 9), tried a different printer, tried printing as an image, or print as a file. Nothing works. Any suggestions? Thanks.

    I had a similar problem after upgrading to Windows 7. The problem seemed to be that there was a dialog box that opened
    that was not visible on the screen and it was blocking the print completion. Try this. Open the Adobe PDF Printing Preferences and clear the field "Rely on system fonts only, do not use document fonts." When I did that it solved my problem.
    The unseen dialog box seems to be the fault of Windows 7, in my opinion.

  • Adobe Reader Crashes when I attempt to print a PDF

    Hi,
    I am running 11.0.02 Adobe Reader on my Macbook Pro (10.6.8 Snow Leopard). Each time I download a pdf via Safari (5.1.8) and try to print, Adobe Reader locks up and crashes.
    When we logged in on a guest account on my Mackbook Pro, the problem disappeared. Printing Worked.
    Logged back in as me, then deleted a number of p.list files in my library preferences, even tried deleting and resintalling Adobe Reader. Still the same problem. Try to print a pdf document in Safari, Adobe Reader locks up and crashes. Save the same file to the desktop and open it directly in Adobe Reader, try to print, Adobe Reader locks up and crashes.
    Any thoughts on how to fix this?
    David

    Hello Pat,
    You are absolutely the BEST.
    I followed your two recommendations and now the program is working perfectly. Yes, my Reader XI was version 11.0.10 when I was having the problems.
    I never would have figured out the solution to the problem without your help.  I was very pleased with your follow through. 
    I really appreciate your help.  THANK YOU! – THANK YOU!
    Adobe is a great program – I have used it for years and this is the first time I have had any problem.  
    Kind regards,
    Hartley

  • RE-printing a PDF book With Acrobat 9

    I have this strange problem. When I print a pdf book as a pdf again (reason I am doing this if because it will give me a page size that will go with the entire book, and as a result, it will be easier to crop the book.), the file size becomes WAY bigger than the original size of the PDF.
    This is the basic process when I do the the printing to pdf:
    Select ALL the pages in the book.
    Go To Print.
    Under the Name List, select Adobe PDF.
    Click Properties.
    On the Layout tab, Click Advanced. Under Paper Size, Select Postscript Custom Paper Size.
    Select the Unit (e.g. Millimeter).
    Once done, go to the ADOBE PDF Setting tab, and then select Default Setting to Standard.
    click all the OKs, until you are ready to print.
    I have tried to to look for the answer on other forums, and googling, but no proper explanation or advice.
    Thanks

    Tried that. That doesnt solve the problem. File is still as big as
    hell. Acrobat 8 works like a charm for this process. I even made
    screenshot for the 'small size' preset and compared it to Acrobat 9.
    Seems the same, so not sure why does it make files bigger. Dont get
    started with file optimization because this book im dealing with here
    has bad images to any downsizing is going to mess it up. Booya:-@

  • Print to PDF (Firefox addon) won't print Combo Box Dropdown lists

    Hi. I have this webpage that a user can type information into, there are also drop down lists where they can choose a value. My problem is that when "Print to PDF" converts the page the typed info shows but none of the changed values in the drop down lists appear in the boxes just the default value for instants under "Postage" the user can drop the list down and pick a value of £5.50 but the PDF just shows "Postage" . If I do a "Print preview" all the changed values are shown correctly. Any Ideas? Cheers Terry

    Hello,
    '''Try Firefox Safe Mode''' to see if the problem goes away. Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * You can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''
    Thank you.

  • Printing to PDF– printer offline

    I'm trying to print a document to PDF.
    In the dock is a printer icon labeled Adobe PDF 8.0 @ My Computer
    When I click on the icon a box opens, showing the cue.
    It says "Printing '2012 AlumBulletin.indd.'
    Looking for printer...
    Printer offline.
    How do I get the PDF printer back online?
    Is there some prefs file to trash and then restart?

    Hi, I am having the same problem on multiple computers starting this spring as you reported.  I just bought a new win 7 64-bit (happens on 32 bit too) and installed Adobe 9 Pro.  First time I used it to print from the web on IE 9 the garbage printing happened.  I've started to use other methods of creating PDFs because the Adope PDF printer is too unreliable, sometimes it works, more often it does not.  The problem also occurs when printing a PDF of a word document.  Fortunately, I can use Word to save in PDF format which does work.
    Very Very Aggravating !!

Maybe you are looking for

  • The computer has rebooted from a bugcheck. The bugcheck was: 0x000000d1

    The computer has rebooted from a bugcheck.  The bugcheck was: 0x000000d1 (0x0000000000000000, 0x0000000000000002, 0x0000000000000000, 0xfffff80003cf33f7). A dump was saved in: C:\Windows\MEMORY.DMP. Report Id: 041715-27750-01. https://drive.google.co

  • Difference in extractvalue in 9.2.0.3 and 9.2.0.4

    Essentially my problem is that in 9.2.0.3 (Standard Edition Database), the ExtractValue is not removing the xml tags for a select statement, whereas the 9.2.0.4 (Enterprise Edition Database) is. See below. In 9.2.0.3 Standard Edition: Running the fol

  • Having problems with font

    i am currently building a website on dreamweaver on a mac and i am using tables, within the tables i want text and the FONT i have chosen is Brush Script MT Italic. However when i preview the webpage in safari the text is in a completely different fo

  • Missing Library in Encore CS5

    Sorry peoples, this has prolly been asked lots of times, but I am going myopic with looking. I had a trial version of the master collection which expired. Encore didn't really want to play in the trial version in any case. I have now registered with

  • AD Connector upgrade

    Hello, If I upgrade my existing Active Directory Connector, will I loose my Custom tasks. I want to understand what all will be impacted. I also  have Exchange integrated with OIM. Currently I am using 11.1.1.5 version and want to upgrade to  11.1.1.