PDF file display on the browser

Hi,
I am using struts DispatchAction to display the existing file (on the server) on the web browser. My code works on FireFox and Google Chrome. But displays empty screen when executed on IE. Please refer to the Action class and kindly help me out what am I missing in the code inorder to work on all browsers.
Page Access URL: http://localhost:8080/pdfWeb/showpdf.do?action=displayPdf
Action Class
public class BaseAction extends DispatchAction {
     public ActionForward displayPdf(ActionMapping mapping, ActionForm form,
               HttpServletRequest request, HttpServletResponse response)
               throws Exception {
     String filepath = "/test/pdf/sample.pdf";
     //For Local:
     String baseFolder = "/Users/raghu/Documents/Shared/personal/Final_Out";
     String contentType = getServlet().getServletContext().getMimeType(filepath);
     response.setContentType(contentType);
          //New
     response.setHeader("Expires", "0");
          response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
          response.setHeader("Pragma", "public");
OutputStream out = response.getOutputStream();
byte[] pdfContent = this.loadFile(baseFolder + filepath);
out.write(pdfContent, 0, pdfContent.length);
if (out != null) {
out.close();
          return null;
     public static byte[] loadFile(String sourcePath) {
     byte[] output = null;
     InputStream inputStream = null;
          try {
               inputStream = new FileInputStream(sourcePath);
               output = readFully(inputStream);
               if (inputStream != null) {
                    inputStream.close();
          catch(IOException ioex) {
               //Handle Exception
          return output;
}

We've had a number of IE related issues displaying PDF files. The first is that IE, rather than paying much attention to Mime type, still looks for extension names in the URL. Nasty as it sounds, it's sometimes necessary to ensure that your URL ends in ".pdf". It may be enough to append "&x=.pdf" onto the URL (which should have no significant impact).
(Another is that some versions can't write a new PDF to an existing window already showing an old one).

Similar Messages

  • Is it possible to print a pdf file served to the browser?

    I have a servlet that will send a pdf file to the browser (IE), (i set the content type to "applicaction/pdf"). Now I need a way to create a print button to allow user that option, seems the browser print button is not satisfactory. Can a pdf be embedded in a web page somehow? Sounds like I would be dealing with 2 different reponse types "application/pdf" and "text/html"..I think the print button would call a method doing some extra things other than what the browser print button does. Is this possible? Thank you

    found an answer..thanks

  • Firefox 33 doesn't display a pdf file when using the response object

    Firefox 33.0.2 does not display pdf files when using the code below from an asp.net program, which works for previous versions of Firefox, and also works with IE. I'm using the built-in pdf viewer. All of my plugins are disabled.
    Dim strPDF As String
    strPDF = Session("filname") 'pdf filename
    Response.Clear()
    Response.ClearHeaders()
    Response.Buffer = True
    Response.ContentType = "application/pdf"
    Response.CacheControl = "Private"
    Response.AddHeader("Pragma", "no-cache")
    Response.AddHeader("Expires", "0")
    Response.AddHeader("Cache-Control", "no-store, no-cache, must-revalidate")
    Response.AddHeader("Content-Disposition", "inline; filename=" + strPDF)
    Response.WriteFile(strPDF)
    Response.Flush()
    Response.Close()
    Response.Clear()
    Response.End()
    Session("filname") = ""

    Thanks cor-el. You pointed me in the right direction. It appears to me that a reported Firefox 33 bug with the handling of compression (Transfer-Encoding: chunked) is the culprit (https://support.mozilla.org/en-US/questions/1026743). I was able to find a work-around by specifying the file size and buffering. Below is my code, with some code from http://www.codeproject.com/Questions/440054/How-to-Open-any-file-in-new-browser-tab-using-ASP.
    Dim strPDF As String
    strPDF = Session("filname") 'pdf filename
    Dim User As New WebClient()
    Dim FileBuffer As [Byte]() = User.DownloadData(strPDF)
    If Not (FileBuffer Is Nothing) Then
    Response.Clear()
    Response.ClearHeaders()
    Response.CacheControl = "Private"
    Response.AddHeader("Pragma", "no-cache")
    Response.AddHeader("Expires", "0")
    Response.AddHeader("Cache-Control", "no-store, no-cache, must-revalidate")
    Response.ContentType = "application/pdf"
    Response.AddHeader("content-length", FileBuffer.Length.ToString())
    Response.BinaryWrite(FileBuffer)
    Response.Flush()
    Response.Close()
    Response.Clear()
    Response.End()
    End If
    Session("filname") = ""

  • Bug - Safari 5.1.5 breaks the keyword search of PDF files displayed on Safari

    Bug - Safari 5.1.5 breaks the keyword search of PDF files displayed on Safari.
    After updating to Safari 5.1.5 with Adobe Acrobat Pro 10.1.3 on Mac OS X 10.6.8, it is not possible to search for keywords in PDF documents displayed on Safari.
    I understand that it is a bug. Is there any way to fix it?
    Thanks.

    Hi...
    Try deleting a plugin...
    Open the Finder. From the menu bar click Go > Go to Folder
    Typs this:    /Library/Internet Plug-Ins
    Move the Adobe PDF Browser plugin  (or PDF Browser plugin) to the Trash.
    Quit then relaunch Safari to test.
    If that doesn't help, back to the Finder menu.
    Go > Go to Folder
    Type this:  ~/Library/Caches/com.apple.Safarfi/Cache.db
    Move the Cache.db file to the Trash.
    Quit then relaunch Safari to test.

  • How can I retain the attached .pdf files (displayed as icons) from my word file 2010 to a pdf file?

    Hi everybody,
    I have looked for an answer in this forum ... without any good result.
    I worked on a Word 2010 file with some attached pdf files. These attached files are displayed as icons on the word file. If you double click on them, you can consult them. This works very good.
    Problem: I would like to convert this word 2010 file into a pdf file, which keeps the icons (linked to attached files) active. If I "pdf" this with my current system, icons are displayed as pictures: I cannot open the attached files.
    My question is very simple: is it possible to retain these active icons (= to open attached documents) in a pdf file? Which adobe package should I use?
    Many thanks for your help 
    cheers
    elgreengo

    No, it's not possible, but I agree it would be a very nice feature.

  • Unable to open .pdf in Firefox 3.6.8 with Adobe Reader 9.3.3 installed. Error message is "The Acrobat/Reader that is running can not be used to view PDF files in a web browser."

    I am unable to open a PDF file in Firefox 3.6.8. Adobe Acrobat Reader 9.3.3 is installed. I get the error message "The Adobe Acrobat/Reader that is running can not be used to view PDF files in a web browser."

    You can get that error if there is still an old Adobe Reader plugin in the plugins folder in the Firefox program folder.
    C:\Program Files\Mozilla Firefox\plugins\nppdf32.dll
    See also http://kb.mozillazine.org/Adobe_Reader

  • Acrobat plug-in. I get this when try to opem. The Adobe Acrobat/Reader that is running can not be used to view PDF files in a Web Browser. Please exit Adobe Acrobat/Reader and exit your Web Browser and try again. Don't problems w/ Internet Explorer-

    Acrobat plug-in.
    The Adobe Acrobat/Reader that is running can not be used to view PDF files in a Web Browser.
    Please exit Adobe Acrobat/Reader and exit your Web Browser and try again.

    See if you can find a NPPDF32.DLL files in the Firefox program folder (C:\Program Files\Mozilla Firefox\)
    You can see the installed plugins on the about:plugins page.
    * http://kb.mozillazine.org/about%3Aplugins
    You can set the pref plugin.expose_full_path to true on the about:config page to see the full path of plugins on the about:plugins page.
    It is best not to leave that pref set to true as it exposes that full path to web servers, so reset that pref to false after you are done with the about:plugins page.
    You can open about:plugins and about:config via the location bar, like you open a website (about: is a special protocol to access some build-in pages).
    If you get a warning when opening the about:config page then you can confirm that you want to continue.
    See Manually uninstalling a plugin:
    * https://support.mozilla.com/kb/Troubleshooting+plugins

  • Cant open pdf file ..it says....the adobe/acrobat reader that is running can not be used to view PDF files in a web browser. please exit adobe/acrobat reader and exit your web brouser and try again

    cant open pdf file ..it says....The adobe/acrobat reader that is running can not be used to view PDF files in a web browser. please exit adobe/acrobat reader and exit your web browser and try again

    -> [[Troubleshooting extensions and themes]]
    -> Clear Cookies & Cache
    * https://support.mozilla.com/en-US/kb/Template:clearCookiesCache
    -> [[How to clear the cache#w_clear-the-cache|Clear the Network Cache]]
    '''Plugins Updates'''
    Your Flash plugin is quite older. You need to update it.
    * Adobe Flash Player 11.0.1.152 (3.59 MB)
    * http://get.adobe.com/flashplayer/
    Your Java plugin is quite older. You need to update it.
    * Java Version 6 Update 29
    * http://java.com/en/download/index.jsp
    * [[Using the Java plugin with Firefox]]
    -> Update All your Firefox Plugins
    * https://www-dev.allizom.org/en-US/plugincheck/
    * http://www.mozilla.com/en-US/plugincheck/
    '''When Downloading Plugins Update setup files, Remove Checkmark from Downloading other Optional Softwares with your Plugins (e.g. Toolbars, McAfee, Google Chrome, etc.)'''
    Check and tell if its working.

  • The Adobe Acrobat/Reader that is running can not be used to view PDF files in a Web Browser. Please exit Adobe Acrobat/Reader and exit your Web Browser and try again.OK. I followed the instruction and the problem still persists.

    I got the following pop-up when I tried to open an online PDF file:
    The Adobe Acrobat/Reader that is running can not be used to view PDF files in a Web Browser.
    Please exit Adobe Acrobat/Reader and exit your Web Browser and try again.
    I tried many time, and it really doesn't work.
    The plug-in I have is Adobe Acrobat 8.3.0.280

    After I upgraded to Firefox 5, I had the same problem and I did a work around temporarily. I went the tools menu, then Add-ons, then clicked the "Plugins" on the left side (4th one down). I "disabled" both Adobe Acrobat 8.3.0.280 and Adobe Acrobat 10.1.0.536 using the disable buttons on the right side. PDF files now open again. However they are outside the actual browser.
    My guess is that Adobe didn't catch up yet with a new update to work with Firefox or vice versa.
    Hope that helps!
    Michael

  • Not to display the file name in the browser bar.

    Hello,
    Merry Christmas to all,
    Is it possible not to display the file name in the browser bar?
    Like say, when we write www.rediff.com, the index page name is not displayed.
    Likewise is it possible for any other page too.
    What I want is not to display any of the page name for the whole application.
    Whichever page is requested the page name should not appear in the address bar of the browser.
    How will I do that, what logics should I apply?
    Please suggest,
    Thanks,

    first, what does this have to do with Java?
    second, no; in order to display something, the browser needs to know where it is. and if it knows, then a user can find out too. maybe you can make it not show up in an address bar sometimes, but that really achieves nothing

  • Firefox will not allow me to download/display pdf files - wheres's the glitch

    When I click on a pdf file to download it nothing, zero, happens and I have to switch to IE and start all over to get the pdf file - very incomvenient. I use Norton security software which does a few things to me that I don't like but can't find but since it does not interfere with IE I doubt that it's in Norton so must be fire fox. This is a phenomenon that has just arisen in the last few months or so

    Reading PDF files is not Firefox, you can read file external to the browser or with a plugin.
    The Download Window closes instantly the download finishes or may not even open at all bring it back with Ctrl+J
    You are using Foxit Reader instead of Adobe Reader
    make sure it is compatible with Firefox 5 if it is running within Firefox, check their site
    or install Adobe Reader unfortunately it comes with Adobe Air
    whatever that it, and being adobe you have to watch out for
    crapware also being install, McAfee Security Scan, Google Chrome, Adobe Air

  • Preview: In a group of PDF files in the same window, going to the next or a previous PDF file displays the bottom of PDF by default, not the top. How do you change this?

    Preview: In a group of PDF files in the same window, going to the next or a previous PDF file displays the bottom of PDF page by default, not the top of the PDF page. How do you change this? In Mac OS 10.9 and previous, going to the next or previous PDF file displays the top of the PDF by default. Is there a way to change this back? When I go to the next or previous PDF file, I want to first view the top of the page, not the bottom. This really doesn't make any sense. Any help? Thanks!
    MacBook Air (13-inch, Mid 2012)
    2 GHz Intel Core i7
    8 GB 1600 MHz DDR3
    500 GB Flash Storage
    Preview Version 8.0 (859)
    Mac OS 10.10.1

    That to me seems like a bug in Yosemite.
    Apple Feedback http://www.apple.com/feedback/
    Bug Reporter https://bugreport.apple.com/

  • Chrome - Adobe-Acrobat/Reader can not be used to view PDF files in a web browser.

    I can't view PDF files via Chrome (it works on Internet Explorer but I prefer Chrome)  -  the error below has arisen recently on Chrome, though I can't see what has changed.
    "Acrobat plug-in
    The Adobe-Acrobat/Reader that is running can not be used to view PDF files in a web browser. Please exit  Adobe Acrobat/Reader and exit your Web Browser and try again."
    I have looked through Forum articles on similar errors and have tried the following(text copied from other Forum entries)
    Repair Adobe Acrobat (from Acrobat)
    Repair Adobe Acrobat (from Control Panel
    Configure Acrobat  as a helper application: Choose Edit > Preferences., Select Internet on the left., Deselect Display PDF In Browser Using [Acrobat application], and then click OK.Quit Acrobat or Reader
    Create a registry item for Acrobat: with Regedit: If the registry item doesn't exist on the system, do the following: Go to Edit > New > Key and create the missing HKEY_CLASSES_ROOT\Software\Adobe\Acrobat\Exe.Go to Edit > New > String Value and name this key (Default).Select (Default), and then go to Edit > Modify. Type the Adobe Acrobat path in the "Value data" for your product.,restart your computer
    Repair the HKCR\AcroExch.Document registry key: Navigate to HKEY_CLASSES_ROOT\AcroExch.Document., Right-click AcroExch.Document and select Delete; make sure that you have the correct key, and click Yes on any prompts, Right-click AcroExch.Document.7 and select Delete; make sure that you have the correct key, and click Yes on any prompts. Repair your Acrobat  installation
    None has solved the problem. However it still works ok with IE. But I want to stick with Chrome because I find IE is so slow!
    I am using Vista, with Adobe Acrobat standard 9.5.2 and Google Chrome version 23.0.1271.64 m which is marked on Chrome as 'up to date'
    Does anyone know why I might be getting this error on Chrome but not IE?

    I think I have discovered the answer to my own question!
    I have disabled Adobe Reader plug-in, and can now see PDFs in Chrome.
    (Steps: Chrome Menu, Settings option, Click Advanced Settings link, then Content Settings button, then select Disable Individual Plug-Ins, and a list of plug-ins is offered to enable or disable).
    I then get a different result depending on whether or not Chrome PDF viewer is enabled - with it enabled I see the PDF document in Chrome, or with it disabled then the option is offered to download it, but either way I can get it it via Chrome without having to run Internet explorer in another browser window.

  • Reader 9.2 - "can not be used to view PDF files in a web browser"

    Hello,
    I recently deployed Adobe 9.2 within our organization. I used the Adobe Customization Wizard 9 to transform the install set, and selected the "Display PDF in Browser" option as default.
    When opening a PDF linked from a web URL, we get the message: "The Adobe Acrobat/Reader that is running can not be used to view PDF files in a Web Browser. Adobe Acrobat/Reader version 8 or 9 is required. Please exit and try again." This occurs under IE8 and IE6, in both Windows XP SP2 and Windows 7.
    If I launch Adobe Reader and unselect "Display PDF in Browser" in preferences, PDFs open normally.

    I think I have discovered the answer to my own question!
    I have disabled Adobe Reader plug-in, and can now see PDFs in Chrome.
    (Steps: Chrome Menu, Settings option, Click Advanced Settings link, then Content Settings button, then select Disable Individual Plug-Ins, and a list of plug-ins is offered to enable or disable).
    I then get a different result depending on whether or not Chrome PDF viewer is enabled - with it enabled I see the PDF document in Chrome, or with it disabled then the option is offered to download it, but either way I can get it it via Chrome without having to run Internet explorer in another browser window.

  • Adobe 9.1.3 and FireFox 3.5.1+ "...can not be used to view PDF files in a Web Browser"

    This is the issue but I'm not sure there is a resolution:
    Firefox:  Version 3.5.1
    Adobe: Version 9.1.3
    When navigating the web, click a URL that opens a PDF inside the browser and you get an error * "The Adobe Acrobat/Reader that is
    running can not be used to view PDF files in a Web Browser".  Please exit Adobe Acrobat/Reader and exit your Web Browser and try again".  I did read a post that doing a "repair" from the Adobe Reader application should fix this, they also reference a few registry keys to check becuase the post states it's lost the application path to Adobe version X.  I don't necessarily buy that "fix" and here are my details below.
    In FireFox if you navigate to Tools > Options > Applications > Adobe Acrobat Document
    You're given choices:
    Always ask:  DOES NOT WORK, produces afore mentioned error *
    Save File:  Works, saves the file to a directory on your PC
    Use Adobe Reader 9.1 (defau...:  Works, opens your PDF's outside of your web browser
    Use Adobe Acrobat (in Firefox):  DOES NOT WORK, produces afore mentioned error *
    Use other...:
    IE seems to just work as expected.
    If you open Adobe Reader > Edit > Preferences > Internet > Check "Display PDF in browser" - DOES NOT WORK, produces afore mentioned error *
    This would seem to be an Adobe error rather than a FireFox web browser problems since FireFox does seem to know the correct path although I suppose you can't rule out that this is a FireFox problem since 2 out of the 4 PDF open options DON'T WORK.
    Any thoughts on this issue would be greatly appreciated.
    Other information:
    Adobe 8.1.5 works perfectly with FF 3.5.1+ when opening PDF's in the web browser, we also had no problems with previous versions either.
    MSI push via Active Directory from Adobe 8.1.5 upgrade to Licensed Distribution I signed up for, Adobe 9.1.3 which was upgraded from 9.1.0, to 9.1.2, to 9.1.3 via an MSP patch.
    Operating system:  Windows XP SP 2, plenty of RAM, plenty of Drive
    IE version this works with the new version of Adobe 9.1.3 is version 7 (7.0.5730.13)
    Our FireFox MSI's come from Front Motions website and as far as I know we've never had problems with their MSI's, also tried the new release of FF 3.5.2 from their website.
    I think that about covers it.  Anyone else experiencing the same problems or have a patch?

    After troublshooting this for the entire day today the issue seems to be a MIME problem.
    If everything is woking perfectly, in Tools > Options > Applications...
    You should see 4 or more things related to Adobe like "Adobe Acrobat Forms Document", etc.  If you don't see at least 4 MIME entries either your Adobe installation is hosed or your FF installation is hosed.  I haven't figured out which is causing the issue.
    What I did was remaster my patches from my original Adobe 9.1.0 MSI with the two updates via the command line in the directories with the source files.  On the 9.1.0 original file I first remastered my MST transform with the Adobe MST utility.  I then applied my patches.
    msiexec /a AcroRead.msi /p AdbeRdrUpd912_all_incr.msp
    msiexec /a AcroRead.msi /p AdbeRdrUpd913_all_incr.msp
    I then uploaded that to my network share, unlinked my group policy, made a new group policy, added a batch file to delete adobe.com from program file and the desktop on system startup even though my MST was supposed to take care of that - it's not a perfect world is it?  :-)
    I then reapplied my GPO's for both FireFox 3.5.2 and Adobe 9.1.3, I checked to make sure the MIME extensions were there and they were.  You might have to go into your Adobe Preferences and select that open in browser setting depending on what happens or adjust your MIME settings in FireFox's options but it should work.
    That's what worked for me.  It's possible a few other things I did along the way tweaked it out, in my group policy on the first run I did select to upgrade previous group policies, for the remaster and repush I didn't select any previous GPO's to upgrade.
    It's hard to tell what one thing tweaked it out or what combination of things tweaked out the install.  I did also reinstall Adobe 8.1.5 and FF 3.0.10 before doing all this since our machines currently have that setup, I'm not sure if that affected it either, it's just hard to tell but I don't think it did simply because I had done that several times in troubleshooting this issue.
    If anyone else has more specifics that would be great!

Maybe you are looking for

  • Error message from a BAD PDF

    I am using Adobe Reader to render PDF documents as a part of a process and then convert it into TIFF. Some of the documents that come in are corrupt PDF documents and cannot render itself in the reader and hence cannot be converted. This is the error

  • Extractor name

    Hi there, Please some one give the name of extractor of following datasources. 2lis_02_itm, 2lis_02_hdr, 2lis_02_scl. Thanks

  • Renaming images without breaking file path

    I've got about 20 images in a RoboHelp 10 project that I need to rename. I can find them in the Project Manager pod and I see the option to rename them there, but if I do so, it breaks the link to the image in any topics in which they already appear.

  • LR CC, LR6: How To Set Filter Brushes Reliably to ADD ?

    Hi, in the new Lightroom versions, the new filter brush can ADD to or SUBTRACT from the area affected by graduated filter or radial filter. But i am not sure how to *reliably* set a brush to ADD or to SUBTRACT. I had assumed: - brush "Erase" does sub

  • Wifi still unable to connect. y location.

    keep getting the unable to connect to wifi message. I've tried resetting network unplugging the router etc.