spot_imgspot_img
3.1 C
London
Thursday, November 30, 2023
spot_img
HomeClaris FileMaker ProAppending PDFs on FileMaker Server

Appending PDFs on FileMaker Server

PDF files are essential in the business world, and being able to
create and manipulate them is a must. Appending one PDF to another is a handy
tool for operations like report generation. Let’s take a look at options for
appending PDFs on FileMaker Server.

There are two basic rules when appending PDFs in FileMaker:

  1. Native FileMaker can only append a PDF if it is currently
    exporting to an existing PDF.
  2. The BaseElements plugin allows you to append existing PDFs
    together. 

This basic distinction is important to keep in mind. If you
are exporting a report PDF that is based on multiple layouts (or a single layout), use native
functionality to go to each layout and export/append all the data as you go. However, if you
wish to append an existing PDF to another existing PDF, you’ll have to use the BaseElements plugin. We’ll look at both methods in this article. Regardless of the tool you use, both can be run by FileMaker
Server. Let’s get started!

Note: In order for server functionality to be demonstrated, you will have to host the demo file (found at the end of this article) on your server. You can run the scripts locally and get the same result, but in the attached video and going forward, I will be demonstrating using a hosted file.

Append PDFs Using Native FileMaker Server

In the demo file, on the right hand side is a field for demonstrating native
FileMaker Server. This field will hold the appended PDF once it’s been generated. The
data for this PDF is based on layouts, which we will look at in a moment. Click
the Append FileMaker Data Using FileMaker Server button. Once the
server processes it, the Result PDF field will contain a PDF consisting of a
header page and a sample report.

Append pdfs using native filemaker server functionality

Let’s look at where this data came from. Using the layout drop down, go to the Report Header layout.
As we’ll see shortly, this is exported as a PDF and then appended to.

Sample report header filemaker server pdf export

Use the layout drop down to go to the Report Layout. This
layout is exported as a PDF and appended to the Report Header PDF when we run our script.

Sample report for appending pdfs in filemaker server

Now let’s see what’s going on under the hood. Open Script
Workspace and go to the SERVER – Append Report script.

Export and append pdfs via filemaker server script

The script exports two PDFs to the same location. When exporting the second PDF, the Append to existing PDF option is turned on; this tells FileMaker to append the PDF to the PDF at the file path. Once that happens we have our finished PDF; all that’s left is to import it into FileMaker. Because the Insert PDF script step is not supported on FM Server, we use the Insert from URL step and specify our file path as the source URL.

Note: The Save Records as PDF script step is only partially supported by FileMaker Server and was not available until version 16.

For more information regarding the how, when, and security options for appending PDFs, see Claris’s support page here. Of particular interest, it specifies that when running on FM Server, you can only append to a PDF generated earlier in the same script. This is important to remember when script planning.

Go back to the Main Screen layout. Now we’ve got
our appended PDF in a container field and can utilize it for our business operations.

Append PDFs using BaseElements

Suppose, however, we want to append two existing PDFs together. We can’t use native FileMaker functions to append; that only works if we are currently exporting data as a PDF. This is where the BaseElements plugin comes in. On the left hand side of the screen, you’ll see two container fields; one for holding
the base PDF and one for the appending PDF.

Click the Append Existing PDF to Base PDF Using BaseElements button. The base PDF now has the existing PDF appended to the bottom.
You can click this button multiple times and it will keep appending the
existing PDF; the end result is one very long PDF.

Append pdfs using baseelements filemaker server

Open Script Workspace and go to the BaseElements – Append
PDFs script. You’ll notice it’s much simpler than the FM Server script we
looked at earlier. All the action takes place in line 11, where we set the base
PDF field to the result of the BE_PDFAppend function. We pass in our two container fields
(one for the base PDF and one for the existing PDF) and BaseElements takes
care of the rest. 

Append existing pdfs using baseelements script filemaker server

The BE_PDFAppend function can also take file paths as parameters and create a new PDF based on the appended PDFs, giving you even more flexibility. For more information on the function and its capabilities, click here for the BaseElements BE_PDFAppend information page. 

Conclusion

Appending PDFs together is an essential tool for data manipulation. When deciding what method to use for implementing appending PDFs in FileMaker, remember the two rules:

  1. Native FileMaker can only append a PDF it is currently exporting to an existing PDF.
  2. The BaseElements plugin allows you to append existing PDFs together. 

These two rules will help you determine what solution meets your business needs. If you have any questions about manipulating PDFs in FileMaker or would like to discuss how this could help your business, contact us today!

Did you know we are an authorized reseller for Claris FileMaker Licensing?
Contact us to discuss upgrading your Claris FileMaker software.

Download the Append PDFs on FileMaker Server File

Please complete the form below to download your FREE FileMaker file.

spot_img
spot_img
Filemaker Cloud Server
MC Services

explore more