2 Replies Latest reply on Jan 27, 2016 3:03 PM by jrenfrew

    How to Email a PDF from Server

    vfoecke

      I have a script that works properly to email a client a PDF of a receipt for a just-completed sale.

       

      Now, as I am working toward allowing clients onto the system via WebDirect, I'd like to tweak the receipt emailing script to run on the Server.

      Unfortunately, the Save Records as PDF command won't run on the Server.

       

      From an earlier thread, I think I can can why this is true:

      As far as I knew it is because the server is lacking the layout rendering engine. Since it can't render any layout it can neither print a layout nor export a layout as a PDF.

       

       

      Is there an elegant solution I'm not seeing?

       

      I can imagine an ugly solution like:

      - the WebDirect client completes the transaction

      - I mark the receipt as needing to be emailed to the client's email address

      - I create an OnTimer script on a non-server machine to periodically troll for receipts waiting to be emailed.

      - When that script finds one, it generates the PDF and emails it as an attachment.

       

      I just can't imagine that that is the best solution in the FileMaker toolbag.

        • 1. Re: How to Email a PDF from Server
          mikebeargie

          The method you described is called the "robot" method, where an unattended computer running a continuous timer loop performs a filemaker-pro-only action. You are right in your reasoning for filemaker servers rendering limitation. I like JohnSindelar term for it: "headless".

           

          An advancement to that technique is to use something like the RemoteScripter plugin to perform the robot function on-demand:

          360Works RemoteScripter :: FileMaker Remote Script Execution Plugin

           

          The "on-demand" robot technique is also covered with sample code here:

          http://www.modularfilemaker.org/module/pdf-in-webdirect/

          and an explanation on how to do it without plugins in further detail here:

          Printing PDFs in FileMaker WebDirect - SeedCode

           

          The only other legitimate way I know for creating PDFs is to use a PHP script with a PDF generation package like TCPDF to generate a PDF result via URL, using a static template filled with CWP filemaker data. A lot of work, but fairly reliable. DBServices covered this method on their blog:

          How to Create a PDF from FileMaker Server | DB Services

           

          All in all, I agree, it sucks that you can't "natively" create a PDF in WebDirect or via Server Scheduled Scripts. But there are ways to do it without waiting for a robot cycle.

          • 2. Re: How to Email a PDF from Server
            jrenfrew

            Mike

            There are other legitimate ways to create PDF files which can be done on the server and triggered from Go or Webdirect aswell as Pro or Advanced. And my particular favourite also works from runtimes too.

             

            Using ScriptMaster with the iText library is my favoured flavour (but there are also a couple of other ways too, just not keen on advertising them..)

            There is arguably as much to learn as there is with learning PHP (OK maybe a bit more) but significantly more you can do this way that is NOT possible with PHP-type scripting which pretty much focusses on initial creation, not subsequent manipulation.

             

            My experience is not that this is fairly reliable, but that it is completely reliable. Many happy customers and complex solutions attest to that.