Jump to content
Server Maintenance This Week. ×

Printing Plug-In


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

Recommended Posts

Hello,

I've got FileMaker 6 unlimited running on a Mac with OSX. I'm trying to automate the printing and emailing of pdf documents. Right now I have FileMaker print to PDF, Troi rename the file, and SMTPit mail the file as an attachment.

My problem: at times, FileMaker doesn't print to PDF quickly enough, and Troi (which is next in the script) has no file to rename. The user gets no attachment. Even worse, the next user gets the attachment belonging to the previous user. I could split up the printing and and renaming, leaving some time between them, but I'm afraid the files might still end up going to the wrong people because this is a web application, and a number of people could be going through the process at the same time.

Question: Is there any Plug-In out there that would allow me to name a pdf file with the contents of a field as the file is being printed? Or, is there any way to script this in FileMaker?

Thanks!

Link to comment
Share on other sites

Interesting. I believe there are 2 ways this could be solved (theoretically). One would be use AppleScript and some kind of "idle" loop, to wait for the existence of the file.

It would be tricky to write though; I've never really understood the "idle" command. So maybe a similar thing could be done in FileMaker.

Troi has a command to check for the existence of a file. FileMaker has a Loop. So, perhaps you could go into a Loop, check for the existence of the file, then rename it after the loop exits.

The main drawback I see is that if, for some reason, the file never appears, the loop will become endless. So probably a (very large) counter should be inserted, as another exit condition.

Please post results, as this would be a useful solution.

Link to comment
Share on other sites

Writing a loop that waits is trivial. I do it all the time using the Troi file plugin to wait for a file that gets created by WinBatch.

Loop

check for existence of file (call Troi plugin to read file)

ExitLoop(If we read file)

Pause/Resume Script(wait 1 second)

End Loop

You can easily insert a counter into this structure to exit the loop after a number of passes.

Steve

Link to comment
Share on other sites

Thanks for the loop suggestion. That should definitely help. I'll try it out and post the results. I wish there was something like AfFiler for Mac. Then I could eliminate any possibility of someone getting the wrong file.

Link to comment
Share on other sites

First, check the actual error code that Troi returns when the file is not found on a rename. Don't depend on his documentation. Then check the error code he returns after the rename to make sure it succeeded. Immediately after you email the PDF file, delete it or move it into another folder. That way there will be no chance of it going to the wrong person.

Steve

Link to comment
Share on other sites

I would assume that if one of your printers is the PDF Writer then you should be able to create a print script just like you do with any other printer. However, doesn't the PDF writer ask for a filename? If it does, and it can't be passed in the script, on a Win platform you can get around it with WinBatch. On a Mac, Applescript (I am assuming since I'm not a MACer)

Steve

Link to comment
Share on other sites

I'm not worried about the file going to the wrong person after it is renamed - the name is unique to each user. This is what I wonder about:

My script for printing and renaming the file is two subscripts: subscript 1 prints (saves the file) as pdf. This can take a few seconds. Subscript 2 renames the file (I'll use the loop suggestion to make sure this part of the script is successful). However, this is a web application and it is possible that two people could be calling on my script at virtually the same time. Is it possible that the subscripts could overlap in such a way that the file printed for one person would be renamed for the other person. Or, would Filemaker complete the whole script for one user before performing the script for the second user. If that's the case, I've got nothing to worry about.

Link to comment
Share on other sites

FileMaker 6 lets you save a file as a pdf document in the Print Dialogue box. You can script this by choosing that as your print setting and than creating a Script that prints without dialogue (or with, if you want to fill in the name of the file each time). If you print without dialogue FileMaker uses whatever name you typed in when you created your print settings, or it uses your database name as default. I use Troi File Plug-in to change the file's name, after printing, to a value from a field. AppleScript can also be used to do this. I haven't heard that AppleScript can be used to name the file before you print, but I'm no expert on AppleScript.

Link to comment
Share on other sites

In regards to this I had created something similar that a client asked for. It uses Applescript to create the file and send to the email package. Also includes changing the name of the file to a field value in FileMaker Pro

You can get a download of this file from http://www.fusiondzine.com/downloads/downloads.htm

It is called [Automate PDF creation and email integration (Mac OSX only)]

Some things you will need to do before running ANY of the scripts

These steps are required BEFORE you run the scripts. The print settings need to be correctly set up. Tedious but worth it.

First do a manual print of your document (choose here whether you wish to print the current record or all records browsed from the filemaker pro option )

Step 1.

Select "Output Options" from the "Copies & Pages" pull down.

Step 2.

Click the "Save as file" check box and make sure the "Format" pull down reads

PDF.

Step 3.

Click the "Presets" pull down and select "Save As".

Step 4.

Rename, as you like. I named it PDF. Click the "OK" button

Step 5.

You just made printer setting for printing to a PDF

How to print a PDF in a FileMaker script

Step 1.

Open your FileMaker file you want to print from.

Step 2.

Go to the File pull down menu and select "print". This window will appear.

Step 3.

Click on the Presets pull down and select the new settings for

printing to PDF you just created.

Step 4.

Click the "Save button".

Name the file what you want. In this example it is called Temp_PDF.pdf

Select the directory where you want to save the file. Here it is the desktop

Step 5.

Now create your script in FileMaker to print with no dialog.

Note: Every time you run this script with these setting the

PDF will overwrite the previous file.

For This demo you do not need to do a manual print. Go to scriptmaker and open the Print PDF script. Close it and replace the print settings.

Link to comment
Share on other sites

This topic is 7624 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.