Show PDF document in Browser (Internet Explorer)

Hi
I need to show a PDF document in Internet Explorer.
We have some static PDF documents in the application. Depending on user selection we determine the name of the PDF document and somehow we have to display in Browser.
Refer below code, steps and problem.
Step 1) I convert the PDF document to ByteArrayOutputStream using below code in a Java class and store this stream to a session variable.
File pdfFile = new File("c:\\temp.pdf");
byte[] data = new byte[(int) pdfFile.length()];
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
FileInputStream fileInputStream = new FileInputStream(pdfFile);
int count = 0;
while (fileInputStream.read(data) != -1)
byteArrayOutputStream.write(data, 0, count);
Step 2) After this the control is transferred to a servlet. It retrieves the stream from session variable and does following (Servelt is called such that it should open new browser window. This is OK.)
response.setHeader( "Content-disposition", "inline; filename = avb.pdf");
response.setContentType("application/pdf");
response.setBufferSize(byteArrayOutputStream.size());
response.setContentLength(byteArrayOutputStream.size());
try
     byteArrayOutputStream.writeTo(response.getOutputStream());
     response.flushBuffer();
catch (IOException e)
     //Handle execption               
PROBLEM: It asks to save pdf document. But after saving I am not able to open document. It shows messge that the document is not of PDF type. But it is actually a PDF so my guess is that something is wrong in above code snippets.
Please help.
Thanks.

FileInputStream fileInputStream = new FileInputStream(pdfFile);
int count = 0;
while (fileInputStream.read(data) != -1)
    byteArrayOutputStream.write(data, 0, count);
}Poor unloved count variable.

Similar Messages

  • Did Adobe Acrobat/reader stop providing browser integrated PDF viewing(addin) for Internet Explorer?

    Did Adobe acrobat and reader stop providing browser integrated PDF viewing capability for Internet Explorer?
    Hi, I have been trying to view PDF's directly on my browser (Internet Explorer 9). We used to be able to have this available. To be honest last configuration that did work was Internet Explorer 8 with Adobe Acrobat 7. But I recently tried with Intenet Explorer 9 with Adobe Acrobat X and did not work as expected (I tried to activate the add in for Adobe but the adobe addin for PDF did not show up) I have the following questions:
    1) Do you still provide PDF's viewing capabilties on Internet Explorer?
    2) If yes: Is there a propper Add-in we (users) are able to install for Internet Explorer?
    3) if yes: Do we require to have Adobe Acrobat to have this capability? (this was my experience with IE8 and Adobe Acrobat 7)
    Additional Info:
    There seems to be an addin for Chrome wich works as expected (opens PDF in browser) to this current date. This does not happen on IE.
    Thanks in advance.
    AlbertCastle

    Are you using the 64-bit edition of Internet Explorer?
    The Adobe Reader/Acrobat plugin is 32-bit, and will not work on a 64-bit browser.
    Other possibilities: http://helpx.adobe.com/acrobat/using/display-pdf-browser-acrobat-xi.html

  • Opening an Acrobat Reader document terminates my Internet Explorer session

    I'm using IE9 and recently every time I try to open an Acrobat PDF document it terminates my IE session.

    Hello there.  Please see below for the answers you are seeking.
    Regards,
    David
    From: Ankit_Jain [email protected]
    Sent: Monday, 21 May 2012 9:03 PM
    To: David Parker
    Subject: Opening an Acrobat Reader document terminates my Internet Explorer session
    Re: Opening an Acrobat Reader document terminates my Internet Explorer session
    created by Ankit_Jain<http://forums.adobe.com/people/Ankit_Jain> in Adobe Reader - View the full discussion<http://forums.adobe.com/message/4425289#4425289

  • Is there any way I can trasnfer my "favourites" from my old browser-Internet Explorer to Firefox?

    For example: I have quite a lot of favourites saved on my old browser, Internet Explorer, is there any way I could tranfer them to Firefox??
    Many thanks,
    Maria

    * Export the favorites in IE to an HTML file (bookmarks.html): File > Import and Export
    * Import the HTML file in Firefox: Bookmarks > Organize Bookmarks > Import & Backup > Import HTML: From File
    See also:
    * http://kb.mozillazine.org/Import_bookmarks ("Import from another browser" and "Import from file")
    * [[Importing Internet Explorer Favorites from another computer]]
    * [[Importing Bookmarks from an HTML File]]

  • When I click on show pdf in a browser then safari goes black. What to do?

    When I click on show pdf in a browser then safari goes black. Other browser like firefox work. What to do in Safari?

    Have you installed any PDF plugins or Adobe Acrobat Reader?  Schubert-it's PDF Plugin and Adobe's Acrobat Reader both may need updates to work properly in Safari.  Double check if you have either which version needs to be installed.

  • I have URL links to PDFs in an excel spreadsheet, the document opens in Internet Explorer, even though Firefox is my Default browser

    I have been through all of the default browser setups and I still Internet Explorer opens. I have an internet shortcut to an excel document on my desktop and Firefox opens just fine.
    Any ideas?

    Hello nanemy1854, set also firefox as default browser in Add or Remove Programs list in win xp, see for more information : [https://support.mozilla.org/en-US/kb/setting-firefox-default-browser-does-not-work#w_windows-xp Firefox as default browser in win xp].
    thank you

  • PDF's in Acrobat Reader X will not open when using the browser, Internet explorer opertes all ok? Mozella 4 is the default browser! Windows XP Home ed with all latest updates!

    When using the Mozella Firefox 4 browser and the NEW version Adobe Reader X, PDF's online will not ever open. After 1-3 minuites, I eventually get a message the Adobe reader is running, but need to close and try again! I get same results when trying again.
    Internet Explorer operates and opens the online PDF's all ok and the Adobe Reader X seems to operate all else ok!
    I think, but not sure, that this issue appeared when the Adobe Reader updated from the older version 9 or so to the NEW Adobe Reader X version about 1 or 2 weeks ago, but not sure. I just remember that Mozella always worked ok previously to the Adobe Reader X version for opening online PDF's last month, etc.
    Note that I said that Internet Explorer browser operates ok Using the New automatically upgraded Adobe Reader X for viewing PDF"S! (adobe notified me that the new version 10 (X) was available for updating, etc) I also just discovered that google chrome browser opens the online PDF's ok!
    I have not trying re-storing the computer to the previous month, etc, since the issue seems to be with Mozella not liking the Adobe Reader X version and Internet Explored browser operating ok!
    Any ideas????

    I had the same problem and my solution was to disable the PDF extension that came with Firefox 4 which belongs to another company. I found out that it wast interfering with ReaderX. I unabled it and restarted Firefox. I have had no problems since then. Go to Tools, Add-On and click on Extensions and disable the PDF extension. I hope this helps

  • PDF's not loading in browser - Internet Explorer 9, Adobe Reader X, Win 7 x64

    I have Adobe Acrobat Reader installed and have a site that uses forms that need to be filled and submitted.  The problem is that when I open the form, they are opening in a seperate Window.
    I've uninstalled and reinstalled Adobe Reader
    I've done 'detect' and repair several times.
    I have checked and unchecked "Display PDF in browser" under EDIT -> PREFERENCES -> Internet
    What I CAN tell is that when I go into Internet Explorer and look at the addons I do NOT see any of the acrobat add-ons that I see on my other computers (that work).
    I've looked in the program files/common files/adobe/acrobat/active x folder and all the files are there but I don't see a way to make Internet Explorer force loading those or getting them in there manually.
    Any help would be appreciated, I'm at my wits end!

    Thank you for this.
    One you said this I checked and it was running IE 64bit.
    For some reason IE*64 was the default browser (which shouldn't happen).  Since IE*32 wouldn't allow me to set it as default (greyed out) I installed Chrome, set it as default browser then fired IE*32 back up, set it as default and vioila it's fixed.
    I'm embarrased I didn't think of that first....
    Thank you!

  • Microsoft Update KB2670838 will not allow PDFs to display in Internet Explorer 11 and 10

    HI all,
    When upgrading to Internet Explorer 11/10 in Windows 7 Enterprise, there is an update KB2670838. It halts the operations of PDF's into the browser, instead it throws up a blank page with a small box thats crossed and it wont let them show up in Adobe Acrobat/Reader.This update is a requirement for Internet Explorer 11 to install and while wed love to get on the latest version, we just cant with this problem. Internet Explorer 9 displays PDFs in broswer just fine.
    We have tried in Adobe to make it so it will not display in broswer by unchecking that option, but it still does not display. reading up on it there is a registry hack that helps alivate this but it is only for Windows 8/8.1.
    Any tips/solutions/Help for this would be appreciated for this.
    Thanks!

    The solution is http://support.microsoft.com/kb/2716529 but as you write, the "fixit" is only for Windows 8.
    To apply it on Windows 7, download, unzip, then run the attached registry script.

  • Adobe PDF direct open in internet explorer problem

    Hi all,
    I have a problem when I want do download a pdf byte stream created by Jasper Reports. I read the necessary information out of my formbean (Struts). Here's the code from the jsp:
    response.setContentType(runReportForm.getContentType());
    String filename = runReportForm.getTechName() + "." + runReportForm.getMode();
    response.setHeader("Content-Disposition", "attachment; filename='" + filename + "'\"");
    byte[] bytes = runReportForm.getBytesOutput();
    response.setContentLength(bytes.length);
    ServletOutputStream ouputStream = response.getOutputStream();
    try {
            ouputStream.write(bytes, 0, bytes.length);
            ouputStream.flush();
         ouputStream.close();
    } catch (IOException e) {
    }The content type for PDF is "application/pdf" or "application/octet-stream", of course.
    Normally, it should open a download dialog with the question "Open" and "Save". In this download dialog is the Adobe icon displayed, too.
    But in my case, I get the dialog with an empty (like unknown file format) icon, but the text says "Adobe Acrobat Document". When I click to open it directly it will open in a separately Adobe Acrobat window instead of displaying in the internet explorer. (Saving to the hard disk works fine).
    Of course I have set the setting "display inside browser" in the options of my Acrobat Reader.
    The same procedure with Excel (content type "application/vnd.ms-excel") makes no problems.
    Thanks for any help.
    Manuel

    If you want to open the PDF in the browser you have to explicitely set the content type to "application/pdf", if you use "application/octet-stream" you'll always get the download box and when you choose to open from this box the reader will be used because the reader is configured to open PDF documents in the windows filetypes settings.

  • Links to PDF files bringing up Internet Explorer has stopped working message.

    When I click on a link to a PDF file - such as a bank statement - a box shows up on screen "Internet Explorer has stopped working correctly. Windows will close the program and notify you if a solution ios available.

    Hi,
    Start>Event Viewer.... post back with the error stack.
    the first step in troubleshooting web browser issues is to test by running in noAddons mode. NoAddons mode leaves ActiveX enabled, but stops COM Addons and Extensions from being loaded. IE10+ has Tools>ActiveX filtering... some websites do not test
    for this and may think that Flash is not installed on the client.
    When posting internet related questions it is helpful if you include the full address of any websites you are having issues with.
    Regards.
    Rob^_^

  • Opening pdf documents in browser impossible

    Hi there all,
    have problems opening pdf documents in safari window. On all of my macs (except for the macpro) pdf docs open in the safari browser window using the pdf plug-in. Installed plug-in list tells me that adobe pdf-viewer plug-in is available. Why doesn't it work ? Running Firefox, same problem. Application asks what to do : open with preview app (standard), but no other possibility, although I have latest adobe reader app. installed, as well as acrobat professional 8.xxx.
    What is going wrong ? It seems pdf plug-in is not found or recognized. Help !

    Hi
    You can view all pdf doc in solman itself just select the same and click display icon or just double click it it will open in solar01 or solar02 itself but wait for some time to get it loaded.
    whereas if you want to open the doc in explorer just click the attributes and generate url and paste the same in explorer.
    You can view in explorer this way.
    If you are facing any issue in the above standard procedure please contact your basis team for the same.
    Please reward points.

  • Fscommand is not working when opening PDF document in browser with Acrobat 9, why?

    We embedded a flash application in PDF using screen annotation. In the flash we use fscommand to call methods available in AcroJS.  In acrobat reader 9, if we view the document in Internet Explorer, we receive a security sandbox violation message saying that it cannot make fscommand calls to <unknown> (allowScriptAccess is ). But when we open the document in Firefox, it works fine.

    Have a read of this article on the web:
    http://www.actionscript.org/resources/articles/99/1/FS-Command-JavaScript-Library/Page1.ht ml
    The part that caught my eye was the following:
    "...These methods will not work with Internet Explorer on Macs. This lack of functionality is a brower issue with communication with plugins and cannot be resolved by anyone except MicroSoft. "
    I wonder if the same is true for Windows?
    Sabian

  • Website requires minimum browser: Internet Explorer 6.0

    I am trying to work in an image based website.  The message I recieve when I try to get into the site:  This image flow resource requires one of the following miminum browser versions:  Internet explorer 6.0.  The browser you are currently using is Apple-Mac Safari Version 5.0.  Any suggestions?

    Can you tell us what the website address is?
    There are two possibilities.
    First, the site is doing simple browser sniffing because their layout only looks good in IE - in which case you might be able to trick the server into thinking you have a different browser (Safari - Preferences - Advanced - Show Develop Menu, then close preferences window and use the Develop menu - User Agent - Internet Explorer 7).
    Or second, the site uses Windows-based ActiveX to integrate site code with Windows - in that case, there's nothing you can do to get it working on a Mac (other than install Windows through a virtualization system such as Parallels Desktop, VMWare Fusion, or Boot Camp).
    Even Microsoft is ashamed of IE6, and wants everyone to upgrade it to a newer version. Websites coded solely for Internet Explorer - and IE6 at that - are a thankfully dying breed.
    Matt

  • Show PDF in IE browser

    Hi, I am experiencing a problem with the IE browser. What I am doing is, I receive a PDF file from a server and write the whole PDF file on the outputstream of the browser, with certain headers that need to be set. The Netscape shows the PDF nicely inside the broswer using adobe plugin, but IE instead opens up a file download box(doesnt ask me to save/cancel) and then start the standalone adobe acrobat reader program (not inside IE) and display's the message "File not found". Below is the code.
    java.net.URL pathToReportURL = new java.net.URL(path);
    java.net.HttpURLConnection conn = (HttpURLConnection)pathToReportURL.openConnection();
    conn.setAllowUserInteraction(false);
    conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    conn.connect();
    String contentType = conn.getContentType();
    response.setContentType(contentType);
    int contentLength = conn.getContentLength();
    response.setContentLength(contentLength);
    response.setHeader("Content-Disposition", "inline; filename=name2.pdf");
    BufferedInputStream  bis = new  BufferedInputStream(conn.getInputStream());
    BufferedOutputStream bos = new BufferedOutputStream response.getOutputStream());
        byte[] buff = new byte[2048];
        int bytesRead;
        while(-1 != (bytesRead = bis.read(buff, 0, buff.length)))
            bos.write(buff, 0, bytesRead);
        bis.close();
        bos.close();
        conn.disconnect();The content type is set as application/pdf properly and the Content-Disposition is set to inline with the filename specified. Anybody have a clue ?

    One thing I am confused about is that , Isn't
    "Content-Disposition : Inline" supposed to
    o show the PDF inside the browser.No, 'inline' only means that it is not an attachment, so you don't get the 'Save As' dialog.
    It can also be that it is an Adobe configuration issue. In Adobe, choose Edit/Preferences/Internet, and verify that the box �Display PDF in Browser� is checked.

Maybe you are looking for