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

MBS FileMaker Plugin Example Databases

Convert to 2 Pages

All examples are included with download of MBS FileMaker Plugin.

Convert to 2 Pages.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts4
Value Lists0
Custom Functions0
Custom Menus24
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
Convert to 2 Pages
2 fields defined, 0 record
Convert to 2 Pages

Fields

Table Name: Convert to 2 Pages - 2 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
InputPDFNormal, BinaryAuto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Repetitions: 1
      OutputPDFNormal, BinaryAuto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1

          Layout Objects: Convert to 2 Pages

          Regular Fields

          Field Name: Convert to 2 Pages::InputPDF
          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
          • Top: 24 pt
          • Left: 19 pt
          • Bottom: 476 pt
          • Right: 402 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: Convert to 2 Pages::OutputPDF
          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
          • Top: 24 pt
          • Left: 630 pt
          • Bottom: 476 pt
          • Right: 1013 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

          Buttons

          Button PropertiesCoordinatesScript/Script Step
            Type:
          • Text: Convert to 2 Pages per Page
          • Top: 36 pt
          • Left: 420 pt
          • Bottom: 74 pt
          • Right: 615 pt
          • Anchoring: Left, Top
          Perform Script [ “Convert to 2 Pages” ]

          Scripts:


          Button PropertiesCoordinatesScript/Script Step
            Type:
          • Text: Convert to 4 Pages per Page
          • Top: 81 pt
          • Left: 420 pt
          • Bottom: 119 pt
          • Right: 615 pt
          • Anchoring: Left, Top
          Perform Script [ “Convert to 4 Pages” ]

          Scripts:


          Script Hierarchy

          InitDynaPDF
          Convert to 4 Pages
          Convert to 2 Pages
          Add crop markers

          Next Script: [Convert to 4 Pages]
          Script NameInitDynaPDF
          Run script with full access privilegesOff
          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: [Convert to 2 Pages]
                          Script NameConvert to 4 Pages
                          Run script with full access privilegesOff
                          Include In MenuYes
                          Layouts that use this script
                          Scripts that use this script
                            Script Definition
                            Script Steps
                            • Set Variable [ $r; Value:MBS("Trace") ]
                            • #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") ]
                            • #Load PDF from container
                            • Set Variable [ $r; Value:MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Convert to 2 Pages::InputPDF) ]
                            • If [ MBS("IsError") ≠ 0 ]
                            • Show Custom Dialog [ Title: "Failed to load PDF"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                            • Exit Script [ ]
                            • End If
                            • Set Variable [ $pageCount; Value:MBS( "DynaPDF.GetImportPageCount"; $pdf ) ]
                            • If [ not ($pageCount >= 1) ]
                            • #no pages?
                            • Exit Script [ ]
                            • End If
                            • #Query page size for first page
                            • Set Variable [ $bounds; Value:MBS("DynaPDF.GetImportPageBounds"; $pdf; 1; "MediaBox") ]
                            • Set Variable [ $bounds; Value:Substitute(Substitute($bounds; ","; ""); "."; ",") ]
                            • Set Variable [ $boundsLeft; Value:GetAsNumber(MiddleValues ( $bounds ; 1 ; 1 )) ]
                            • Set Variable [ $boundsTop; Value:GetAsNumber(MiddleValues ( $bounds ; 2 ; 1 )) ]
                            • Set Variable [ $boundsRight; Value:GetAsNumber(MiddleValues ( $bounds ; 3 ; 1 )) ]
                            • Set Variable [ $boundsBottom; Value:GetAsNumber(MiddleValues ( $bounds ; 4 ; 1 )) ]
                            • Set Variable [ $w; Value:Abs($boundsRight - $boundsLeft) ]
                            • Set Variable [ $h; Value:Abs($boundsBottom - $boundsTop) ]
                            • #optionally here half w or h to get smaller paper size
                            • Set Variable [ $page; Value:1 ]
                            • Loop
                            • #Import page as template
                            • Set Variable [ $template; Value:MBS("DynaPDF.ImportPageAsTemplate"; $pdf; $page) ]
                            • Set Variable [ $m; Value:Mod ( $page ; 4 ) ]
                            • If [ $m = 1 ]
                            • #first page of four
                            • If [ $page > 1 ]
                            • Set Variable [ $r; Value:MBS("DynaPDF.EndPage"; $pdf) ]
                            • End If
                            • Set Variable [ $r; Value:MBS("DynaPDF.AppendPage"; $pdf) ]
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetPageWidth"; $pdf; $w * 2) ]
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetPageHeight"; $pdf; $h * 2) ]
                            • Set Variable [ $r; Value:MBS("DynaPDF.PlaceTemplateEx"; $pdf; $template; 0; $h; $w; $h) ]
                            • Else If [ $m = 2 ]
                            • #second page of four
                            • Set Variable [ $r; Value:MBS("DynaPDF.PlaceTemplateEx"; $pdf; $template; $w; $h; $w; $h) ]
                            • Else If [ $m = 3 ]
                            • #third page of four
                            • Set Variable [ $r; Value:MBS("DynaPDF.PlaceTemplateEx"; $pdf; $template; 0; 0; $w; $h) ]
                            • Else If [ $m = 0 ]
                            • #forth page of four
                            • Set Variable [ $r; Value:MBS("DynaPDF.PlaceTemplateEx"; $pdf; $template; $w; 0; $w; $h) ]
                            • End If
                            • #next...
                            • Set Variable [ $page; Value:$page + 1 ]
                            • Exit Loop If [ $page > $pageCount ]
                            • End Loop
                            • Set Variable [ $r; Value:MBS("DynaPDF.EndPage"; $pdf) ]
                            • Set Field [ Convert to 2 Pages::OutputPDF; MBS("DynaPDF.Save"; $pdf; "Merged.pdf") ]
                            • #done, save to container
                            • 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: [Convert to 4 Pages]Next Script: [Add crop markers]
                                  Script NameConvert to 2 Pages
                                  Run script with full access privilegesOff
                                  Include In MenuYes
                                  Layouts that use this script
                                  Scripts that use this script
                                    Script Definition
                                    Script Steps
                                    • Set Variable [ $r; Value:MBS("Trace") ]
                                    • #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") ]
                                    • #Load PDF from container
                                    • Set Variable [ $r; Value:MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Convert to 2 Pages::InputPDF) ]
                                    • If [ MBS("IsError") ≠ 0 ]
                                    • Show Custom Dialog [ Title: "Failed to load PDF"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                    • Exit Script [ ]
                                    • End If
                                    • Set Variable [ $pageCount; Value:MBS( "DynaPDF.GetImportPageCount"; $pdf ) ]
                                    • If [ not ($pageCount >= 1) ]
                                    • #no pages?
                                    • Exit Script [ ]
                                    • End If
                                    • #Query page size for first page
                                    • Set Variable [ $bounds; Value:MBS("DynaPDF.GetImportPageBounds"; $pdf; 1; "MediaBox") ]
                                    • Set Variable [ $bounds; Value:Substitute(Substitute($bounds; ","; ""); "."; ",") ]
                                    • Set Variable [ $boundsLeft; Value:GetAsNumber(MiddleValues ( $bounds ; 1 ; 1 )) ]
                                    • Set Variable [ $boundsTop; Value:GetAsNumber(MiddleValues ( $bounds ; 2 ; 1 )) ]
                                    • Set Variable [ $boundsRight; Value:GetAsNumber(MiddleValues ( $bounds ; 3 ; 1 )) ]
                                    • Set Variable [ $boundsBottom; Value:GetAsNumber(MiddleValues ( $bounds ; 4 ; 1 )) ]
                                    • Set Variable [ $w; Value:Abs($boundsRight - $boundsLeft) ]
                                    • Set Variable [ $h; Value:Abs($boundsBottom - $boundsTop) ]
                                    • #optionally here half w or h to get smaller paper size
                                    • Set Variable [ $page; Value:1 ]
                                    • Loop
                                    • #Import page as template
                                    • Set Variable [ $template; Value:MBS("DynaPDF.ImportPageAsTemplate"; $pdf; $page) ]
                                    • Set Variable [ $m; Value:Mod ( $page ; 2 ) ]
                                    • If [ $m = 1 ]
                                    • #first page of two
                                    • If [ $page > 1 ]
                                    • Set Variable [ $r; Value:MBS("DynaPDF.EndPage"; $pdf) ]
                                    • End If
                                    • Set Variable [ $r; Value:MBS("DynaPDF.AppendPage"; $pdf) ]
                                    • Set Variable [ $r; Value:MBS("DynaPDF.SetPageWidth"; $pdf; $w * 2) ]
                                    • Set Variable [ $r; Value:MBS("DynaPDF.SetPageHeight"; $pdf; $h) ]
                                    • Set Variable [ $r; Value:MBS("DynaPDF.PlaceTemplateEx"; $pdf; $template; 0; 0; $w; $h) ]
                                    • Else If [ $m = 0 ]
                                    • #second page of two
                                    • Set Variable [ $r; Value:MBS("DynaPDF.PlaceTemplateEx"; $pdf; $template; $w; 0; $w; $h) ]
                                    • End If
                                    • #next...
                                    • Set Variable [ $page; Value:$page + 1 ]
                                    • Exit Loop If [ $page > $pageCount ]
                                    • End Loop
                                    • Set Variable [ $r; Value:MBS("DynaPDF.EndPage"; $pdf) ]
                                    • Set Field [ Convert to 2 Pages::OutputPDF; MBS("DynaPDF.Save"; $pdf; "Merged.pdf") ]
                                    • #done, save to container
                                    • 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: [Convert to 2 Pages]
                                          Script NameAdd crop markers
                                          Run script with full access privilegesOff
                                          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") ]
                                              • #Load PDF from container
                                              • Set Variable [ $r; Value:MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Convert to 2 Pages::InputPDF) ]
                                              • If [ MBS("IsError") ≠ 0 ]
                                              • Show Custom Dialog [ Title: "Failed to load PDF"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                              • Exit Script [ ]
                                              • End If
                                              • Set Variable [ $Debug; Value:1 ]
                                              • #Query page size for first page
                                              • Set Variable [ $bounds; Value:MBS("DynaPDF.GetImportPageBounds"; $pdf; 1; "MediaBox") ]
                                              • Set Variable [ $boundsLeft; Value:MBS("Math.TextToNumber"; MiddleValues ( $bounds ; 1 ; 1 )) ]
                                              • Set Variable [ $boundsTop; Value:MBS("Math.TextToNumber"; MiddleValues ( $bounds ; 2 ; 1 )) ]
                                              • Set Variable [ $boundsRight; Value:MBS("Math.TextToNumber"; MiddleValues ( $bounds ; 3 ; 1 )) ]
                                              • Set Variable [ $boundsBottom; Value:MBS("Math.TextToNumber"; MiddleValues ( $bounds ; 4 ; 1 )) ]
                                              • Set Variable [ $w; Value:Abs($boundsRight - $boundsLeft) ]
                                              • Set Variable [ $h; Value:Abs($boundsBottom - $boundsTop) ]
                                              • #now import page as template and place on new page with border around
                                              • Set Variable [ $template; Value:MBS("DynaPDF.ImportPageAsTemplate"; $pdf; 1) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.AppendPage"; $pdf) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.SetPageWidth"; $pdf; $w + 200) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.SetPageHeight"; $pdf; $h + 200) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.PlaceTemplateEx"; $pdf; $template; 100; 100; $w; $h) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.SetStrokeColor"; $pdf; 1; 0; 0) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.SetLineWidth"; $pdf; 1) ]
                                              • If [ $Debug ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.Rectangle"; $pdf; 100-1; 100-1; $w+2; $h+2; "stroke") ]
                                              • End If
                                              • Set Variable [ $r; Value:MBS("DynaPDF.MoveTo"; $pdf; 100; 100 - 10) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.LineTo"; $pdf; 100; 0) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.ClosePath"; $pdf; "stroke") ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.MoveTo"; $pdf; 100; 100 + 10 + $h) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.LineTo"; $pdf; 100; $h + 200) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.ClosePath"; $pdf; "stroke") ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.MoveTo"; $pdf; 100 + $w; 100 - 10) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.LineTo"; $pdf; 100 + $w; 0) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.ClosePath"; $pdf; "stroke") ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.MoveTo"; $pdf; 100 + $w; 100 + 10 + $h) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.LineTo"; $pdf; 100 + $w; $h + 200) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.ClosePath"; $pdf; "stroke") ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.MoveTo"; $pdf; 100 - 10; 100) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.LineTo"; $pdf; 0; 100) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.ClosePath"; $pdf; "stroke") ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.MoveTo"; $pdf; 100 + 10 + $w; 100) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.LineTo"; $pdf; $w + 200; 100) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.ClosePath"; $pdf; "stroke") ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.MoveTo"; $pdf; 100 - 10; 100+$h) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.LineTo"; $pdf; 0; 100 + $h) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.ClosePath"; $pdf; "stroke") ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.MoveTo"; $pdf; 100 + 10 + $w; 100 + $h) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.LineTo"; $pdf; $w + 200; 100 + $h) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.ClosePath"; $pdf; "stroke") ]
                                              • If [ $Debug ]
                                              • #no bounding box
                                              • Else
                                              • Set Variable [ $r; Value:MBS("DynaPDF.SetBBox"; $pdf; "crop";100; 100; $w+100; $h+100) ]
                                              • End If
                                              • Set Variable [ $r; Value:MBS("DynaPDF.SetBBox"; $pdf; "media"; 0; 0; $w+200; $h+200) ]
                                              • Set Variable [ $r; Value:MBS("DynaPDF.EndPage"; $pdf) ]
                                              • Set Field [ Convert to 2 Pages::OutputPDF; MBS("DynaPDF.Save"; $pdf; "Merged.pdf") ]
                                              • #done, save to container
                                              • 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: Convert to 2 Pages

                                                    Used functions: