Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

MBS FileMaker Plugin Example Databases

Merge PDFs

All examples are included with download of MBS FileMaker Plugin.

Merge PDFs.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts10
Value Lists0
Custom Functions0
Custom Menus33
File Options
Default custom menu set[Standard FileMaker Menus]
When opening file
Minimum allowed version12.0
Login usingAccount Name; Account= Admin
Allow user to save passwordOff
Require iOS passcodeOff
Switch to layoutOff
Hide all toolbarsOff
Script triggers
OnFirstWindowOpenOff
OnLastWindowCloseOff
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
Merge PDFs
5 fields defined, 2 records
Merge PDFs

Fields

Table Name: Merge PDFs - 5 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
DynaPDF LicenseKeyNormal, TextAuto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Global
  • Repetitions: 1
  • Index Language: German
      FinalPDFNormal, BinaryAuto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Global
      • Repetitions: 1
          InputPDFNormal, BinaryAuto-Enter:
          • Allow editing
          Validation:
          • Only during data entry
          Storage:
          • Repetitions: 1
              InputPathNormal, TextAuto-Enter:
              • Allow editing
              Validation:
              • Only during data entry
              Storage:
              • Repetitions: 1
              • Indexing: None
              • Automatically create indexes as needed
              • Index Language: German
                  InputNameNormal, TextAuto-Enter:
                  • Allow editing
                  Validation:
                  • Only during data entry
                  Storage:
                  • Repetitions: 1
                  • Indexing: None
                  • Automatically create indexes as needed
                  • Index Language: German

                      Layout Objects: Merge PDFs

                      Regular Fields

                      Field Name: Merge PDFs::DynaPDF LicenseKey
                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                      • Top: 6 pt
                      • Left: 145 pt
                      • Bottom: 25 pt
                      • Right: 398 pt
                      • Anchoring: Left, Top
                      Field Format:
                      • Edit Box
                      Field Behavior:
                      • Allow field to be entered: In Find mode, In Browse mode
                      • Touch keyboard type: Default for Data Type
                      • Go to next field using: Tab key
                      No

                      Field Name: Merge PDFs::FinalPDF
                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                      • Top: 32 pt
                      • Left: 145 pt
                      • Bottom: 257 pt
                      • Right: 398 pt
                      • Anchoring: Left, Top
                      Field Format:
                      • Edit Box
                      Field Behavior:
                      • Allow field to be entered: In Find mode, In Browse mode
                      • Touch keyboard type: Default for Data Type
                      • Go to next field using: Tab key
                      No

                      Field Name: Merge PDFs::InputPDF
                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                      • Top: 298 pt
                      • Left: 145 pt
                      • Bottom: 523 pt
                      • Right: 398 pt
                      • Anchoring: Left, Top
                      Field Format:
                      • Edit Box
                      • Optimized for interactive content
                      Field Behavior:
                      • Allow field to be entered: In Find mode, In Browse mode
                      • Touch keyboard type: Default for Data Type
                      • Go to next field using: Tab key
                      No

                      Field Name: Merge PDFs::InputPath
                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                      • Top: 530 pt
                      • Left: 145 pt
                      • Bottom: 549 pt
                      • Right: 398 pt
                      • Anchoring: Left, Top
                      Field Format:
                      • Edit Box
                      Field Behavior:
                      • Allow field to be entered: In Find mode, In Browse mode
                      • Touch keyboard type: Default for Data Type
                      • Go to next field using: Tab key
                      Yes

                      Field Name: Merge PDFs::InputName
                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                      • Top: 273 pt
                      • Left: 145 pt
                      • Bottom: 292 pt
                      • Right: 398 pt
                      • Anchoring: Left, Top
                      Field Format:
                      • Edit Box
                      Field Behavior:
                      • Allow field to be entered: In Find mode, In Browse mode
                      • Touch keyboard type: Default for Data Type
                      • Go to next field using: Tab key
                      Yes

                      Buttons

                      Button PropertiesCoordinatesScript/Script Step
                        Type:
                      • Text: Import PDF File
                      • Top: 273 pt
                      • Left: 413 pt
                      • Bottom: 310 pt
                      • Right: 606 pt
                      • Anchoring: Left, Top
                      Perform Script [ “Import File” ]

                      Scripts:


                      Button PropertiesCoordinatesScript/Script Step
                        Type:
                      • Text: Select PDF File
                      • Top: 319 pt
                      • Left: 413 pt
                      • Bottom: 357 pt
                      • Right: 606 pt
                      • Anchoring: Left, Top
                      Perform Script [ “Select PDF” ]

                      Scripts:


                      Button PropertiesCoordinatesScript/Script Step
                        Type:
                      • Text: Merge to Container
                      • Top: 32 pt
                      • Left: 413 pt
                      • Bottom: 69 pt
                      • Right: 606 pt
                      • Anchoring: Left, Top
                      Perform Script [ “Merge”; Parameter: 0 ]

                      Scripts:


                      Button PropertiesCoordinatesScript/Script Step
                        Type:
                      • Text: Merge to File on Desktop
                      • Top: 79 pt
                      • Left: 413 pt
                      • Bottom: 116 pt
                      • Right: 606 pt
                      • Anchoring: Left, Top
                      Perform Script [ “Merge”; Parameter: 1 ]

                      Scripts:


                      Button PropertiesCoordinatesScript/Script Step
                        Type:
                      • Text: Merge with Table Of Contents
                      • Top: 126 pt
                      • Left: 413 pt
                      • Bottom: 163 pt
                      • Right: 606 pt
                      • Anchoring: Left, Top
                      Perform Script [ “Merge with Table Of Content” ]

                      Scripts:


                      Script Hierarchy

                      InitDynaPDF
                      Merge
                      Merge with Table Of Content
                      Clear
                      Import File
                      Update Name
                      Select PDF
                      Add Page Numbers
                      Zip PDFs
                      Merge with Images

                      Next Script: [Merge]
                      Script NameInitDynaPDF
                      Run script with full access privilegesOff
                      Siri Shortcut VisibleOff
                      Include In MenuYes
                      Layouts that use this script
                        Scripts that use this script
                        Script Definition
                        Script Steps
                        • #Locate DynaPDF library
                        • #you can have libraries in container and export at runtime to folder of your choice.
                        • #Or install library somewhere and pass path.
                        • #If library is in same folder as plugin, you can only pass only file name.
                        • If [ MBS("IsServer") ]
                        • #Put the path you use for your server here:
                        • If [ Get(SystemPlatform) = -2 ]
                        • #Server on Windows
                        • Set Variable [ $path; Value:"C:\Programs\FileMaker Server\dynapdf.dll" ]
                        • Else If [ MBS("IsLinux") ]
                        • #Server on Linux for FileMaker Cloud
                        • Set Variable [ $path; Value:"/opt/FileMaker/FileMaker Server/dynapdf.linux.so" ]
                        • Else
                        • #Server on Mac
                        • Set Variable [ $path; Value: "/Library/FileMaker Server/dynapdf.dylib" ]
                        • End If
                        • Else
                        • #For desktop and our examples we look in same folder as database:
                        • Set Variable [ $databasePath; Value:Get(FilePath) ]
                        • Set Variable [ $databasePath; Value:MBS("Path.FilemakerPathToNativePath"; $databasePath) ]
                        • Set Variable [ $databasePath; Value:Substitute ( $databasePath ; ".fp7" ; ".fmp12") ]
                        • Set Variable [ $databaseName; Value:Get(FileName) & ".fmp12" ]
                        • If [ Get(SystemPlatform) = -2 ]
                        • Set Variable [ $path; Value:Substitute ( $databasePath ; $databaseName ; "dynapdf.dll" ) ]
                        • #plugin will look for dynapdf.dll and if not found also for dynapdf.dll (64-bit) and dynapdf32.dll (32-bit).
                        • Else
                        • Set Variable [ $path; Value:Substitute ( $databasePath ; $databaseName ; "dynapdf.dylib" ) ]
                        • #Mac dylib is usually 32 and 64 bit together.
                        • End If
                        • End If
                        • #You can test for free.
                        • #If you like to get a dynapdf license, please follow links on our pricing page:
                        • #https://www.monkeybreadsoftware.de/filemaker/pricing.shtml
                        • Set Variable [ $LicenseKey; Value:"" // put your key here or leave empty for demo. // Use e.g. "Lite", "Pro" or "Starter" to use demo mode for just that mode. ]
                        • Set Variable [ $r; Value:MBS( "DynaPDF.Initialize"; $path; $LicenseKey) ]
                        • If [ $r ≠ "OK" ]
                        • Show Custom Dialog [ Title: "Error"; Message: $r; Default Button: “OK”, Commit: “No”; Button 2: “Cancel”, Commit: “No” ]
                        • Halt Script
                        • End If
                        Fields used in this script
                          Scripts used in this script
                            Layouts used in this script
                              Tables used in this script
                                Table occurrences used by this script
                                  Custom Functions used by this script
                                    Custom menu set used by this script

                                      Previous Script: [InitDynaPDF]Next Script: [Merge with Table Of Content]
                                      Script NameMerge
                                      Run script with full access privilegesOff
                                      Siri Shortcut VisibleOff
                                      Include In MenuYes
                                      Layouts that use this script
                                      Scripts that use this script
                                        Script Definition
                                        Script Steps
                                        • #Initialize DynaPDF if needed
                                        • If [ MBS("DynaPDF.IsInitialized") ≠ 1 ]
                                        • Perform Script [ “InitDynaPDF” ]
                                        • End If
                                        • #Clear current PDF document
                                        • Set Variable [ $pdf; Value:MBS("DynaPDF.New") ]
                                        • Set Variable [ $MergeToFile; Value:Get(ScriptParameter) ]
                                        • #optionally we can merge to external file
                                        • If [ $MergeToFile = 1 ]
                                        • Set Variable [ $destPath; Value:MBS("Folders.UserDesktop") & "/test.pdf" ]
                                        • Set Variable [ $r; Value:MBS("DynaPDF.OpenOutputFile"; $pdf; $destPath) ]
                                        • If [ MBS("IsError") ]
                                        • Show Custom Dialog [ Title: "Failed to create PDF file."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                        • Exit Script [ ]
                                        • End If
                                        • End If
                                        • #Merge files
                                        • Go to Record/Request/Page [ First ]
                                        • Set Variable [ $destPage; Value:1 ]
                                        • Loop [ Flush: Always ]
                                        • #open PDF
                                        • If [ not IsEmpty ( Merge PDFs::InputPDF ) ]
                                        • Set Variable [ $r; Value:MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Merge PDFs::InputPDF) ]
                                        • If [ MBS("IsError") ]
                                        • Show Custom Dialog [ Title: "Failed to open PDF."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                        • Exit Script [ ]
                                        • End If
                                        • Else If [ not IsEmpty ( Merge PDFs::InputPath ) ]
                                        • Set Variable [ $r; Value:MBS("DynaPDF.OpenPDFFromFile"; $pdf; Merge PDFs::InputPath) ]
                                        • If [ MBS("IsError") ]
                                        • Show Custom Dialog [ Title: "Failed to open PDF."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                        • Exit Script [ ]
                                        • End If
                                        • Else
                                        • #no PDF?
                                        • End If
                                        • #check if we have pages to import
                                        • If [ MBS( "DynaPDF.GetImportPageCount"; $PDF ) > 0 ]
                                        • Set Variable [ $r; Value:MBS("DynaPDF.ImportPDFFile"; $pdf; $destpage) ]
                                        • If [ GetAsNumber($r) >0 ]
                                        • Set Variable [ $destPage; Value:$r+1 ]
                                        • End If
                                        • End If
                                        • #optionally close import files
                                        • Set Variable [ $r; Value:MBS("DynaPDF.CloseImportFile"; $pdf) ]
                                        • #next file
                                        • Go to Record/Request/Page [ Next; Exit after last ]
                                        • End Loop
                                        • Perform Script [ “Add Page Numbers”; Parameter: $pdf ]
                                        • #to debug, you can disable compression and open PDF in text editor
                                        • // Set Variable [ $r; Value:MBS("DynaPDF.SetCompressionLevel"; $pdf; 0) ]
                                        • #show final PDF
                                        • Set Field [ Merge PDFs::FinalPDF; MBS("DynaPDF.Save"; $pdf; "Merged.pdf") ]
                                        • Set Variable [ $r; Value:MBS("DynaPDF.Release"; $pdf) ]
                                        Fields used in this script
                                        Scripts used in this script
                                        Layouts used in this script
                                          Tables used in this script
                                          Table occurrences used by this script
                                          Custom Functions used by this script
                                            Custom menu set used by this script

                                              Previous Script: [Merge]Next Script: [Clear]
                                              Script NameMerge with Table Of Content
                                              Run script with full access privilegesOff
                                              Siri Shortcut VisibleOff
                                              Include In MenuYes
                                              Layouts that use this script
                                              Scripts that use this script
                                                Script Definition
                                                Script Steps
                                                • #Initialize DynaPDF if needed
                                                • If [ MBS("DynaPDF.IsInitialized") ≠ 1 ]
                                                • Perform Script [ “InitDynaPDF” ]
                                                • End If
                                                • #Clear current PDF document
                                                • Set Variable [ $pdf; Value:MBS("DynaPDF.New") ]
                                                • #create dummy page for table
                                                • Set Variable [ $r; Value:MBS("DynaPDF.AppendPage"; $pdf) ]
                                                • Set Variable [ $r; Value:MBS("DynaPDF.EndPage"; $pdf) ]
                                                • #create table for index
                                                • Set Variable [ $r; Value:MBS("DynaPDF.SetPageCoords"; $pdf; "TopDown") ]
                                                • Set Variable [ $table; Value:MBS("DynaPDF.Table.Create"; $pdf; 10; 2; 500; 20) ]
                                                • // Set Variable [ $r; Value:MBS("DynaPDF.Table.SetBorderWidth"; $table; -1; -1; 1; 1; 1; 1) ]
                                                • // Set Variable [ $r; Value:MBS("DynaPDF.Table.SetGridWidth"; $table; 1; 1) ]
                                                • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetFont"; $table; -1; -1; "Helvetica"; 0; 1; "unicode") ]
                                                • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetFontSize"; $table; -1; -1; 14) ]
                                                • Set Variable [ $r; Value:MBS( "DynaPDF.Table.SetColWidth"; $Table; 0; 450; 1 ) ]
                                                • Set Variable [ $r; Value:MBS( "DynaPDF.Table.SetColWidth"; $Table; 1; 50;1 ) ]
                                                • #Build Table Of Contents
                                                • Go to Record/Request/Page [ First ]
                                                • Set Variable [ $destPage; Value:2 ]
                                                • Loop [ Flush: Always ]
                                                • #open PDF
                                                • If [ not IsEmpty ( Merge PDFs::InputPDF ) ]
                                                • Set Variable [ $r; Value:MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Merge PDFs::InputPDF) ]
                                                • If [ MBS("IsError") ]
                                                • Show Custom Dialog [ Title: "Failed to open PDF."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                • Exit Script [ ]
                                                • End If
                                                • Else If [ not IsEmpty ( Merge PDFs::InputPath ) ]
                                                • Set Variable [ $r; Value:MBS("DynaPDF.OpenPDFFromFile"; $pdf; Merge PDFs::InputPath) ]
                                                • If [ MBS("IsError") ]
                                                • Show Custom Dialog [ Title: "Failed to open PDF."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                • Exit Script [ ]
                                                • End If
                                                • Else
                                                • #no PDF?
                                                • End If
                                                • #check if we have pages to import
                                                • Set Variable [ $pageCount; Value:MBS( "DynaPDF.GetImportPageCount"; $PDF ) ]
                                                • If [ $pageCount > 0 ]
                                                • Set Variable [ $lastPage; Value:MBS("DynaPDF.ImportPDFFile"; $pdf; $destpage) ]
                                                • If [ GetAsNumber($lastPage) >0 ]
                                                • #put in a named destination for this new page
                                                • Set Variable [ $NamedDest; Value:"Record" & Get(RecordID) ]
                                                • Set Variable [ $NamedDestHandle; Value:MBS( "DynaPDF.CreateNamedDest"; $PDF; $NamedDest; $DestPage; "Fit") ]
                                                • #add table entry
                                                • Set Variable [ $rowNum; Value:MBS("DynaPDF.Table.AddRow"; $table) ]
                                                • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $rowNum; 0; "left"; "top"; Merge PDFs::InputName) ]
                                                • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $rowNum; 1; "right"; "top"; $destPage) ]
                                                • #add click action
                                                • Set Variable [ $Action; Value:MBS( "DynaPDF.CreateGoToActionEx"; $PDF; $NamedDestHandle) ]
                                                • Set Variable [ $r; Value:MBS( "DynaPDF.Table.SetCellAction"; $Table; $rowNum; 0; $action; "Invert" ) ]
                                                • Set Variable [ $r; Value:MBS( "DynaPDF.Table.SetCellAction"; $Table; $rowNum; 1; $action; "Invert" ) ]
                                                • #also add a bookmark
                                                • Set Variable [ $r; Value:MBS( "DynaPDF.AddBookmark"; $pdf; Merge PDFs::InputName; -1; $destpage) ]
                                                • Set Variable [ $destPage; Value:$lastPage + 1 ]
                                                • End If
                                                • End If
                                                • #optionally close import files
                                                • Set Variable [ $r; Value:MBS("DynaPDF.CloseImportFile"; $pdf) ]
                                                • #next file
                                                • Go to Record/Request/Page [ Next; Exit after last ]
                                                • End Loop
                                                • #Draw Table
                                                • Set Variable [ $r; Value:MBS("DynaPDF.EditPage"; $pdf; 1) ]
                                                • Set Variable [ $r; Value:MBS("DynaPDF.Table.Draw"; $table; 50; 50; 742) ]
                                                • Set Variable [ $r; Value:MBS("DynaPDF.EndPage"; $pdf) ]
                                                • Perform Script [ “Add Page Numbers”; Parameter: $pdf ]
                                                • #to debug, you can disable compression and open PDF in text editor
                                                • // Set Variable [ $r; Value:MBS("DynaPDF.SetCompressionLevel"; $pdf; 0) ]
                                                • #show final PDF
                                                • Set Field [ Merge PDFs::FinalPDF; MBS("DynaPDF.Save"; $pdf; "Merged.pdf") ]
                                                • Set Variable [ $r; Value:MBS("DynaPDF.Release"; $pdf) ]
                                                Fields used in this script
                                                Scripts used in this script
                                                Layouts used in this script
                                                  Tables used in this script
                                                  Table occurrences used by this script
                                                  Custom Functions used by this script
                                                    Custom menu set used by this script

                                                      Previous Script: [Merge with Table Of Content]Next Script: [Import File]
                                                      Script NameClear
                                                      Run script with full access privilegesOff
                                                      Siri Shortcut VisibleOff
                                                      Include In MenuYes
                                                      Layouts that use this script
                                                        Scripts that use this script
                                                          Script Definition
                                                          Script Steps
                                                          • Set Field [ Merge PDFs::DynaPDF LicenseKey; "" ]
                                                          • Set Field [ Merge PDFs::FinalPDF; "" ]
                                                          Fields used in this script
                                                          Scripts used in this script
                                                            Layouts used in this script
                                                              Tables used in this script
                                                              Table occurrences used by this script
                                                              Custom Functions used by this script
                                                                Custom menu set used by this script

                                                                  Previous Script: [Clear]Next Script: [Update Name]
                                                                  Script NameImport File
                                                                  Run script with full access privilegesOff
                                                                  Siri Shortcut VisibleOff
                                                                  Include In MenuNo
                                                                  Layouts that use this script
                                                                  Scripts that use this script
                                                                    Script Definition
                                                                    Script Steps
                                                                    • If [ Get(FoundCount) = 0 ]
                                                                    • New Record/Request
                                                                    • End If
                                                                    • #import PDF
                                                                    • Go to Field [ Merge PDFs::InputPDF ]
                                                                    • Insert PDF [ ]
                                                                    • Set Field [ Merge PDFs::InputName; Substitute(GetAsText ( Merge PDFs::InputPDF ); ".pdf"; "") ]
                                                                    Fields used in this script
                                                                    Scripts used in this script
                                                                      Layouts used in this script
                                                                        Tables used in this script
                                                                        Table occurrences used by this script
                                                                        Custom Functions used by this script
                                                                          Custom menu set used by this script

                                                                            Previous Script: [Import File]Next Script: [Select PDF]
                                                                            Script NameUpdate Name
                                                                            Run script with full access privilegesOff
                                                                            Siri Shortcut VisibleOff
                                                                            Include In MenuNo
                                                                            Layouts that use this script
                                                                              Scripts that use this script
                                                                                Script Definition
                                                                                Script Steps
                                                                                • If [ not IsEmpty ( Merge PDFs::InputPDF ) ]
                                                                                • Set Field [ Merge PDFs::InputName; Substitute(GetAsText ( Merge PDFs::InputPDF ); ".pdf"; "") ]
                                                                                • End If
                                                                                • If [ not IsEmpty ( Merge PDFs::InputPath ) ]
                                                                                • Set Field [ Merge PDFs::InputName; Substitute(MBS( "Path.LastPathComponent"; Merge PDFs::InputPath ); ".pdf"; "") ]
                                                                                • End If
                                                                                Fields used in this script
                                                                                Scripts used in this script
                                                                                  Layouts used in this script
                                                                                    Tables used in this script
                                                                                    Table occurrences used by this script
                                                                                    Custom Functions used by this script
                                                                                      Custom menu set used by this script

                                                                                        Previous Script: [Update Name]Next Script: [Add Page Numbers]
                                                                                        Script NameSelect PDF
                                                                                        Run script with full access privilegesOff
                                                                                        Siri Shortcut VisibleOff
                                                                                        Include In MenuYes
                                                                                        Layouts that use this script
                                                                                        Scripts that use this script
                                                                                          Script Definition
                                                                                          Script Steps
                                                                                          • If [ Get(FoundCount) = 0 ]
                                                                                          • New Record/Request
                                                                                          • End If
                                                                                          • #pick file with file dialog
                                                                                          • Set Variable [ $r; Value:MBS("FileDialog.Reset") ]
                                                                                          • Set Variable [ $r; Value:MBS("FileDialog.SetAllowMulti"; 0) ]
                                                                                          • Set Variable [ $r; Value:MBS("FileDialog.OpenFileDialog") ]
                                                                                          • If [ $r = "OK" ]
                                                                                          • Set Variable [ $index; Value:0 ]
                                                                                          • Set Field [ Merge PDFs::InputPath; MBS("FileDialog.GetPath"; $index) ]
                                                                                          • Set Field [ Merge PDFs::InputName; Substitute(MBS( "Path.LastPathComponent"; Merge PDFs::InputPath ); ".pdf"; "") ]
                                                                                          • Commit Records/Requests [ No dialog ]
                                                                                          • End If
                                                                                          Fields used in this script
                                                                                          Scripts used in this script
                                                                                            Layouts used in this script
                                                                                              Tables used in this script
                                                                                              Table occurrences used by this script
                                                                                              Custom Functions used by this script
                                                                                                Custom menu set used by this script

                                                                                                  Previous Script: [Select PDF]Next Script: [Zip PDFs]
                                                                                                  Script NameAdd Page Numbers
                                                                                                  Run script with full access privilegesOff
                                                                                                  Siri Shortcut VisibleOff
                                                                                                  Include In MenuNo
                                                                                                  Layouts that use this script
                                                                                                    Scripts that use this script
                                                                                                    Script Definition
                                                                                                    Script Steps
                                                                                                    • Set Variable [ $pdf; Value:Get(ScriptParameter) ]
                                                                                                    • #set coordinates to go from top to down
                                                                                                    • Set Variable [ $r; Value:MBS( "DynaPDF.SetPageCoords"; $PDF; "TopDown" ) ]
                                                                                                    • #Add Page Numbers
                                                                                                    • Set Variable [ $PageCount; Value:MBS( "DynaPDF.GetPageCount"; $pdf ) ]
                                                                                                    • Set Variable [ $PageNumber; Value:1 ]
                                                                                                    • Loop [ Flush: Always ]
                                                                                                    • Set Variable [ $r; Value:MBS("DynaPDF.EditPage"; $pdf; $PageNumber) ]
                                                                                                    • If [ MBS("IsError") = 0 ]
                                                                                                    • Set Variable [ $pageWidth; Value:MBS("DynaPDF.GetPageWidth"; $pdf) ]
                                                                                                    • Set Variable [ $pageHeight; Value:MBS("DynaPDF.GetPageHeight"; $pdf) ]
                                                                                                    • Set Variable [ $r; Value:MBS( "DynaPDF.SetFont"; $pdf; "Helvetica"; 0; 20) ]
                                                                                                    • Set Variable [ $r; Value:MBS( "DynaPDF.WriteFTextEx"; $pdf; 50; $pageHeight - 50; $pageWidth-100; 30; "right"; GetAsText($PageNumber) & " of " & $PageCount) ]
                                                                                                    • Set Variable [ $r; Value:MBS("DynaPDF.EndPage"; $pdf) ]
                                                                                                    • End If
                                                                                                    • Set Variable [ $PageNumber; Value:$PageNumber +1 ]
                                                                                                    • Exit Loop If [ $PageNumber > $PageCount ]
                                                                                                    • End Loop
                                                                                                    Fields used in this script
                                                                                                      Scripts used in this script
                                                                                                        Layouts used in this script
                                                                                                          Tables used in this script
                                                                                                            Table occurrences used by this script
                                                                                                              Custom Functions used by this script
                                                                                                                Custom menu set used by this script

                                                                                                                  Previous Script: [Add Page Numbers]Next Script: [Merge with Images]
                                                                                                                  Script NameZip PDFs
                                                                                                                  Run script with full access privilegesOff
                                                                                                                  Siri Shortcut VisibleOff
                                                                                                                  Include In MenuYes
                                                                                                                  Layouts that use this script
                                                                                                                    Scripts that use this script
                                                                                                                      Script Definition
                                                                                                                      Script Steps
                                                                                                                      • Set Variable [ $r; Value:MBS( "Archive.Create"; "zip"; "deflate") ]
                                                                                                                      • If [ MBS("IsError") ]
                                                                                                                      • Show Custom Dialog [ Title: "Failed to create zip archive."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                      • Exit Script [ ]
                                                                                                                      • End If
                                                                                                                      • Go to Record/Request/Page [ First ]
                                                                                                                      • Set Variable [ $destPage; Value:1 ]
                                                                                                                      • Loop [ Flush: Always ]
                                                                                                                      • Set Variable [ $r; Value:MBS( "Archive.AddContainer"; Merge PDFs::InputPDF) ]
                                                                                                                      • Go to Record/Request/Page [ Next; Exit after last ]
                                                                                                                      • End Loop
                                                                                                                      • Set Variable [ $zip; Value:MBS( "Archive.Close"; "test.zip") ]
                                                                                                                      • If [ MBS("IsError") ]
                                                                                                                      • Show Custom Dialog [ Title: "Failed to create zip archive."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                      • Else
                                                                                                                      • Set Field [ Merge PDFs::FinalPDF; $zip ]
                                                                                                                      • End If
                                                                                                                      Fields used in this script
                                                                                                                      Scripts used in this script
                                                                                                                        Layouts used in this script
                                                                                                                          Tables used in this script
                                                                                                                          Table occurrences used by this script
                                                                                                                          Custom Functions used by this script
                                                                                                                            Custom menu set used by this script

                                                                                                                              Previous Script: [Zip PDFs]
                                                                                                                              Script NameMerge with Images
                                                                                                                              Run script with full access privilegesOff
                                                                                                                              Siri Shortcut VisibleOff
                                                                                                                              Include In MenuYes
                                                                                                                              Layouts that use this script
                                                                                                                                Scripts that use this script
                                                                                                                                  Script Definition
                                                                                                                                  Script Steps
                                                                                                                                  • #Initialize DynaPDF if needed
                                                                                                                                  • If [ MBS("DynaPDF.IsInitialized") ≠ 1 ]
                                                                                                                                  • Perform Script [ “InitDynaPDF” ]
                                                                                                                                  • End If
                                                                                                                                  • #Clear current PDF document
                                                                                                                                  • Set Variable [ $pdf; Value:MBS("DynaPDF.New") ]
                                                                                                                                  • Set Variable [ $MergeToFile; Value:Get(ScriptParameter) ]
                                                                                                                                  • #optionally we can merge to external file
                                                                                                                                  • If [ $MergeToFile = 1 ]
                                                                                                                                  • Set Variable [ $destPath; Value:MBS("Folders.UserDesktop") & "/test.pdf" ]
                                                                                                                                  • Set Variable [ $r; Value:MBS("DynaPDF.OpenOutputFile"; $pdf; $destPath) ]
                                                                                                                                  • If [ MBS("IsError") ]
                                                                                                                                  • Show Custom Dialog [ Title: "Failed to create PDF file."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                  • Exit Script [ ]
                                                                                                                                  • End If
                                                                                                                                  • End If
                                                                                                                                  • #Merge files
                                                                                                                                  • Go to Record/Request/Page [ First ]
                                                                                                                                  • Set Variable [ $destPage; Value:1 ]
                                                                                                                                  • Loop [ Flush: Always ]
                                                                                                                                  • #This will only use container as input, but can take images there, too
                                                                                                                                  • Set Variable [ $containerValue; Value:Merge PDFs::InputPDF ]
                                                                                                                                  • If [ not IsEmpty ( $containerValue ) ]
                                                                                                                                  • #now check what is inside by looking on types and/or file name
                                                                                                                                  • Set Variable [ $containerName; Value:GetAsText ( $containerValue ) ]
                                                                                                                                  • Set Variable [ $containerTypes; Value:MBS("Container.GetTypes"; $containerValue) ]
                                                                                                                                  • #Try PDF
                                                                                                                                  • If [ Position ( $containerTypes ; "PDF" ; 1 ; 1 ) > 0 or Position ( $containerName ; ".pdf" ; 1 ; 1 ) > 0 ]
                                                                                                                                  • Set Variable [ $r; Value:MBS("DynaPDF.OpenPDFFromContainer"; $pdf; $containerValue) ]
                                                                                                                                  • If [ MBS("IsError") ]
                                                                                                                                  • Show Custom Dialog [ Title: "Failed to open PDF"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                  • Else
                                                                                                                                  • #check if we have pages to import and then append them to the PDF
                                                                                                                                  • If [ MBS( "DynaPDF.GetImportPageCount"; $PDF ) > 0 ]
                                                                                                                                  • Set Variable [ $destpage; Value:MBS("DynaPDF.GetPageCount"; $pdf) + 1 ]
                                                                                                                                  • Set Variable [ $r; Value:MBS("DynaPDF.ImportPDFFile"; $pdf; $destpage) ]
                                                                                                                                  • If [ MBS("IsError") ]
                                                                                                                                  • Show Custom Dialog [ Title: "Failed to import pages from PDF 1."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                  • End If
                                                                                                                                  • End If
                                                                                                                                  • End If
                                                                                                                                  • Else
                                                                                                                                  • #if we have HEIC or HEIF, please convert
                                                                                                                                  • If [ Position ( $containerName ; ".HEIC" ; 1 ; 1 ) > 0 or Position ( $containerName ; ".HEIF" ; 1 ; 1 ) > 0 ]
                                                                                                                                  • Set Variable [ $containerValue; Value:MBS("Container.ReadImage"; $containerValue; "PNG"; "image.png" ) ]
                                                                                                                                  • End If
                                                                                                                                  • Set Variable [ $r; Value:MBS("DynaPDF.ReadImageFormat"; $pdf; $containerValue) ]
                                                                                                                                  • If [ MBS("IsError") ]
                                                                                                                                  • Show Custom Dialog [ Title: "Failed to read image"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                  • Else
                                                                                                                                  • #calculate zoom factor to scale proportional to something like A4
                                                                                                                                  • Set Variable [ $ImageWidth; Value:GetAsNumber (LeftValues ( $r ; 1 )) ]
                                                                                                                                  • Set Variable [ $imageHeight; Value:GetAsNumber (MiddleValues ( $r ; 2; 1 )) ]
                                                                                                                                  • Set Variable [ $PageHeight; Value:842 // DIN A4 ]
                                                                                                                                  • Set Variable [ $Factor; Value:Min( $PageHeight / $ImageHeight; $PageHeight / $ImageWidth) ]
                                                                                                                                  • #no recompression if possible!
                                                                                                                                  • Set Variable [ $r; Value:MBS("DynaPDF.SetSaveNewImageFormat"; $pdf; 0) ]
                                                                                                                                  • #calculate where the image goes
                                                                                                                                  • Set Variable [ $x; Value:0 ]
                                                                                                                                  • Set Variable [ $y; Value:0 ]
                                                                                                                                  • Set Variable [ $w; Value:$ImageWidth * $factor ]
                                                                                                                                  • Set Variable [ $h; Value:$ImageHeight * $factor ]
                                                                                                                                  • #and insert on a page with matching size
                                                                                                                                  • Set Variable [ $r; Value:MBS("DynaPDF.AppendPage"; $pdf) ]
                                                                                                                                  • Set Variable [ $r; Value:MBS("DynaPDF.SetPageHeight"; $pdf; $h) ]
                                                                                                                                  • Set Variable [ $r; Value:MBS("DynaPDF.SetPageWidth"; $pdf; $w) ]
                                                                                                                                  • Set Variable [ $r; Value:MBS("DynaPDF.InsertImage"; $pdf; $containerValue; $x; $y; $w; $h) ]
                                                                                                                                  • Set Variable [ $r; Value:MBS("DynaPDF.EndPage"; $pdf) ]
                                                                                                                                  • End If
                                                                                                                                  • End If
                                                                                                                                  • End If
                                                                                                                                  • #next file
                                                                                                                                  • Go to Record/Request/Page [ Next; Exit after last ]
                                                                                                                                  • End Loop
                                                                                                                                  • Perform Script [ “Add Page Numbers”; Parameter: $pdf ]
                                                                                                                                  • #to debug, you can disable compression and open PDF in text editor
                                                                                                                                  • // Set Variable [ $r; Value:MBS("DynaPDF.SetCompressionLevel"; $pdf; 0) ]
                                                                                                                                  • #show final PDF
                                                                                                                                  • Set Field [ Merge PDFs::FinalPDF; MBS("DynaPDF.Save"; $pdf; "Merged.pdf") ]
                                                                                                                                  • Set Variable [ $r; Value:MBS("DynaPDF.Release"; $pdf) ]
                                                                                                                                  Fields used in this script
                                                                                                                                  Scripts used in this script
                                                                                                                                  Layouts used in this script
                                                                                                                                    Tables used in this script
                                                                                                                                    Table occurrences used by this script
                                                                                                                                    Custom Functions used by this script
                                                                                                                                      Custom menu set used by this script

                                                                                                                                        Download example: Merge PDFs

                                                                                                                                        Used functions: