We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34072
    • 31 Posts
    Hi everyone,

    Version of MODx: Revo 2.0.7 Traditional
    Server OS: CentOS 5.5
    PHP Version: 5.2.10
    MySQL Version: 5.0.77
    Browsers: *Firefox (Mac), Firefox (Windows), IE (Windows)

    I’m having a bit of a problem with Static Resources displaying a download dialogue box when the link is clicked rather than displaying the PDF in the browser.

    I’m 99% sure this isn’t a browser settings issue as when I create a link to a PDF in TinyMCE, that link will open the PDF file in the browser. Also, I’m pretty sure that the Static Resources links were displaying the PDF in the browser window when I was using Revo 2.0.6 or earlier.

    I’m using the following page settings for static resources (see attachment)

    Is there something I can do to tell the static resources to open in the browser window?

    Thanks, Kahli


      • 9207 ☆ A M B ☆
      • 2,475 Posts
      Check your content types (System --> Content Types)... it’s the PHP header() function that prints the correct MIME type, and that’s what triggers the browser to initiate a download.

      For a pdf, either create a content type, or ensure that your existing content type uses "application/pdf" for the mime type and uses ".pdf" for the file extension. You should clear your cache after changing this.
        • 34072
        • 31 Posts
        Hi Everett,

        Thank you. My content type for PDF looked okay, except that I had "Binary" ticked. I’ve unticked "Binary" and cleared my cache and now everything seems to be working okay.

        I did try this earlier but forgot to clear the site’s cache, and I got a bunch of errors. Thank you for reminding me that it’s important to clear the cache. And thanks for your help.

        Cheers, Kahli
          • 34072
          • 31 Posts
          Hi again,

          Unfortunately I was a bit premature with my previous post - I’m still having issues. The two PDF static resources I created prior to upgrading to 2.0.7 work fine, but all the static resources I’ve created since then either open only a blank page, or open the PDF document in the browser, but the document’s missing sections.

          I’ve tried clearing the site cache, clearing the browser cache, and using multiple browsers. In IE on Windows 7, the broken static resources display the error:
          An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem

          But I’m pretty sure the problem isn’t with the PDF. If I create a regular link to the PDF (in the text of a webpage, either non-rich-text or using TinyMCE), the PDF opens without any problems.

          Any tips? I’m thinking of rolling back to 2.0.6 or earlier at this stage because I’m pretty sure these problems have only popped up since upgrading to 2.0.7.

          Thanks, Kahli
            • 22303 MODX Staff
            • 10,725 Posts
            It should absolutely be binary. I cannot reproduce any problems or see any changes in 2.0.7 that would affect this. Hmmm huh
              • 34072
              • 31 Posts
              Hi OpenGeek,

              I changed the PDF Content Type back to binary and that has brought back the initial issue where a dialogue box pops up when the link is clicked.

              Cheers, Kahli
                • 9207 ☆ A M B ☆
                • 2,475 Posts
                Wait... shouldn’t this make your browser display a dialog box as to whether you want to download the content?

                Maybe you need to change the content disposition from "attachment" to "in-line".
                  • 34072
                  • 31 Posts
                  Hi Everett,

                  I’ve double-checked, and Content Disposition is set to Inline on all the Static Resources.

                  I’ve attached screen-shots of the dialogue boxes that open in Firefox (Mac), Firefox (Windows), and IE (Windows) just in case they contain any helpful info.

                  When I click Open on the IE dialogue box, the PDF does open in the browser. As 95% of the website’s users are using IE, this is "good enough" at this stage but I really would prefer to figure this out.

                  Cheers,
                    • 9207 ☆ A M B ☆
                    • 2,475 Posts
                    I’d try setting the disposition to ’attachment’ just to compare the behavior here. Also,I think you need to set the file extension to ".pdf" for your PDF content type. It should get appended to your alias to form the file name. Sometimes that extension can help tell the browser how to handle the file.
                      • 34072
                      • 31 Posts
                      Hi Everett,

                      I already had .pdf set as the file extension for the PDF Content Type.

                      You aren’t going to believe this - I changed the content disposition to "attachment" and the PDF loaded in the browser, with no dialogue boxes popping up, in all the browsers I tested.

                      My guess is somehow "Inline" and "Attachment" have been switched around so that setting the content disposition as "Inline" makes it open as an attachment and vice versa. Is there something I can do to change it so they behave as they should? I have over 100 PDFs set up this way on my site and I’d rather not have to go in to each one individually and change the content disposition.

                      Thank you so much,
                      Kahli