step 1
getting FileMaker to print to ps file without dialog
Create a new FileMaker *Scriptmaker script
add: Page Setup (restore, No dialog)
add: Print (No dialog)
Exit script
Print your found records to file manually
remember where you saved it, and what the name is - you can change it at this time.
open your FM script again
double click Page Setup
uncheck restore setup options
check restore setup options
click okay
Save setup options in resulting dialog
Now, test your script via FileMaker to see if it prints a ps file in the location you specified. Delete the resulting PS file and test it again.
Now, if at this point your FM script is printing a postscript file you can now call it via the “do script” command from an applescript.
So, if in your FMPro script - you manually saved a PS file on your desktop and named it fee.ps you can rename it from within your applescript. You cannot do it via FileMaker directly, unfortunately. But, you can get data to use as the name from a FileMaker field.
step 2
Use the Finder to rename your PS file with data extracted from your field
tell application "FileMaker Pro"
set myDB to a reference to database "name of my db.fp5" --added to make this a little more specific.
set the newName to cell "field1" of current record of myDB--note, added myDB
set myMailContent to cell "field2" of current record of myDB--will become body of email
--copy newName as string --I commented this out, no need to copy as we already set newName to some data in the command above.
go to layout "Print_Studio"
activate--I had better luck activating FMPro at this point.
--print with dialog --instead of printing, we'll call the script we created
do script "print"--or whatever you named your print script
--no need for the next line either, read on.
--paste newName --want it to use newName as filename for PDF
end tell
--now, since you remembered where you saved your PS file, and what the name of it is, you can use newName to rename it. Since the script will get to the renaming part before the PS file is actually created, enter a repeat loop until it exists - otherwise, your script will break because there is no file to rename.
tell application "Finder"
repeat until exists (file ((path to desktop) & "fee.ps" as string))
--do nothing
end repeat
set the name of file ((path to desktop) & "fee.ps" as string) to newName
end tell
Now, I’m not entirely privy to just how to save that as a PDF instead of a PS. If you are working under OSX - which I’m assuming you’re not since you posted here - you could convert the PS file to a pdf using a do shell script “pstopdf”. Under OS9, FMPro 5, there are settings to print to pdf under the save as file options - but I am certain you would need Distiller installed for this to be enabled. I do not, and it is grayed out on my menu.
Maybe someone else out here knows how to do that portion.
Best,