Jump to content
Server Maintenance This Week. ×

Apple/shell script


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

Recommended Posts

  • Newbies

I have this script that works ok when Ii run it from Applesript editor.

It brings ne the pdf box I´m after.

I want to run this script inide Filemaker, but can´t get it to work..

What am I missing here.. ??

Thanks for any tips on how i can make script like this work.

------------

on run

set fs to choose file of type "com.adobe.pdf" with prompt "Select one or more PDF files to process:" with multiple selections allowed

my process_files_(fs)

end run

on open fs

my process_files_(fs)

end open

on process_files_(fs)

repeat with f in fs

tell application "System Events" to set finfo to the properties of f

if kind of finfo is "Folder" then

tell application "Finder" to set dirList to (items in f) as alias list

do shell script "echo Directory: " & name of finfo & " >> $HOME/Desktop/List.txt"

process_files_(dirList) -- recurse directories

else if tolower(«class extn» of finfo) is not equal to "pdf" then

tell me to activate

tell me to display dialog (name of finfo & " is not a PDF file") with icon caution giving up after 2

else

my process_PDF_(f)

end if

end repeat

end process_files_

on process_PDF_(f)

do shell script "echo " & space & trimbox_(quoted form of POSIX path of f) & return

end process_PDF_

on tolower(theText)

try

set newText to do shell script "echo" & space & theText & space & "| tr \"[:upper:]\" \"[:lower:]\""

end try

return newText

end tolower

on trimbox_(f)

set tb to do shell script "export VERSIONER_PYTHON_PREFER_32_BIT=yes;

/usr/bin/env python -c 'import os, sys, glob, Quartz

this_pdf = Quartz.CGPDFDocumentCreateWithProvider( Quartz.CGDataProviderCreateWithFilename('\"" & f & "\"') )

page = Quartz.CGPDFDocumentGetPage(this_pdf, 1)

r = Quartz.CGPDFPageGetBoxRect(page, Quartz.kCGPDFTrimBox)

print \"%.2f x %.2f\" % (round (r.size.width*0.352777778) , round(r.size.height*0.352777778))

Quartz.CGPDFContextClose(this_pdf)' "

set trimboks to tb

display dialog "TrimBox= " & trimboks & " mm"

end trimbox_

-----------------------

What do i have to do to get this to work in Filemaker ?

Link to comment
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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