In the Debugger, I’m executing the script below using ‘open’ and passing in a PDF.
thePDFDoc var always ends up as missing value.
The debugger shows me the line before returns the URL with
– file:/// appended
(NSURL) Macintosh%20HD/Users/sphil/SomeDoc.pdf – file:///
Is this malformed? If yes, how do I get a well-formed URL?
If no, how do I prevent thePDFDoc from being ‘missing value’?
use scripting additions use framework "Foundation" on open these_items local thePDFDoc local this_file1 local this_file2 local this_file3 local this_path local pdfURL set this_file1 to item 1 of these_items set this_file2 to (POSIX file this_file1) as text set this_file3 to text 2 thru -1 of this_file2 set this_path to current application's NSString's stringWithString:this_file3 set pdfURL to current application's NSURL's fileURLWithPath:this_file2 set thePDFDoc to current application's PDFDocument's alloc()'s initWithURL:pdfURL end open