FM Print

I have 2 questions on Printing in Filemaker. First how would I print out my found record to a printer.
Second question how would I use print to save as a file. Print destination would be File and save file to a path instead of sending it to the printer to print I would like to do this in applescript.

tell application “FileMaker Pro”
go to layout “Layout 1”
set cell “Country” of request 1 to “USA”
find
print destination File tomypath
end tell

FileMaker’s dictionary doesn’t contain syntax for printing to a file. You can however set up a FileMaker script to do that - then have AS move and rename this file.

  1. Print whatever it is to your file - remember what you name it and where it is saved.

  2. Set up a FM script that does the following:
    Page Setup “restore, no dialog”
    Print “no dialog”

Have your applescript invoke this script, or trigger it within FMPro, (your call here) - then work with the resulting exported file.

Is there any way to make a postscipt file of a record using applescript.
Lets say you find a record Now instead of printing it out I just want to make a postscript file of that record.

I’m trying something similar and finding that Printing is the hardest part so far…
I want to have FM invoke the applescript because it’s containing other applications also. I can’t get it to print the file.


tell application "FileMaker Pro"
	set the newName to cell "field1" of current record
	set myMailContent to cell "field2" of current record --will become body of email
	copy newName as string
	go to layout "Print_Studio"
	print with dialog
	paste newName --want it to use newName as filename for PDF
end tell

That’s where I’ve stopped. I will use this in conjunction with another script that will attach the resulting pdf file and email it to preset recipients. I’ve got the mail part working just need help smoothing out the filemaker end.

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,

I see this is an old thread but here is what I have done.

If you are using OS9, you can install PrintToPDF which behaves exactly like a desktop printer. So, all you have to do is write a script to switch from your regular printer to PrintToPDF, script the Filemaker print routine, and then switch back to your regular printer.

PrintToPDF is a shareware program available from:
http://www.jwwalker.com


tell application "desktop printer manager"
  set default printer to "PrintToPDF"
end tell
--I'm not positive about the syntax for running Filemaker scripts
--It's been a while since I've done it.
--You may have to change "tell database..." to "tell document..."
tell application "Filemaker pro"
  tell database "MyFile.fp5"
    do script filemaker script "MyFilemakerPrintScript"
  end tell
end tell
tell application "desktop printer manager"
  set default printer to "PrintToPDF"
end tell
--You may also want to add a loop to count items in the current desktop printer
--folder before changing the default printer. This will allow spooled jobs to finish
--printing before switching printer. If you have Apples scripting additions, and the
--scriptable desktop printer manager, you should be able to find the example
--called SetDefaultPrinter