-2

We need a script that will print a multipage PDF within a printing sequence from filemaker pro.

We use a filemaker PRO database that is rough around the edges but general works for our processes. We are trying to automate some workflows but continue to run into gaping glitches that have stumped us and held back our productivity with this application.

It appears that filemaker is unable to print multipage PDF's that are stored in it's container fields. Further complicating the mater filemaker pro for mac has a frequent problem crashing on larger files when using Adobe as the default web plugin to view PDF files, thereby making it necessary to default to using "preview" for mac as the default reader.

The problem with using preview though is that when certain documents were created originally using acrobat such as forms or PDFs with embedded pics, Preview will fail to recognize the data on the forms or the embedded pics thereby rendering a blank page, making its necessary to use Acrobat only to print the documents...

Our solution requires us to batch print large amounts of documents from found sets within our database.

Each record has a series of layouts that must be printed in a specific order and a collection of attachments (container fields) that must also be printed.

Currently we are able to batch print all the filemaker layout documents in the proper sequential order for a batch, (Average 20 records per batch, each record having 10 pages = 200 Pages (without corresponding attachments)

Because of filemaker's limitations however we must then manually go into each record, open each relevant attachment, right click to "open as" Adobe PDF, execute a print command, manually close the adobe window, manually close the filemaker container window and repeat for each relevant attachment per record.... As you can imagine this becomes very time consuming.

To make matters more complicated we then have to hand collate the documents to insert the separately printed container PDF's and associate them with the other printed docs...

We are trying to create scripting that will enable us to print the entire file in the proper sequential order so that it is pre collated. (i.e. Print 5 layouts, print container 1, print 3 layouts, print container 2, print 2 layouts, print containers 3 and 4) move to next record repeat...

I believe one way to solve this is to export the PDF from the container field to a watch folder that would have an applescript attached to it and automatically print.. However I have been unsuccessful in figuring out how to script a hot folder to print using the adobe engine.

I have made hot folders that print using the default preview engine however this results in a blank document. These documents only seem to print correctly when printed from the print dialog of adobe reader or acrobat alone.

I am open to any suggestions at this point...

Update: I was able to create an apple script by culling together bits from other posts. This script batchprints PDFS from a folder using the acrobat pro 11 engine and moves them to a separate folder when complete... I'd like assistance in integrating this script into filemaker so that when I export a PDF from a container field it prints in sequence with the other documents from the filemaker record... Here is the script:

property myFolder : "HD:Users:User:desktop:Print:"

set myfiles to list folder myFolder without invisibles

repeat with myfile in myfiles

    set mycurrentfile to ((myFolder as string) & (myfile as string)) as string
    batchprint(mycurrentfile)

end repeat

on batchprint(mycurrentfile)

    tell application "Adobe Acrobat Pro"
        activate -- bring up acrobat
        open alias mycurrentfile -- acrobat opens that new file    
        tell application "System Events"
            tell process "Acrobat"
                click menu item "Print..." of menu 1 of menu bar item "File" of menu bar 1
                click button "Print" of window "Print"
                tell application "System Events"
                    tell process "Acrobat"
                        click menu item "Close" of menu 1 of menu bar item "File" of menu bar 1
                    end tell
                end tell
            end tell
        end tell
    end tell

    tell application "Finder" -- to move the printed file out 
        set x to (("HD:Users:User:desktop:Printed PDFs") as text)
        if alias x exists then
            beep
        else
            make new folder at the desktop with properties {name:"Printed PDFs"}
        end if
        move alias mycurrentfile to folder "Printed PDFs"
end tell


end batchprint
Chuck
  • 4,662
  • 2
  • 33
  • 55
drbronze
  • 33
  • 1
  • 8
  • 1
    Is this question about programming? Have you tried anything? Show us your code? Also make your question shorter, currently it's **FAR** too long. Nobody will bother to read the whole thing. – Xaver Kapeller Jun 23 '14 at 15:42
  • Thank you for your input. The question is about scripting filemaker pro to print multipage adobe acrobat documents using applescript. I will edit the question to make the point more clear. – drbronze Jun 23 '14 at 22:27

1 Answers1

0

I did something like this recently, although it wasn't as complicated as your requirements, using AppleScript. I didn't use a watch folder however. The steps were basically the following:

  • Calculate the location to export by appending the filename to Get( TemporaryPath ).
  • Export the container field contents to FileMaker to that path.
  • Save the path to a global field in FileMaker
  • Use an embedded AppleScript to access the global field path
  • Use AppleScript to open the file in Preview and print it

Try forgetting about the hot folder idea for a bit and see if you can create an AppleScript that will simply print a PDF that is in a known location, then work from that to printing a PDF whose path is stored in a FileMaker global field. Once you get that working the above algorithm should work.

Chuck
  • 4,662
  • 2
  • 33
  • 55
  • Thank you for the input. I have tried a similar solution, exporting the PDF's to the desktop, however have been unsuccessful in creating an apple script to print them properly. Unfortunately there appears to be a bug in preview and or acrobat that will not allow preview to read PDFs created in acrobat with imbedded/layered graphics. When you open or print these documents in preview they print blank. Therefore it necessitates we print them in acrobat only. That is one of the areas where I am hitting a brick wall. I cannot get a functioning apple script to print the PDFs with using acrobat. – drbronze Jun 23 '14 at 22:34
  • I'm unfamiliar with Acrobat's dictionary, or if it even has one, but my next suggestion would be to experiment with PDFPenPro (http://smilesoftware.com/PDFpen/index.html), first for the printing aspect and if that doesn't work, as a possible conversion tool to get the file into a format that Preview can work with. See http://smilesoftware.com/help/PDFpen/applescript.html for (slightly) more information about that app's scriptability. – Chuck Jun 23 '14 at 22:42
  • Sounded Promising. Sadly I dowloaded a demo of PDF pen Pro and it too will not open our PDFs properly. They appear blank or are missing information. Still in a pickle but I appreciate your assistance. – drbronze Jun 23 '14 at 22:54
  • I've never seen a PDF that PDFpen couldn't open. Learn something new every day. :) Perhaps the PDF generation is a point that could be resolved? If you can figure out a way to convert the PDFs to a more standard format (and I'm no PDF expert at all, so this is throwing something at the wall and seeing if it sticks) then that would be the solution. I have found Smile's tech support to be very good if you're inclined to ask them why PDFpen can't open the files properly. – Chuck Jun 23 '14 at 23:01
  • I will ask them and see if they have a clearer answer. I do believe I kind of know why... I have been dealing with this issue for quite awhile. It appears to be something with the adobe rendering engine when it saves layered files as PDF... For instance we have a PDF of our letterhead. When we cut and paste a graphic onto it and save it as a PDF. These are the documents that will only open in Acrobat. However if we paste text to the same PDF letterhead and save it, it will be accessible in any PDF program... – drbronze Jun 24 '14 at 00:02
  • Good News: After culling together numerous script examples from stack flow I wrote a script that opens and prints documents in adobe acrobat pro 11. – drbronze Jun 24 '14 at 11:04
  • Good news I culled together numerous posts from stackoverflow to figure out an applescript that batch prints docs in a folder and moves them to a second folder when done... This appears to be working well. I amended my original post above to include the script...@Chuck I liked your idea to Save the path to a global field in FileMaker and Use an embedded AppleScript to access the global field path, but frankly I'm at a bit of a loss how to do so with the script I created... Can you offer clear directions? – drbronze Jun 24 '14 at 11:10
  • Check out an article I wrote at http://chivalrysoftware.com/index.php/blog/124-filemaker-applescript-php-oh-my which touches on that topic. Most of it will be necessary for your needs, but read the sections entitled __Some Security__ (just the part about the `appl.TempDirFilepath` custom function), __AppleScript Glue__ (demonstrates how to get information from FileMaker to AppleScript using global fields) and __Return to FileMaker__ (demonstrates storing the information in global fields for AppleScript). Perhaps later today I can edit my answer to include only the relevant portions for you. – Chuck Jun 24 '14 at 11:42