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

MBS FileMaker Plugin Example Databases

Invoice

All examples are included with download of MBS FileMaker Plugin.

Invoice.fmp12

Overview
Tables2
Relationships1
Layouts2
Scripts2
Value Lists0
Custom Functions1
Custom Menus0
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
Invoice
8 fields defined, 2 records
Invoice
Items
6 fields defined, 50 records
Items

Fields

Table Name: Invoice - 8 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
Header LineNormal, TextAuto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Repetitions: 1
  • Indexing: None
  • Automatically create indexes as needed
  • Index Language: German
      Bottom LineNormal, TextAuto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1
      • Indexing: None
      • Automatically create indexes as needed
      • Index Language: German
          AddressNormal, TextAuto-Enter:
          • Allow editing
          Validation:
          • Only during data entry
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German
              IDNormal, NumberAuto-Enter:
              • Allow editing
              • Serial: Generate: On creation, Next value: 5, Increment: 1
              Validation:
              • Only during data entry
              Storage:
              • Repetitions: 1
              • Indexing: All
              • Index Language: German
                  Invoice IDNormal, TextAuto-Enter: Validation:
                  • Only during data entry
                  Storage:
                  • Repetitions: 1
                  • Indexing: None
                  • Automatically create indexes as needed
                  • Index Language: German
                      Creation DateNormal, TimestampAuto-Enter:
                      • Creation timestamp
                      • Allow editing
                      Validation:
                      • Only during data entry
                      Storage:
                      • Repetitions: 1
                      • Indexing: None
                      • Automatically create indexes as needed
                      • Index Language: German
                          PDF TemplateNormal, BinaryAuto-Enter:
                          • Allow editing
                          Validation:
                          • Only during data entry
                          Storage:
                          • Global
                          • Repetitions: 1
                              PDF OutputNormal, BinaryAuto-Enter:
                              • Allow editing
                              Validation:
                              • Only during data entry
                              Storage:
                              • Repetitions: 1

                                  Table Name: Items - 6 Fields
                                  Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
                                  LabelNormal, TextAuto-Enter:
                                  • Allow editing
                                  Validation:
                                  • Only during data entry
                                  Storage:
                                  • Repetitions: 1
                                  • Indexing: None
                                  • Automatically create indexes as needed
                                  • Index Language: German
                                      QuantityNormal, NumberAuto-Enter:
                                      • Allow editing
                                      Validation:
                                      • Only during data entry
                                      Storage:
                                      • Repetitions: 1
                                      • Indexing: None
                                      • Automatically create indexes as needed
                                      • Index Language: German
                                          PriceNormal, NumberAuto-Enter:
                                          • Allow editing
                                          Validation:
                                          • Only during data entry
                                          Storage:
                                          • Repetitions: 1
                                          • Indexing: None
                                          • Automatically create indexes as needed
                                          • Index Language: German
                                              SumNormal, NumberAuto-Enter: Validation:
                                              • Only during data entry
                                              Storage:
                                              • Repetitions: 1
                                              • Indexing: None
                                              • Automatically create indexes as needed
                                              • Index Language: German
                                                  Invoice IDNormal, NumberAuto-Enter:
                                                  • Allow editing
                                                  Validation:
                                                  • Only during data entry
                                                  Storage:
                                                  • Repetitions: 1
                                                  • Indexing: All
                                                  • Index Language: German
                                                      Item IDNormal, NumberAuto-Enter:
                                                      • Allow editing
                                                      • Serial: Generate: On creation, Next value: 51, Increment: 1
                                                      Validation:
                                                      • Only during data entry
                                                      Storage:
                                                      • Repetitions: 1
                                                      • Indexing: None
                                                      • Automatically create indexes as needed
                                                      • Index Language: German

                                                            Layout Objects: Invoice

                                                            Regular Fields

                                                            Field Name: Invoice::Header Line
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 64 pt
                                                            • Left: 135 pt
                                                            • Bottom: 114 pt
                                                            • Right: 388 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: Invoice::Bottom Line
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 114 pt
                                                            • Left: 135 pt
                                                            • Bottom: 135 pt
                                                            • Right: 388 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: Invoice::Address
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 137 pt
                                                            • Left: 135 pt
                                                            • Bottom: 158 pt
                                                            • Right: 388 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: Invoice::ID
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 160 pt
                                                            • Left: 135 pt
                                                            • Bottom: 182 pt
                                                            • Right: 388 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: Invoice::Invoice ID
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 183 pt
                                                            • Left: 135 pt
                                                            • Bottom: 204 pt
                                                            • Right: 388 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: Invoice::Creation Date
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 206 pt
                                                            • Left: 135 pt
                                                            • Bottom: 228 pt
                                                            • Right: 388 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: Items::Label
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 245 pt
                                                            • Left: 26 pt
                                                            • Bottom: 266 pt
                                                            • Right: 304 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: Items::Quantity
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 245 pt
                                                            • Left: 304 pt
                                                            • Bottom: 266 pt
                                                            • Right: 361 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: Items::Price
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 245 pt
                                                            • Left: 361 pt
                                                            • Bottom: 266 pt
                                                            • Right: 418 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: Items::Sum
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 245 pt
                                                            • Left: 418 pt
                                                            • Bottom: 266 pt
                                                            • Right: 475 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: Invoice::PDF Template
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 538 pt
                                                            • Left: 94 pt
                                                            • Bottom: 663 pt
                                                            • Right: 347 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: Invoice::PDF Output
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 268 pt
                                                            • Left: 495 pt
                                                            • Bottom: 521 pt
                                                            • Right: 828 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: Create PDF
                                                            • Top: 77 pt
                                                            • Left: 427 pt
                                                            • Bottom: 99 pt
                                                            • Right: 547 pt
                                                            • Anchoring: Left, Top
                                                            Perform Script [ “Run” ]

                                                            Scripts:


                                                            Portals

                                                            Portal PropertiesCoordinatesFieldsOptions
                                                            • Top: 242 pt
                                                            • Left: 23 pt
                                                            • Bottom: 519 pt
                                                            • Right: 483 pt
                                                            • Anchoring: Left, Top
                                                            Field Objects
                                                            • Sort records: On

                                                              Field: Item ID

                                                              • Ascending order
                                                              • Reorder based on summary field: Off
                                                              • Override field's language for sort: Off

                                                            • Filter calculation: None
                                                            • Initial Row: 1
                                                            • Number of Rows: 11
                                                            • Allow deletion of portal records

                                                            Layout Objects: Items

                                                            Regular Fields

                                                            Field Name: Items::Label
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 52 pt
                                                            • Left: 138 pt
                                                            • Bottom: 73 pt
                                                            • Right: 391 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: Items::Quantity
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 75 pt
                                                            • Left: 138 pt
                                                            • Bottom: 96 pt
                                                            • Right: 217 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: Items::Price
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 98 pt
                                                            • Left: 138 pt
                                                            • Bottom: 119 pt
                                                            • Right: 217 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: Items::Sum
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 121 pt
                                                            • Left: 138 pt
                                                            • Bottom: 142 pt
                                                            • Right: 217 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: Items::Invoice ID
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 144 pt
                                                            • Left: 138 pt
                                                            • Bottom: 165 pt
                                                            • Right: 217 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: Items::Item ID
                                                            Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                            • Top: 167 pt
                                                            • Left: 138 pt
                                                            • Bottom: 188 pt
                                                            • Right: 217 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

                                                            Script Hierarchy

                                                            InitDynaPDF
                                                            Run

                                                            Next Script: [Run]
                                                            Script NameInitDynaPDF
                                                            Run script with full access privilegesOff
                                                            Include In MenuNo
                                                            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]
                                                                            Script NameRun
                                                                            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 [ $debug; Value:1 ]
                                                                              • Set Variable [ $useTemplate; Value:1 // import single pages requires a Pro license. // set 0 to use Starter license only ]
                                                                              • #Currency for formatting
                                                                              • Set Variable [ $currencyBefore; Value:"" ]
                                                                              • Set Variable [ $currencyAfter; Value:"€" ]
                                                                              • Set Variable [ $taxRate; Value:,19 ]
                                                                              • #Detect decimal separator
                                                                              • Set Variable [ $numberText; Value:GetAsText(8,888) ]
                                                                              • Set Variable [ $comma; Value:Middle ( $numberText; 2; 1 ) ]
                                                                              • If [ $debug ]
                                                                              • Set Variable [ $TracePath; Value:MBS( "Path.AddPathComponent"; MBS( "Folders.UserDesktop" ); "trace.txt" ) ]
                                                                              • Set Variable [ $r; Value:MBS("Trace"; $TracePath) ]
                                                                              • End If
                                                                              • #Initialize DynaPDF if needed
                                                                              • If [ MBS("DynaPDF.IsInitialized") ≠ 1 ]
                                                                              • Perform Script [ “InitDynaPDF” ]
                                                                              • End If
                                                                              • If [ MBS("DynaPDF.IsInitialized") ≠ 1 ]
                                                                              • Exit Script [ ]
                                                                              • End If
                                                                              • Go to Layout [ “Invoice” (Invoice) ]
                                                                              • #Start new PDF
                                                                              • Set Variable [ $pdf; Value:MBS("DynaPDF.New") ]
                                                                              • #Set some flags for import
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.SetImportFlags"; $pdf; "ImportAll ImportAsPage") ]
                                                                              • #Set language metadata
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.SetLanguage"; $pdf; "en-US") ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.CreateStructureTree"; $pdf) ]
                                                                              • #Add first page
                                                                              • If [ $useTemplate ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Invoice::PDF Template) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.ImportPDFPage"; $pdf; 1) ]
                                                                              • #now change it by writing on it
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.EditPage"; $pdf; 1) ]
                                                                              • Else
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.AppendPage"; $pdf) ]
                                                                              • End If
                                                                              • #set coordinates to go from top to down
                                                                              • Set Variable [ $r; Value:MBS( "DynaPDF.SetPageCoords"; $PDF; "TopDown" ) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.SetFont"; $pdf; "Times"; 0; 14; 1; "unicode") ]
                                                                              • #leading is line height
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.SetLeading"; $pdf; 18) ]
                                                                              • #write the address
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.WriteFTextEx"; $pdf; 58; 150; 400; -1; "left"; Invoice::Address) ]
                                                                              • #switch to bold font
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.SetFont"; $pdf; "Times"; 2; 14; 1; "unicode") ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.WriteFTextEx"; $pdf; 58; 310; 200; 30; "left"; "Invoice " & Invoice::Invoice ID) ]
                                                                              • #switch to font back
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.SetFont"; $pdf; "Times"; 0; 14; 1; "unicode") ]
                                                                              • #write date
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.WriteFTextEx"; $pdf; 338; 310; 200; 30; "right"; GetAsDate( Invoice::Creation Date)) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.SetLeading"; $pdf; 0) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.WriteFTextEx"; $pdf; 58; 350; 400; -1; "left"; Invoice::Header Line) ]
                                                                              • #use position after text for the table
                                                                              • Set Variable [ $pageHeight; Value:MBS("DynaPDF.GetPageHeight"; $pdf) ]
                                                                              • Set Variable [ $y; Value:$pageHeight - MBS( "DynaPDF.GetLastTextPosY"; $pdf ) + 10 ]
                                                                              • #Build intermediate table for sum
                                                                              • Set Variable [ $itable; Value:MBS("DynaPDF.Table.Create"; $pdf; 3; 2; 500; 10) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellPadding"; $itable; -1; -1; 1; 1; 1; 1) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetGridWidth"; $itable; ,5; ,5) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetBorderWidth"; $itable; -1; -1; ,5; ,5; 0; ,5) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetRGBColor"; $itable; -1; -1; "BorderColor"; 127; 127; 127) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetRGBColor"; $itable; -1; -1; "GridHorzColor"; 127; 127; 127) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetRGBColor"; $itable; -1; -1; "GridVertColor"; 127; 127; 127) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetFont"; $itable; -1; -1; "Helvetica"; 0; 1; "unicode") ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetFontSize"; $itable; -1; -1; 12) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetColWidth"; $itable; 0; 50+210+80+60; 1) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetColWidth"; $itable; 1; 80; 1) ]
                                                                              • #Add row
                                                                              • Set Variable [ $row; Value:MBS("DynaPDF.Table.AddRow"; $itable) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $itable; $row; 0; "right"; "top"; "Sum") ]
                                                                              • #Build end table for sum
                                                                              • Set Variable [ $etable; Value:MBS("DynaPDF.Table.Create"; $pdf; 3; 2; 500; 10) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellPadding"; $etable; -1; -1; 1; 1; 1; 1) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetGridWidth"; $etable; ,5; ,5) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetBorderWidth"; $etable; -1; -1; ,5; ,5; 0; ,5) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetRGBColor"; $etable; -1; -1; "BorderColor"; 127; 127; 127) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetRGBColor"; $etable; -1; -1; "GridHorzColor"; 127; 127; 127) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetRGBColor"; $etable; -1; -1; "GridVertColor"; 127; 127; 127) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetFont"; $etable; -1; -1; "Helvetica"; 0; 1; "unicode") ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetFontSize"; $etable; -1; -1; 12) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetColWidth"; $etable; 0; 50+210+80+60; 1) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetColWidth"; $etable; 1; 80; 1) ]
                                                                              • #sum rows
                                                                              • Set Variable [ $row; Value:MBS("DynaPDF.Table.AddRow"; $etable) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $etable; $row; 0; "right"; "top"; "Sum before Tax") ]
                                                                              • Set Variable [ $row; Value:MBS("DynaPDF.Table.AddRow"; $etable) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $etable; $row; 0; "right"; "top"; "Tax") ]
                                                                              • Set Variable [ $row; Value:MBS("DynaPDF.Table.AddRow"; $etable) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $etable; $row; 0; "right"; "top"; "Sum including Tax") ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetFont"; $etable; $row; 1; "Helvetica"; 2; 1; "unicode") ]
                                                                              • #Build main table
                                                                              • Set Variable [ $table; Value:MBS("DynaPDF.Table.Create"; $pdf; 20; 5; 500; 10) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellPadding"; $table; -1; -1; 1; 1; 1; 1) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetGridWidth"; $table; ,5; ,5) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetBorderWidth"; $table; -1; -1; ,5; ,5; ,5; ,5) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetRGBColor"; $table; -1; -1; "BorderColor"; 127; 127; 127) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetRGBColor"; $table; -1; -1; "GridHorzColor"; 127; 127; 127) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetRGBColor"; $table; -1; -1; "GridVertColor"; 127; 127; 127) ]
                                                                              • 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; 12) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetColWidth"; $table; 0; 50; 1) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetColWidth"; $table; 1; 210; 1) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetColWidth"; $table; 2; 80; 1) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetColWidth"; $table; 3; 60; 1) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetColWidth"; $table; 4; 80; 1) ]
                                                                              • #Add header row
                                                                              • Set Variable [ $row; Value:MBS("DynaPDF.Table.AddRow"; $table) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $row; 0; "right"; "top"; "Index") ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $row; 1; "left"; "top"; "Product") ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $row; 2; "right"; "top"; "Price") ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $row; 3; "right"; "top"; "Quantity") ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $row; 4; "right"; "top"; "Total Price") ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetFlags"; $table; $row; -1; "HeaderRow") ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetFont"; $table; $row; -1; "Helvetica"; 2; 1; "unicode") ]
                                                                              • #Walk over items in invoice to put them into table
                                                                              • Go to Related Record [ From table: “Items”; Using layout: “Items” (Items) ] [ Show only related records ]
                                                                              • Set Variable [ $e1; Value:Get ( LastError ) ]
                                                                              • Set Variable [ $NumberOfItems; Value:0 ]
                                                                              • Set Variable [ $index; Value:0 ]
                                                                              • #Prices list will remmeber the prices for summing htem
                                                                              • Set Variable [ $Prices; Value:MBS( "QuickList.New") ]
                                                                              • Set Variable [ $r; Value:MBS( "QuickList.AddValue"; $Prices; 0 ) ]
                                                                              • #Loop over items
                                                                              • If [ $e1 = 0 and Get ( FoundCount ) >0 ]
                                                                              • Set Variable [ $NumberOfImages; Value:Get ( FoundCount ) ]
                                                                              • Go to Record/Request/Page [ First ]
                                                                              • Loop
                                                                              • #Add a row
                                                                              • Set Variable [ $row; Value:MBS("DynaPDF.Table.AddRow"; $table) ]
                                                                              • Set Variable [ $index; Value:$index +1 ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $row; 0; "right"; "top"; GetAsText($index)) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $row; 1; "left"; "top"; Items::Label) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $row; 2; "right"; "top"; $currencyBefore & FormatNumber(Items::Price; $comma) & $currencyAfter) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $row; 3; "right"; "top"; Items::Quantity) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $table; $row; 4; "right"; "top"; $currencyBefore & FormatNumber(Items::Sum; $comma) & $currencyAfter) ]
                                                                              • #Remember prices for summing
                                                                              • Set Variable [ $r; Value:MBS( "QuickList.AddValue"; $Prices; Items::Sum ) ]
                                                                              • Go to Record/Request/Page [ Next; Exit after last ]
                                                                              • End Loop
                                                                              • End If
                                                                              • Go to Related Record [ From table: “Invoice”; Using layout: “Invoice” (Invoice) ]
                                                                              • #Draw Table
                                                                              • Set Variable [ $PageNumber; Value:1 ]
                                                                              • Set Variable [ $h; Value:300 ]
                                                                              • Set Variable [ $sum; Value:0 ]
                                                                              • Set Variable [ $sum; Value:0 ]
                                                                              • Loop
                                                                              • #Draw something on page
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.Draw"; $table; 58; $y; $h) ]
                                                                              • Set Variable [ $y; Value:$y + $r ]
                                                                              • #Sum up the prices in the rows we just draw
                                                                              • Set Variable [ $firstRow; Value:MBS( "DynaPDF.Table.GetFirstRow"; $table ) ]
                                                                              • Set Variable [ $nextRow; Value:MBS( "DynaPDF.Table.GetNextRow"; $table ) ]
                                                                              • Set Variable [ $row; Value:$firstRow ]
                                                                              • Loop
                                                                              • Set Variable [ $price; Value:MBS( "QuickList.GetValue"; $Prices; $row ) ]
                                                                              • Set Variable [ $sum; Value:$sum + $price ]
                                                                              • Set Variable [ $row; Value:$row + 1 ]
                                                                              • Exit Loop If [ $row >= $nextRow ]
                                                                              • End Loop
                                                                              • Exit Loop If [ MBS("DynaPDF.Table.HaveMore"; $table) ≠ 1 ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $itable; 0; 1; "right"; "top"; $currencyBefore & FormatNumber($sum; $comma) & $currencyAfter) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.Draw"; $itable; 58; $y; 100) ]
                                                                              • Set Variable [ $y; Value:$y + $r ]
                                                                              • #Draw sum table
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.EndPage"; $pdf) ]
                                                                              • Set Variable [ $y; Value:$y + 5 ]
                                                                              • #Add another page
                                                                              • If [ $useTemplate ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.ImportPDFPage"; $pdf; 2) ]
                                                                              • Set Variable [ $PageCount; Value:MBS( "DynaPDF.GetPageCount"; $pdf ) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.EditPage"; $pdf ; $PageCount) ]
                                                                              • Else
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.AppendPage"; $pdf) ]
                                                                              • End If
                                                                              • Set Variable [ $h; Value:580 ]
                                                                              • Set Variable [ $y; Value:120 ]
                                                                              • End Loop
                                                                              • #Bottom table for tax and sums
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $etable; 0; 1; "right"; "top"; $currencyBefore & FormatNumber($sum; $comma) & $currencyAfter) ]
                                                                              • Set Variable [ $tax; Value:Round($sum * $taxRate;2) ]
                                                                              • Set Variable [ $sum; Value:$sum + $tax ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $etable; 1; 1; "right"; "top"; $currencyBefore & FormatNumber($tax; $comma) & $currencyAfter) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.SetCellText"; $etable; 2; 1; "right"; "top"; $currencyBefore & FormatNumber($sum; $comma) & $currencyAfter) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.Draw"; $etable; 58; $y; 100) ]
                                                                              • Set Variable [ $y; Value:$y + $r ]
                                                                              • #Bottom text
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.SetFont"; $pdf; "Times"; 0; 14; 1; "unicode") ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.WriteFTextEx"; $pdf; 58; $y; 500; -1; "left"; Invoice::Bottom Line) ]
                                                                              • #End page
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.EndPage"; $pdf) ]
                                                                              • #Add extra pages
                                                                              • If [ $useTemplate ]
                                                                              • Set Variable [ $page; Value:3 ]
                                                                              • Set Variable [ $importPageCount; Value:MBS( "DynaPDF.GetImportPageCount"; $pdf ) ]
                                                                              • Loop
                                                                              • Exit Loop If [ $page > $importPageCount ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.ImportPDFPage"; $pdf; $page) ]
                                                                              • Set Variable [ $page; Value:$page + 1 ]
                                                                              • End Loop
                                                                              • End If
                                                                              • #Set title of document
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.SetDocInfo"; $pdf; "Title"; "Test PDF") ]
                                                                              • #Add Page Numbers
                                                                              • Set Variable [ $PageCount; Value:MBS( "DynaPDF.GetPageCount"; $pdf ) ]
                                                                              • Set Variable [ $PageNumber; Value:1 ]
                                                                              • Set Variable [ $pageWidth; Value:MBS("DynaPDF.GetPageWidth"; $pdf) ]
                                                                              • Set Variable [ $pageHeight; Value:MBS("DynaPDF.GetPageHeight"; $pdf) ]
                                                                              • Loop
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.EditPage"; $pdf; $PageNumber) ]
                                                                              • Set Variable [ $r; Value:MBS( "DynaPDF.SetFont"; $pdf; "Helvetica"; 0; 12) ]
                                                                              • 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) ]
                                                                              • Set Variable [ $PageNumber; Value:$PageNumber +1 ]
                                                                              • Exit Loop If [ $PageNumber > $PageCount ]
                                                                              • End Loop
                                                                              • #save PDF
                                                                              • Set Variable [ $PDFData; Value:MBS("DynaPDF.Save"; $pdf; "hello.pdf") ]
                                                                              • #Free all data
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.Release"; $table) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.Release"; $etable) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Table.Release"; $itable) ]
                                                                              • Set Variable [ $r; Value:MBS("DynaPDF.Release"; $pdf) ]
                                                                              • Set Variable [ $r; Value:MBS("QuickList.Free"; $Prices) ]
                                                                              • #Put in Container
                                                                              • Set Field [ Invoice::PDF Output; $PDFData ]
                                                                              • #Write to Desktop
                                                                              • Set Variable [ $path; Value:MBS( "Path.AddPathComponent"; MBS( "Folders.UserDesktop" ); Invoice::Invoice ID & ".pdf" ) ]
                                                                              • Set Variable [ $r; Value:MBS("Files.WriteFile"; $PDFData; $path) ]
                                                                              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

                                                                                Custom Functions

                                                                                Function NameParametersAvailabilityDefinitionIn Field DefinitionsIn Scripts
                                                                                FormatNumbervalue;commaAll accountsLet( [ value = Round(value; 2); result = GetAsText(value); result = Case( (Left(result; 1) = comma) and (Length(result) = 2) ; "0" & result & "0"; (Left(result; 1) = comma) and (Length(result) = 3) ; "0" & result; Middle(result; Length(result)-2; 1) = comma ; result; Middle(result; Length(result)-1; 1) = comma ; result & "0"; Middle(result; Length(result); 1) = comma ; result & "00"; result & comma & "00") ]; result )

                                                                                  Custom Menu Sets

                                                                                  Menu SetsMenusIn ScriptsIn LayoutsComments
                                                                                  [Standard FileMaker Menus]
                                                                                  • All Standard Menus

                                                                                  Download example: Invoice

                                                                                  Used functions: