We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46787
    • 3 Posts
    Hey all,
    I have some code in a snippet. I am using Friendly URLs. When I make the content type "HTML" for a resource containing the snippet, the snippet runs and produces output to my screen. When I change the content type to "PDF", the snippet seems not to run. The way I see this is a PDF is displayed in my browser with an error message about formatting. When I download the PDF from the PDF displayer, it seems to contain the snippet call ("[[!my_snippet_name]]").

    What bone-headed thing have I done?

    P
      • 3749
      • 24,544 Posts
      When you set the content type to PDF, MODX delivers the content as a PDF file, which your browser tries to display as a PDF. It doesn't work because it's not really a PDF file.

      Can you give a little more detail on what you're trying to accomplish?
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 46787
        • 3 Posts
        Quote from: BobRay at Jun 04, 2014, 04:07 PM
        When you set the content type to PDF, MODX delivers the content as a PDF file, which your browser tries to display as a PDF. It doesn't work because it's not really a PDF file.

        Can you give a little more detail on what you're trying to accomplish?

        I can try ;-)

        Thanks for the response. I am using TCPDF to produce a PDF from some (ultimately) dynamically generated HTML.
        I looked at HTMLtoPDF in the MODX add ons, but it seemed a bit more complicated than I thought I needed, and was based on an older version of TCPDF.

        When I run the php file (outside of MODX) to generate the PDF from some HTML, all is golden.
        If I reference that external php file as the href in an anchor tag, all is golden.
        When I try to do it through a snippet call, and set the content type to HTML, I get the PDF binary (altered to HTML text).
        When I try to do it through a snippet call, and set the content type to PDF, no snippet call is made.
        Seems like there should be a way to get actual PDF output from a snippet call, but I haven't seen how to get MODX to parse my snippet for other than an HTML content type.

        Am I crazy?

        Thanks again.
          • 41611
          • 7 Posts
          Uncheck 'binary' in Content Types - worked for me in the same case - HTMLtoPDF in snippet smiley
            • 46787
            • 3 Posts
            Quote from: morelmm at Oct 22, 2014, 03:51 AM
            Uncheck 'binary' in Content Types - worked for me in the same case - HTMLtoPDF in snippet smiley

            Thanks, I will give that a try.