MBS FileMaker Plugin Example Databases

Place Picture

All examples are included with download of MBS FileMaker Plugin.

Place Picture.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts2
Value Lists1
Custom Functions0
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
Place Picture
6 fields defined, 1 record
Place Picture

Fields

Table Name: Place Picture - 6 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
TitleNormal, TextAuto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Repetitions: 1
  • Indexing: None
  • Automatically create indexes as needed
  • Index Language: German
      SizeNormal, TextAuto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1
      • Indexing: None
      • Automatically create indexes as needed
      • Index Language: German
          CommentNormal, TextAuto-Enter:
          • Allow editing
          Validation:
          • Only during data entry
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German
              ImageNormal, BinaryAuto-Enter:
              • Allow editing
              Validation:
              • Only during data entry
              Storage:
              • Repetitions: 1
                  PDFNormal, BinaryAuto-Enter:
                  • Allow editing
                  Validation:
                  • Only during data entry
                  Storage:
                  • Repetitions: 1
                      PositionNormal, TextAuto-Enter:
                      • Allow editing
                      Validation:
                      • Only during data entry
                      • Value list: Positions
                      Storage:
                      • Repetitions: 1
                      • Indexing: None
                      • Automatically create indexes as needed
                      • Index Language: German

                          Layout Objects: Place Picture

                          Regular Fields

                          Field Name: Place Picture::Title
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 68 pt
                          • Left: 69 pt
                          • Bottom: 89 pt
                          • Right: 322 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: Place Picture::Size
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 91 pt
                          • Left: 69 pt
                          • Bottom: 112 pt
                          • Right: 322 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: Place Picture::Comment
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 114 pt
                          • Left: 69 pt
                          • Bottom: 255 pt
                          • Right: 322 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: Place Picture::Image
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 68 pt
                          • Left: 350 pt
                          • Bottom: 525 pt
                          • Right: 1007 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: Place Picture::PDF
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 325 pt
                          • Left: 69 pt
                          • Bottom: 525 pt
                          • Right: 322 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: Place Picture::Position
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 263 pt
                          • Left: 69 pt
                          • Bottom: 284 pt
                          • Right: 322 pt
                          • Anchoring: Left, Top
                          Field Format: Field Behavior:
                          • Allow field to be entered: In Find mode, In Browse mode
                          • Touch keyboard type: Default for Data Type
                          • Go to next field using: Tab key
                          Yes

                          Buttons

                          Button PropertiesCoordinatesScript/Script Step
                            Type:
                          • Text: Create 2 Page PDF
                          • Top: 290 pt
                          • Left: 69 pt
                          • Bottom: 319 pt
                          • Right: 281 pt
                          • Anchoring: Left, Top
                          Perform Script [ “Create PDF” ]

                          Scripts:


                          Value Lists

                          Value List NameSourceValuesOn Layouts
                          PositionsCustom
                          • Wide Image Right Aligned, Wide Image Left Aligned

                          Script Hierarchy

                          Create PDF
                          InitDynaPDF

                          Next Script: [InitDynaPDF]
                          Script NameCreate PDF
                          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") = 0 ]
                            • Perform Script [ “InitDynaPDF” ]
                            • End If
                            • Set Variable [ $r; Value:MBS("Trace"; "/Users/cs/Desktop/debug.log") ]
                            • #Clear current PDF document
                            • Set Variable [ $pdf; Value:MBS("DynaPDF.New") ]
                            • #read image size
                            • Set Variable [ $r; Value:MBS("DynaPDF.ReadImageFormat"; $pdf; Place Picture::Image) ]
                            • Set Variable [ $ImageWidth; Value:GetAsNumber (LeftValues ( $r ; 1 )) ]
                            • Set Variable [ $imageHeight; Value:GetAsNumber (MiddleValues ( $r ; 2; 1 )) ]
                            • #no recompression! we use JPEG pass through
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetSaveNewImageFormat"; $pdf; 0) ]
                            • Set Variable [ $r; Value:MBS( "DynaPDF.SetGStateFlags"; $pdf; "UseImageColorSpace" ) ]
                            • #Our page size is 30 cm on each size and 8 point crop offset
                            • Set Variable [ $cx; Value:8 ]
                            • Set Variable [ $cy; Value:8 ]
                            • Set Variable [ $pw; Value:Round(30 / 2,54 * 72;0) // 30 cm ]
                            • Set Variable [ $ph; Value:$pw ]
                            • #Calculate image size
                            • Set Variable [ $h; Value:$ph+2 ]
                            • Set Variable [ $w; Value:Round($ImageWidth / $ImageHeight * $h; 0) ]
                            • Set Variable [ $x; Value:$pw * 2/3 ]
                            • Set Variable [ $y; Value:-1 ]
                            • Set Variable [ $tx; Value:70 ]
                            • Set Variable [ $tw; Value:$x - $tx -30 ]
                            • Set Variable [ $TextOnPage; Value:1 ]
                            • #Check position
                            • Set Variable [ $pos; Value:Place Picture::Position ]
                            • If [ $pos = "Wide Image Left Aligned" ]
                            • Set Variable [ $TextOnPage; Value:2 ]
                            • Set Variable [ $x; Value:-1 ]
                            • Set Variable [ $tx; Value:$w - $pw + 30 ]
                            • Set Variable [ $tw; Value:$pw - $tx - 70 ]
                            • End If
                            • #Change page size to 30 cm by 30 cm
                            • Set Variable [ $h; Value:MBS("DynaPDF.SetPageWidth"; $pdf; $pw + $cx*2) ]
                            • Set Variable [ $h; Value:MBS("DynaPDF.SetPageHeight"; $pdf; $ph + $cy*2) ]
                            • #Add page
                            • Set Variable [ $r; Value:MBS("DynaPDF.AppendPage"; $pdf) ]
                            • #Coordinates from top left
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetPageCoords"; $pdf; "topdown") ]
                            • If [ $TextOnPage = 1 ]
                            • #Load a font
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetFont"; $pdf; "Helvetica"; 0; 14) ]
                            • #Set black color (we are in RGB)
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetFillColor"; $pdf; 0; 0; 0) ]
                            • #Define where our text will go
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetTextRect"; $pdf; $cx+$tx; /* pos x */ $cy+70; /* pos y */ $tw; /* width of text rect */ -1) ]
                            • #Write text with formatting commands inside in text rectangle with left alignment
                            • Set Variable [ $r; Value:MBS("DynaPDF.WriteFText"; $pdf; "left"; Place Picture::Title & ¶ & ¶ & "\FT[Helvetica-Bold]Size:\FT[Helvetica]" & ¶ & Place Picture::Size & ¶ & ¶ & "\FT[Helvetica-Bold]Comment:\FT[Helvetica]" & ¶ & Place Picture::Comment) ]
                            • End If
                            • #Place image
                            • Set Variable [ $r; Value:MBS("DynaPDF.InsertImage"; $pdf; Place Picture::Image; $cx+$x; $cy+$y; $w; $h) ]
                            • #Set media and crop box to hide the area we like to crop later after print
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetBBox"; $pdf; "media"; 0; 0; $pw + $cx * 2; $ph+$cy*2) ]
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetBBox"; $pdf; "crop"; $cx; $cy; $pw + $cx; $ph + $cy) ]
                            • #Draw a red rectangle outside the visible area
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetStrokeColor"; $pdf; 1; 0; 0) ]
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetLineWidth"; $pdf; 1) ]
                            • Set Variable [ $r; Value:MBS("DynaPDF.Rectangle"; $pdf; $cx - 1; $cy - 1; $pw+2; $ph+2; "stroke") ]
                            • #Close page and start next one
                            • Set Variable [ $r; Value:MBS("DynaPDF.EndPage"; $pdf) ]
                            • Set Variable [ $r; Value:MBS("DynaPDF.AppendPage"; $pdf) ]
                            • If [ $TextOnPage = 2 ]
                            • #Load a font
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetFont"; $pdf; "Helvetica"; 0; 14) ]
                            • #Set black color (we are in RGB)
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetFillColor"; $pdf; 0; 0; 0) ]
                            • #Define where our text will go
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetTextRect"; $pdf; $cx+$tx; /* pos x */ $cy+70; /* pos y */ $tw; /* width of text rect */ -1) ]
                            • #Write text with formatting commands inside in text rectangle with left alignment
                            • Set Variable [ $r; Value:MBS("DynaPDF.WriteFText"; $pdf; "left"; Place Picture::Title & ¶ & ¶ & "\FT[Helvetica-Bold]Size:\FT[Helvetica]" & ¶ & Place Picture::Size & ¶ & ¶ & "\FT[Helvetica-Bold]Comment:\FT[Helvetica]" & ¶ & Place Picture::Comment) ]
                            • End If
                            • #The image is placed again, but more to left to fit
                            • Set Variable [ $x; Value:$x - $pw // move 30 cm left ]
                            • #Place image again
                            • Set Variable [ $r; Value:MBS("DynaPDF.InsertImage"; $pdf; Place Picture::Image; $cx+$x; $cy+$y; $w; $h) ]
                            • #Set bounding boxes
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetBBox"; $pdf; "media"; 0; 0; $pw + $cx * 2; $ph+$cy*2) ]
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetBBox"; $pdf; "crop"; $cx; $cy; $pw + $cx; $ph + $cy) ]
                            • #Draw crop rectangle
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetLineWidth"; $pdf; 1) ]
                            • Set Variable [ $r; Value:MBS("DynaPDF.SetStrokeColor"; $pdf; 1; 0; 0) ]
                            • Set Variable [ $r; Value:MBS("DynaPDF.Rectangle"; $pdf; $cx - 1; $cy - 1; $pw+2; $ph+2; "stroke") ]
                            • #End page
                            • Set Variable [ $r; Value:MBS("DynaPDF.EndPage"; $pdf) ]
                            • #Load PDF from container
                            • Set Field [ Place Picture::PDF; MBS("DynaPDF.Save"; $pdf; "Merged.pdf") ]
                            • Set Variable [ $r; Value:MBS("DynaPDF.Release"; $pdf) ]
                            • Set Variable [ $r; Value:MBS("Container.WriteFile"; Place Picture::PDF; "/Users/cs/Desktop/output.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: [Create PDF]
                                  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
                                    • 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" ) ]
                                    • Else
                                    • Set Variable [ $path; Value:Substitute ( $databasePath ; $databaseName ; "dynapdf.dylib" ) ]
                                    • End If
                                    • #Initialize DynaPDF
                                    • Set Variable [ $r; Value:MBS( "DynaPDF.Initialize"; $path) ]
                                    • Set Variable [ $$DynaPDFInited; Value:1 ]
                                    • If [ $r ≠ "OK" ]
                                    • Show Custom Dialog [ Title: "DynaPDF failed to initialize"; Message: $r; Default Button: “OK”, Commit: “No”; Button 2: “Abbrechen”, Commit: “No” ]
                                    • 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

                                                  Download example: Place Picture

                                                  Used functions:




                                                  Links
                                                  MBS FileMaker tutorial videos