« Track Line with Data … | Home | Xojo Enterprise is no… »

How to Convert a PDF document to a PDF/A

A lot of companies need PDF/A for long term archiving. PDF/A should make a barrier-free accessible documents possible after 100 years. Thats because of the tree structure of the elements, which makes it possible to open the document in the future with a screen reader application and it looks the same like 100 years ago when it was created. All fonts and color profiles are embedded to the PDF Document, so no external dependencies cause trouble. 

I want to show how you can do it with our MBS Plugin in FileMaker and DynaPDF.

In our example layout we have two container. One with the name Input for the PDF to process and one with the name Output for the result. You can insert a PDF file by putting your document into the Input container via Drag & Drop. We add a button which calls the following script:

# Convert to PDF/A script

# Initialize DynaPDF if needed

If [ MBS("DynaPDF.IsInitialized")  ≠  1 ] 

Perform Script [ Specified: From list ; “InitDynaPDF” ; Parameter: ]

End If

If [ MBS("DynaPDF.IsInitialized")  ≠  1 ] 

Exit Script [ Text Result: "Failed to initialize DynaPDF." ] 

End If

# Clear current PDF document

Set Variable [ $pdf ; Value: MBS("DynaPDF.New") ] 

# set import flags

Set Variable [ $r ; Value: MBS("DynaPDF.SetImportFlags"; $pdf; "ImportAll ImportAsPage") ] 

# Load PDF from container

Set Variable [ $r ; Value: MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Convert::Input) ] 

Set Variable [ $r ; Value: MBS("DynaPDF.ImportPDFFile"; $pdf; 1) ] 

Set Variable [ $r ; Value: MBS("DynaPDF.SetLanguage"; $pdf; "en-US") ] 

Set Variable [ $r ; Value: MBS("DynaPDF.CreateStructureTree"; $pdf) ] 

# Check if this PDF conforms to PDF/A-1b 2005

Set Variable [ $c ; Value: MBS("DynaPDF.CheckConformance"; $pdf; "PDFA 1b 2005") ] 

If [ $c = 1 ] 

#  A RGB ICC profile must be added to the document

Set Variable [ $r ; Value: MBS("DynaPDF.AddOutputIntentEx"; $pdf; Convert::RGB ICC Profile) ] 

Else If [ $c = 2 ] 

#  A CMYK ICC profile must be added to the document

Set Variable [ $r ; Value: MBS("DynaPDF.AddOutputIntentEx"; $pdf; Convert::CMYK ICC Profile) ] 

Else If [ $c = 3 ] 

#  A Gray, RGB, or CMYK ICC profile must be added to the document 

Set Variable [ $r ; Value: MBS("DynaPDF.AddOutputIntentEx"; $pdf; Convert::RGB ICC Profile) ] 

End If

# now set PDF Version.

Set Variable [ $r ; Value: MBS("DynaPDF.SetPDFVersion"; $pdf; "PDF/A-1b 2005") ] 

# Save PDF and reuse filename

Set Variable [ $PDFData ; Value: MBS("DynaPDF.Save"; $pdf; GetAsText(Convert::Input)) ] 

# Free Data

Set Variable [ $r ; Value: MBS("DynaPDF.Release"; $pdf) ] 

# Write to Container

New Record/Request

Set Field [ Convert::Output ; $PDFData ] 

Commit Records/Requests [ With dialog: On ] 


At first we initialize DynaPDF and open a new and clear PDF document. We set some flags for the import of the PDF. In this case we import all elements from the PDF, but with other settings you can to example only import the bookmarks or anything except the bookmarks. We import the page as a page and don't convert them to templates. Using templates is useful if an imported page can be used multiple times in one document.

Then the PDF in the input container is opened for the import to the current PDF document. With MBS("DynaPDF.SetLanguage"; $pdf; „en-US") we set the language to US english and create with MBS("DynaPDF.CreateStructureTree"; $pdf)  the structure tree. This is important for the barrier-free access to the document. A tagged PDF has the structure of the PDF outlined similar to an XML document. It defines which elements there are in a PDF document. For example, headings can also be identified as such. That makes the presentation in a screen viewer possible. Next the current PDF document is transformed to a PDF/A 1b 2005 document using the DynaPDF.CheckConformance function. With this function it is not only possible to convert a document to a PDFA 1b 2015, also to the following formats: 

  • PDFA 2b
  • PDFA 3b
  • Normalize
  • ZUGFeRD Basic
  • ZUGFeRD Comfort 
  • ZUGFeRD Extended  

This function returns a value which tells us the color profiles we need to add to the PDF. The color profiles are stored as global container fields in our example database. DynaPDF.AddOutputIntentEx adds the color profile and embedded it to the PDF document. At the end we set the PDF version, save the pdf, free the storage of the PDF document and write it to the Output Container. 

For this example you need the MBS FileMaker Plugin and at least a DynaPDF Pro + PDF/A licenses from us. You can even request a trial license on our homepage.

Have fun with this functionality in your solutions. 

If you have questions, please do not hesitate to contact me.  

Written by Stefanie Juchmes

18 03 19 - 14:01