![]() If you want to make modifications to the script, you can find it by selecting Show Contents from the contextual Finder menu of the clipPDF bundle. Rr=os.spawnlp(os.P_WAIT,gsBin,gsBin," -sDEVICE=pdfwrite", " -sOutputFile="+outname, " -q", " -dbatch", " -dNOPAUSE", inname, " -c", " quit")Ĭontent=NSData.dataWithContentsOfFile_(outname)īclareTypes_owner_(, None)ītData_forType_(content, NSPDFPboardType) You may have to hard-code the path in gsBin: # ghostscript (gs) is used to rewrite the PDF file. Tmpdir = tempfile.mkdtemp(""," clipPDF"," /tmp") Result = board.dataForType_(NSPDFPboardType) ![]() Another potential cause of errors is an outdated version of ghostscript - use version 8.61 or above. This is done by adding the path to the variable gsBin. Alternatively, you can edit the python script to hard-wire the path to ghostscript. Make sure you set up the PATH as mentioned above. If there is an error converting the PDF, the most likely reason is that gs hasn't been found. If there is a problem (e.g., if there was no PDF on the clipboard), the script should tell you so with an Alert box. I emphasize this so you don't get suspicious if nothing seems to happen after activating the menu item. If the PDF fix is successful, the script remains completely silent so as not to interfere with the workflow. Log out and back in to make this environment setup take effect. Of course, while in the Terminal, you should also make sure that gs -help returns no error. For example, if you haven't already done so, go to the Terminal and issue the commandĭefaults write ~/.MacOSX/environment PATH $PATHĪs dicussed on another page. ![]() I do this with the help of the defaults system. You can't run the script from within "Script Editor" without modifying some internal path info.įinally, you need to make sure gs can be found by the script. If you prefer to keep the script somewhere else, that's no problem, as long as it's recognized by the Script menu. If this folder doesn't exist, create it first. Move the unzipped clipPDF script bundle into the folder ~/Library/Scripts/. If you don't see the Script menu icon in the menu bar of your main window, you have to enable it by launching /Applications/AppleScript/AppleScript Utility and selecting a checkbox to that effect. This is usually taken care of when you install a TeX distribution, but you can also install it separately from fink or MacPorts. Since the script calls ghostscript, you need to have the command gs in your PATH. Here are the steps to make this work painlessly: Finally, you may prefer the even easier-to-install Application bundle. If you don't know what ghostscript is, just skip to the stand-alone version. I'm also posting a second version of that Applescript which does not require any additonal software. In response to a suggestion by Ken Drake at , ![]() My initial solution is an Applescript that requires an additional piece of software ( ghostscript). I packaged it in different flavors, so you should look through the following notes to see which solution you like best. On this page you can download a fix for this cropping issue and for a problem that manifests itself similarly in Mathematica 7. The reason for the PDF cropping issue with Preview is explained by Martin Costabel in this mail thread. I'm leaving this page up for future reference because it shows a method to use Leopard's built-in Python to manipulate PDF data on the Cocoa Pasteboard. The pasted PDF content in Keynote looks as if you never cropped anything at all. If you want to copy snippets of a PDF document into Apple's Keynote '08 presentation software (or any other iWork '08 application, for that matter - i.e., Pages and Numbers), there is a new problem that "cropped" up with the upgrade to Leopard: a rectangle selected and copied within Peview doesn't get pasted into Keynote in its cropped form. Most recent version, fixes the issue for Mathematica 7 and Keynote '08.Ĭopying PDF selections from Preview to Mathematica or iWork '08 under Lepoard The crop you sow and the crop you reap The same as above, but as application instead of a script Works with Keynote '08, but doesn't fix Mathematica issue. My oldest solution, included mainly for historical reasons and to help diagnose problems.įixing the Preview clipping dimensions without ghostscript For historical reasons, the sections are written in chronological order from the top down.įixing the Preview clipping dimensions with ghostscript
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |