This example demonstrates how to script the installation of Ghostscript, which is used to Import or Convert From PDF documents. Scripting the installation can be helpful when you have multiple computers needing the utility or if you are distributing a bound/runtime solution.
Download Example File
Testing the Example
To use this example, you first need to place the Ghostscript files in the container fields. Ghostscript is freely available to download, however licensing restrictions prevent us from distributing it with the plug-in. To obtain the correct files to place in the container fields, use the following steps.
- Install Ghostscript on your FileMaker Pro/Advanced computer
Installing Ghostscript is only necessary once, and is simply needed to get the files we require for the database to work. Complete the instructions in the "Download Ghostscript" and "Install Ghostscript" sections of the Working with PDF Files tab of the documentation, and then continue with the following steps.Note
If you want to create a Ghostscript Scripted Install for both Windows and Mac, you will need to install Ghostscript on both a Windows and Mac computer one time to obtain the correct files to add to this database.
- Open FileMaker Pro/Advanced and the "Ghostscript Scripted Install" database
WindowsWith the Ghostscript Scripted Install database open, right-click on the Win EXE field, and select "Insert File".Mac
In the “Insert File” dialog, browse to the folder where you installed Ghostscript in Step 1 and open the “bin” folder. By default, this will most likely be:
or C:\Program Files (x86)\gs\gsX.XX\bin<br> Note, the X.XX represents the version number, and may be different than what you see here.
Once you open the “bin” folder, find the “gswin32c.exe” file, select it, make sure the “Store only a reference to the file” box at the bottom of the dialog is unchecked, and then click Open.Note
Make sure to select the "gswin32c.exe" file and not "gswin32.exe". The "c" in the filename represents "command line", which is the file CNS Image requires.
Next, right-click on the Win DLL field, and select “Insert File”.
In the “Insert File” dialog, browse to same folder as the .exe file was found earlier, select the “gsdll32.dll” file, make sure the “Store only a reference to the file” box at the bottom of the dialog is unchecked, and then click Open.With the Ghostscript Scripted Install database open, right-click on the Mac field, and select "Insert File".
In the “Insert File” dialog, browse to the folder where you installed Ghostscript in Step 1. By default, this will most likely be:
Once you open the “Applications” folder, find the “gs” file, select it, make sure the “Store only a reference to the file” box at the bottom of the dialog is unchecked, and then click Open.
- Ready for Install
- Install Ghostscript on your FileMaker Pro/Advanced computer
Access the Plug-in
When using plug-ins (not just ours), they do not add new script steps, but instead add new functions that are available in the calculation engine.
The “Specify Calculation” window as shown in the image above is found in many different places in FileMaker. The most common places to use the plug-in is within the "Set Field or “Set Variable” script/button steps.
In FileMaker’s “Specify Calculation” window, the plug-in is accessed using the “CNSImage_FunctionName” functions. To find a list of these in FileMaker, click “View” menu in the top right corner of a “Specify Calculation” window, select “External Functions”, and then scroll through the list until you find the plug-in name. There are many functions available that allow you to do a variety of different things. For a complete listing of the functions and help for each one, see the Functions tab of the CNS Image Knowledge Base.
How to recreate in your solution
After you have gone over the example databases, learned how they work and how the plug-in works, you can integrate the plug-in into your own solutions. There are many ways this can be done, but here are a few of the most common ways.Note, to properly integrate the plug-in into your own solution you need to be proficient at FileMaker scripting and calculations. While our documentation tries to provide some tips, teaching all the ins and outs of FileMaker scripting and calculations is beyond what we do. FileMaker offers many training options to help you further your FileMaker developing skills. If you are looking for a professional developer to integrate the plug-in into your solution, you can search for one on FileMaker's Consultants site.
Import example script
This is the easiest way to go, but can be the most frustrating at the same time. When importing a script, you will have to go back over the imported script with a fine tooth comb. Field references will be different between the example database and your own database, so you will have to touch every script step to make sure all field references are correct. This will mainly deal with the Set Field script step (but check all the script steps to make sure they are correct for your database). Select the Set Field step and check the “Specify target field” button to make sure that field is correct. Then check the “Calculated result” button and make sure any field (and table names) are correct. If you find /* */ at the beginning and end of the calculation, FileMaker has commented out the code because of incorrect field references. You will need to fix all field references, and then remove the /* */ from the beginning and the end.
Re-create example script
Print out or view the example script and re-create it in your own database. Since you will be creating the script as you go, you are less likely to overlook an incorrect field reference as you would with Importing an example script. This method helps you to better understand what your script is doing since you are actually creating the script yourself.
Create script from scratch
If you went over all the example databases, you should have a pretty good idea what a script would look like. Using the function browser to give you more information about the functions, you can create a script to send an email exactly as you need it. Click the “Functions” tab to open the function browser. Remember to build error checking into your scripts. This is very important and will save much frustration later when something stops working and you have no idea why and no errors to go by.
Be sure to check out the Coding Considerations section for some helpful tips on working with the plug-in functions and writing scripts.