2 Replies Latest reply on Jun 28, 2013 8:21 PM by mikebeargie

    Save URL screen to PDF (applescript?)

    mikebeargie

      I have a need for saving a URL to a PDF, and grabbing it into a container field. I am dealing with a mac only environment so I was thinking applescript might be my best bet.

       

      Unfortunately, my applescript is pretty rusty and google didn't turn up much I could understand.

       

      I did however use this automator package:

      http://scott.j38.net/interactive/url2pdf/

      to create an automator that saves a PDF to a specific directory.

       

      I can get the above to work when I manually specify a URL in the "Get Specified URLs" automator block, then click run for the app to run.

       

      Can anyone assist me in finding the right way to pass this automator "app" a URL, and telling it to run in the background so it saves the PDF in the app-specified directory?

       

      Or have you done this a better/easier way?

        • 1. Re: Save URL screen to PDF (applescript?)
          sporobolus

          on 2013-06-28 17:57 Mike Beargie wrote

          Can anyone assist me in finding the right way to pass this automator "app" a URL, and telling it to run in the background so it saves the PDF in the app-specified directory?

           

          the page for the Automator Action you cite states that the work is done by a

          command line app; if you look into the package for the action you'll find a

          .scpt file, which is AppleScript code, and a url2pdf unix executable file;

          reading through the .scpt you can see how the arguments for url2pdf are

          constructed, so i would ignore Automator and just write a short, task-specific

          calculated AppleScript to construct the shell command and call url2pdf

           

          i moved url2pdf to /usr/local/bin and this worked as the calculation for a

          Perform AppleScript step:

           

          Let ([
               $url_to_pass = "http://filemaker.com";
               $posix_output_folder = "/tmp";
               cmdstring = "/usr/local/bin/url2pdf --url=\"" & $url_to_pass & "\" 
          --autosave-path=/tmp"  ];
             "do shell script " & Quote(cmdstring)
          )
          

           

          • 2. Re: Save URL screen to PDF (applescript?)
            mikebeargie

            Thank you very much Steve, we primarily do windows environments at work so I'm more familiar with the send event stuff than the apple command line / applescript stuff. Thanks for your well demonstrated example.

             

            PS - If you'll be at devcon, let me buy you a round!