Jump to content

Easy way to use FM to download any file (e.g., PDF) and save it externally


This topic is 2922 days old. Please don't post here. Open a new topic instead.

Recommended Posts

There are probably other ways to do this, but you can use two Troi plug-ins, URL and File, to achieve this functionality very easily.  Downside of course is that you have to buy the plug-ins.

 

The URL plugin is used to download the PDF file into a variable.  The File plugin is then used to save the variable as a file.  Although File thinks it's a text file, by simply adding ".pdf" it's saved as a PDF.  I read somewhere that variables can have up to 300 million characters or so, which means that this trick will work for any file up to around 300 megabytes in size.  And of course, it's not limited to PDFs.

Here's an example, which downloads a patent in PDF form from Google, and saves it to my hard drive.  Note that the other nice things about using Troi URL for this, as opposed to dropping into AppleScript and BASH/Curl, for instance, is that URL follows redirection of links.  The link in the example redirects to some storage server at Google -- if you used BASH/Curl, the redirection won't be followed.
 

Set Variable [ $thepatent; Value:TURL_Get("-NoDialog"; "http://www.google.com/patents/US8289390.pdf") ]

Set Variable [ $result; Value:TrFile_CreateFile(""; "Macintosh HD:Users:Mike:Sample.pdf") & TrFile_SetDefaultFileSpec(""; "Macintosh HD:Users:Mike:Sample.pdf") & TrFile_SetContents(""; $thepatent) ]
Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.