Jump to content

Saving PDFs automatically


HazMatt

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

Recommended Posts

Here's what I have:

1) A predictable file path

2) A predictable file name

3) PDF creation software, of course

Our engineers go through a tedious process to save PDFs. They must...

1) Click a "Save PDF" button to activate a script

2) Paste the calculated file name into the Save dialog box

3) Navigate to the correct folder on a network drive

4) Click "Save"

More steps may include...

5) Creating PDFs from a CAD program using virtually the same process as above

6) Combining these PDFs into a single PDF file for general use and archiving

I believe the first 4 steps can be simplified into 1 automatic step. Can this sort of thing be done in AppleScript? Can this be done in Windows? Is the Troi File plugin the best way to go?

Link to comment
Share on other sites

The following looks like it may offer you a solution.

I use a shareware program called pdf995 from www.pdf995.com Basically it just presents a virtual printer device that you can print to, just like a regular printer, but saves as a PDF.

Among its options it provides the ability to

1) save a file to the same directory/path every time

2) use the same file name every time

3) append the current PDF being generated to the previous one

If I want a different file name every time, I script the print sequence and copy the filename I want to the paste buffer before issuing the print step. This way when the PDF application presents the save as window I simply hit CTRL-V to paste in the file name.

This is on Windows. Hope it helps.

Echo

Link to comment
Share on other sites

  • 4 weeks later...

Hi Frank, I'm still searching for the perfect solution. I don't know your email address, and I guess I could PM you, but I intend to post back to this thread. I would suggest adding this thread to your favorites.

Echo, thanks for the suggestion. I already had implemented a paste-file-name feature which does help out. I ended up purchasing the Troi File plugin, but am off to a slow start. The options that you list for "Pdf995" are exactly what I'm trying to accomplish. I am developing this thing on a Mac, however, and a Windows only solution will be difficult for me.

Given the popularity of the PDF, I am very frustrated at the way PDFs are implemented. They are relegated to an option in the print dialog box, when they should almost be created in a "Save As...". The fact that FileMaker cannot remember (in a script) the "Destination - File" setting further complicates the issue.

The workaround is to setup external PDF creation software, which turns into a hodge-podge very quickly. And again, there is no built-in way to change the printer within a script. I very much wish to refrain from buying FM plugins or other software to fix an issue here, fix an issue there, but it appears as if that's the only way to do it. frown.gif

I will continue looking for a solution, and maybe that will include more 3rd party software... <sigh> Does FileMaker 7 have improved PDF creation capability? I will go see!

Link to comment
Share on other sites

Since you have Troi File, the steps would be:

1. Save the file in a preset location with a preset name.

2. Use the plugin to move and rename the file.

Troi's stuff is pretty straightforward once you get the basic idea of using plugins in general. Also Troi has its own mailing list you can join for more specific help.

Link to comment
Share on other sites

Hi Fitch,

I have messed around with getting that procedure to work, and the steps you provided are in fact the same as those in Troi's sample database example.

The key to my issue is probably the print driver called "PDFWriter". I just don't have it and don't know how to get it, and yet I can still generate a PDF from FileMaker by two methods:

1) Printing is setup for our LaserJet 4MV... I simply change Destination from "Printer" to "File" in the print dialog box and save the file (Acrobat Distiller opens and processes the .ps file)

2) Printing is not setup. I have installed a "Create Adobe PDF" print driver that allows for more straight-forward PDF creation options (such as open Acrobat when done and no need for switching destination). Acrobat Distiller does not open.

Maybe someone can tell me how I can install "PDFWriter"? What Acrobat package does that print driver come with? Mac OS 9 / X or Windows? This is the source of my frustration.

I think I will get plugged in to Troi's mailing list... thanks for the tip!

Link to comment
Share on other sites

The OS 9 solution that has worked for me is PrinttoPDF in combination with an AppleScript that changes the print driver, prints the document and then types in the name of the file (this requires Sandis scripting addition) and then changes the print driver back to the original. This is a limited approach because you can not control the location of the file saved.

Link to comment
Share on other sites

  • 3 weeks later...

Here is an AppleScript that I developed sometime ago, so no promises. Using Adobe's PDF print driver (PDFWriter??) installed in the extensions folder, your first need to choose the driver in the chooser (this too can be AppleScripted). After you print your document, the file will appear on the desktop with the same name as the document you printed from, but with a .pdf extension. You just run the following applescript after your FM script prints the document...

property LocalCacheName ??? "Reports"

property thePDFName : "YOUR_FileMaker_FILE_NAME.pdf"

set thePath to path to startup disk

set theFolderPath to (thePath & LocalCacheName) as string

try

set theFolder to alias theFolderPath

on error

tell application "Finder" to set theFinderRef to make new folder at folder thePath with properties {name:LocalCacheName}

set theFolder to alias theFolderPath

end try

repeat

try

set theAlias to alias (((path to desktop) & thePDFName) as string)

exit repeat

on error

delay 1

end try

end repeat

tell application "FileMaker Pro" to set theNewName to cell "g_pdf_name" of current record

tell application "Finder"

move file theAlias to folder theFolder

set name of the result to theNewName

end tell

Link to comment
Share on other sites

  • 4 months later...
  • 2 weeks later...
  • Newbies

In Windows 98 this is the way I got around it. Its kinda loopy but it works!

Software list:

adobe acrobat distiller

autoit (freeware scripting tool - like applescript)http://www.hiddensoft.com/AutoIt/

fmp 6

Set up distiller so its the default printer on your workstation under control panel/printers - distiller printer

In distiller properties configure the "print to the following port" by clicking "add port", selecting the "pdf port" option and choosing the location that you want the file to be saved to.

Send the filename to the clipboard via the the file maker scriptstep copy command from your filemaker field that stores the name *.pdf

go to the filemaker layout you want to print

Open up the print setup dialogue box in filemaker.

Use the "Send Message" scriptstep to start the Autoit script - makeing sure you have a pause script step in filemaker after it - about five secs

Develop the autoit script to select the print settings you want and paste the file name you have developed (via a field)into the "save as" dialoge box.

Hey Presto you've made your first pdf file from a filemaker file record

Link to comment
Share on other sites

  • 3 weeks later...
  • Newbies

I just posted this in another Forum.... But I am so pleased with it I thought I should post it here as well... It is only for OS X:

Thanks to this and several other Forums I was able to put together this Script. The Structure has been coppied from other Scripts. Please note that I am a very poor AppleScript programmer so if any logical errors have been entered I am sorry for that.

This Script creates both the PDF Services Folder and a complete Script so it can be run on a computer without a prior install. It copies its PDF files to a mounted server volume. If you want it to install locally just replace the code "disk theServerName" with "startup disk".

It needs to be installed as a Filemaker script with the following logic:

PerformAppleScript [....the following code...]

PageSetup[Restore,No dialog]

Print[No dialog]

You must Print at least once before setting the "No dialog" so that the print features are saved.

-- SET THE LOCAL VARIABLES MOST OF WHICH WILL LATER BE OVERWRITTEN

property theServerName : "Transfer"

property theLocalFolder : "PDF_OUTPUT_FOLDER"

property theAssignmentID : "AS_10009"

property theFileId : "test.pdf"

property theScriptName : "vdh_pdf_generate.scpt"

-- GET FILEMAKER FIELDS INTO LOCAL VARIABLES (NOTICE HOW 'TELL APPLICATION FILEMAKER PRO' IS NOT INCLUDED

-- THIS SOLVES THE 1753 ERROR THAT SO OFTEN OCCURS, DONT ASK ME WHY POSSIBLY BECAUSE WE ARE IN FILEMAKER

set theServerName to cell "server_name" of current record

set theLocalFolder to cell "local_folder" of current record

set theFileId to cell "file_id" of current record

set theAssignmentID to cell "assignment_id" of current record

-- SET UP SCRIPT FOR WRITING TO PDF SERVICES FOLDER

script ScriptFile

on open these_items

set this_file to item 1 of these_items

tell application "Finder"

set the file_name to the name of this_file

set the parent_folder to (the container of this_file) as alias

try

set thenewpath to make new folder at disk theServerName with properties {name:theLocalFolder}

on error

set thenewpath to folder theLocalFolder of disk theServerName

end try

try

set thenewpath to make new folder at thenewpath with properties {name:theAssignmentID}

on error

set thenewpath to folder theAssignmentID of thenewpath

end try

set the name of this_file to theFileId

duplicate file this_file to thenewpath with replacing

end tell

end open

end script

-- CREATE PDF Services FOLDER ON MACHINES THAT DONT HAVE IT ALREADY INSTALLED

tell application "Finder"

try

make new folder at (path to library folder) with properties {name:"PDF Services"}

end try

end tell

set TheFile to (path to library folder) & "PDF Services:"& theScriptName as string

-- WRITES SCRIPT TO PDF SERVICES FOLDER

store script ScriptFile in file TheFile replacing yes

Link to comment
Share on other sites

  • 1 month later...

Well, I am finally back on this project. I purchased 3 licenses of the Troi File plugin (2 PC / 1 Mac) but will instead be using a site license of the ChangePrinter plugin by Productive Computing. We originally purchased the ChangePrinter plugin to be able to switch printers directly within scripts, which works well (some small glitches, but they are manageable). The ChangePrinter plugin has file manipulation abilities as well, so I favor the easier to use ChangePrinter authentication method (just install site-license plugin on each client) vs. Troi File's (complicated copy/paste/save method of a text file?)

Anyway, I am dealing with the Mac OS X part of my script (I realize now that the best way to script for a cross-platform environment is to split it up between Mac OS 9, Mac OS X and Windows). Like a good printing scripter I have isolated my Page Setup / Print steps into its own nice little sub-script (called out, of course, by a script that runs different subscripts for different platforms)B)

#Restore saved print settings

Page Setup [Restore, No dialog]

#Print

Print [No dialog]

I can run the script successfully in Mac OS X (10.3.5) on my G3 400 MHz with 640 MB of RAM. A PDF file named "document.pdf" appears on my desktop (the name of the file is saved in the script). However, I tried running the script in Mac OS X (10.3.5) on an iMac G3 350 MHz with 320 MB of RAM and a FileMaker error message pops up saying "Sorry, there is not enough memory to complete this operation." The script fails and I have the option to continue or cancel the script.

My main concern is with Mac OS X. I was under the impression that if any given application needed more memory, Mac OS X would provide it automatically. Adjusting an application's memory allotment was a thing of the past (Mac OS 9). I opened the Activity Monitor on the iMac while I ran the script, and it appears as if the amount of free memory (approx. 88 MB) does not change. Why am I getting this error?

Link to comment
Share on other sites

If you are running this with saved settings and the printer or ppd is possibly different then you might get this message, or the "Print Center" application may be mudged. There are "Print Center Repair" apps available on www.versiontracker.com. Occassionally a reboot may be neccessary if things have gone waaaaay south in the OS. My machine gets rebooted regularly and I have occassional issues - (muhahahahaha), my wife's runs for WEEKS with all apps etc. running with no issues. Go figure.

Link to comment
Share on other sites

  • 2 months later...

I should detail the solution that I have implemented. It's not absolutely perfect, but it's very close for what we want. We are still in FileMaker 6 in a Windows & Mac environment.

We were able to do the whole thing with two pieces of software: the Acrobat Distiller program on Windows and Mac OS 9 or the built-in PDF print routine in Mac OS X, and the ChangePrinter plugin by Productive Computing.

The plugin's main feature is the ability to change a printer within a script. A by-product of the plugin is tools that greatly aid in the PDF creation process. The path to the current workstation's desktop is one example.

Here's the process that I implemented:

A user clicks a button and triggers my script. The script then determines if the current printer according to FileMaker is Acrobat Distiller, and attempts to change it via the ChangePrinter plugin if it is not. If it can't switch the printer to Distiller, the script fails and informs the user that they probabl don't have Distiller installed.

Then, based on Status(CurrentPlatform) it prints (via an external script housing the Print / Page Setup PDF settings) the PDF to the desktop. This is necessary as each platform handles it differently (for instance, the default name given to the PDF file (Mac OS 9 prompts the user for the file name, OS X allows me to save the name in the script, and Windows saves the PDF as .pdf).

I then rename the file with the ChangePrinter plugin to a calculated text field based on the part number (I am working with all engineering documents).

At this point, I have the PDF on the desktop with the correct name. Next, I want to move it to a network drive. Again, I have to treat each platform slightly different. I need different calculated fields holding AppleScripts to mount the correct volume (including using volume aliases on the local computer) on the desktop. With Windows, it's easier to script because I just need to specify an Open URL script step no a calculated field housing the correct file path. I verify that the volume is mounted (most important on the Mac), then I actually move / copy the file using the ChangePrinter plugin. I delete the original file off the local computer, and I'm done.

A lot of steps, but it works pretty good. It works the best on Mac OS X because it doesn't prompt me for anything (unless the network volume isn't mounted - both Mac OS 9 and Mac OS X require me to login in that case).

So if anybody is developing their own solution with the ChangePrinter plugin, I am willing to help out. There are a few "gotchas" that require workarounds, but it works well.

Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...

WARNING

Be VERY sure Afeina's products are exactly what you need before you purchase a license. We made the mistake of purchasing after integrating the AfFiler and ProPrint plugins and testing them for a couple hours. After purchasing, we ran into MAJOR stability issues with both plugins and gave up.

NO REFUNDS!!

We're now out over $400 and have nothing but a couple useless, unstable, thrown-together glorified batch files. Afeina has a LONG way to go before their products are worth this much money.

If you're looking for PDF generation, emailing and printer switching capabilites, I heartily recommend the schubec PS2PDF plugin (yes, it's an actual FMX plugin, unlike Afeina's crap) available at www.schubec.com.

Link to comment
Share on other sites

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