MBS FileMaker Plugin Example Databases

OCR with DynaPDF

All examples are included with download of MBS FileMaker Plugin.

OCR with DynaPDF.fmp12

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

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
OCR
4 fields defined, 2 records
OCR

Fields

Table Name: OCR - 4 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
ImageNormal, BinaryAuto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Repetitions: 1
      ResultNormal, TextAuto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1
      • Indexing: None
      • Automatically create indexes as needed
      • Index Language: German
          TextNormal, TextAuto-Enter:
          • Allow editing
          Validation:
          • Only during data entry
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German
              PDFNormal, BinaryAuto-Enter:
              • Allow editing
              Validation:
              • Only during data entry
              Storage:
              • Repetitions: 1

                  Layout Objects: OCR

                  Regular Fields

                  Field Name: OCR::Image
                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                  • Top: 24 pt
                  • Left: 138 pt
                  • Bottom: 149 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: System Default
                  • Go to next field using: Tab key
                  No

                  Field Name: OCR::Result
                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                  • Top: 150 pt
                  • Left: 138 pt
                  • Bottom: 164 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: System Default
                  • Go to next field using: Tab key
                  Yes

                  Field Name: OCR::Text
                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                  • Top: 168 pt
                  • Left: 138 pt
                  • Bottom: 248 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: System Default
                  • Go to next field using: Tab key
                  Yes

                  Field Name: OCR::PDF
                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                  • Top: 24 pt
                  • Left: 600 pt
                  • Bottom: 251 pt
                  • Right: 937 pt
                  • Anchoring: Left, Top
                  Field Format:
                  • Edit Box
                  Field Behavior:
                  • Allow field to be entered: In Find mode, In Browse mode
                  • Touch keyboard type: System Default
                  • Go to next field using: Tab key
                  No

                  Group Buttons

                  Button PropertiesCoordinatesScript/Script Step
                    Type:
                  • Text: Make PDF
                    Additional Properties:
                  • Change to hand cursor over button
                  • Rectangular
                  • Top: 36 pt
                  • Left: 403 pt
                  • Bottom: 61 pt
                  • Right: 573 pt
                  • Anchoring: Left, Top
                  Perform Script [ “Run”; Parameter: 0 ]

                  Scripts:


                  Button PropertiesCoordinatesScript/Script Step
                    Type:
                  • Text: Make PDF with Text visible
                    Additional Properties:
                  • Change to hand cursor over button
                  • Rectangular
                  • Top: 72 pt
                  • Left: 403 pt
                  • Bottom: 97 pt
                  • Right: 573 pt
                  • Anchoring: Left, Top
                  Perform Script [ “Run”; Parameter: 1 ]

                  Scripts:


                  Script Hierarchy

                  Run
                  Trace
                  InitDynaPDF

                  Next Script: [Trace]
                  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
                    • #Initialize DynaPDF if needed
                    • If [ MBS("DynaPDF.IsInitialized") ≠ 1 ]
                    • Perform Script [ “InitDynaPDF” ]
                    • End If
                    • #Init OCR
                    • 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" ]
                    • Set Variable [ $path; Value:Substitute ( $databasePath ; $databaseName ; "" ) ]
                    • Set Variable [ $r; Value:MBS( "OCR.Initialize"; $path; "eng") ]
                    • Set Field [ OCR::Result; $r ]
                    • Set Variable [ $rr; Value:MBS( "OCR.SetPageSegMode"; "Auto") ]
                    • #Process Image
                    • Set Variable [ $img; Value:MBS("GMImage.NewFromContainer"; OCR::Image) ]
                    • Set Variable [ $r; Value:MBS( "OCR.SetImage"; $img) ]
                    • Set Field [ OCR::Text; MBS("OCR.GetText") ]
                    • #Clear current PDF document
                    • Set Variable [ $pdf; Value:MBS("DynaPDF.New") ]
                    • #Add page
                    • Set Variable [ $r; Value:MBS("DynaPDF.AppendPage"; $pdf) ]
                    • #Add Image
                    • Set Variable [ $r; Value:MBS("DynaPDF.ReadImageResolution"; $pdf; OCR::Image) ]
                    • Set Variable [ $resX; Value:GetAsNumber (LeftValues ( $r ; 1 )) ]
                    • Set Variable [ $resY; Value:GetAsNumber (MiddleValues ( $r ; 2; 1 )) ]
                    • If [ $resX <= 0 ]
                    • Set Variable [ $resX; Value:72 ]
                    • End If
                    • If [ $resY <= 0 ]
                    • Set Variable [ $resY; Value:72 ]
                    • End If
                    • Set Variable [ $r; Value:MBS("DynaPDF.ReadImageFormat"; $pdf; OCR::Image) ]
                    • Set Variable [ $ImageWidth; Value:GetAsNumber (LeftValues ( $r ; 1 )) ]
                    • Set Variable [ $imageHeight; Value:GetAsNumber (MiddleValues ( $r ; 2; 1 )) ]
                    • Set Variable [ $BitsPerPixel; Value:GetAsNumber (MiddleValues ( $r ;3; 1 )) ]
                    • #no recompression!
                    • Set Variable [ $r; Value:MBS("DynaPDF.SetSaveNewImageFormat"; $pdf; 0) ]
                    • Set Variable [ $x; Value:0 ]
                    • Set Variable [ $y; Value:0 ]
                    • Set Variable [ $w; Value:$ImageWidth * 72 / $ResX ]
                    • Set Variable [ $h; Value:$ImageHeight * 72 / $ResY ]
                    • Set Variable [ $r; Value:MBS("DynaPDF.SetPageHeight"; $pdf; $h) ]
                    • Set Variable [ $r; Value:MBS("DynaPDF.SetPageWidth"; $pdf; $w) ]
                    • Set Variable [ $r; Value:MBS("DynaPDF.InsertImage"; $pdf; OCR::Image; $x; $y; $w; $h) ]
                    • #Hide Text...
                    • If [ Get(ScriptParameter) = 0 ]
                    • Set Variable [ $r; Value:MBS("DynaPDF.SetAlpha"; $pdf; 0; 0) ]
                    • End If
                    • #Add Text
                    • Set Variable [ $r; Value:MBS("DynaPDF.SetFillColor"; $pdf; 1; 0; 0) ]
                    • Set Variable [ $r; Value:MBS("DynaPDF.SetFont"; $pdf; "Helvetica"; 0; 12) ]
                    • Set Variable [ $r; Value:MBS("OCR.WriteToPDF"; $pdf; $x; $y; $w; $h) ]
                    • #Show Text...
                    • If [ Get(ScriptParameter) = 0 ]
                    • Set Variable [ $r; Value:MBS("DynaPDF.SetAlpha"; $pdf; 0; 0) ]
                    • End If
                    • #End page
                    • Set Variable [ $r; Value:MBS("DynaPDF.EndPage"; $pdf) ]
                    • #Set title
                    • Set Variable [ $r; Value:MBS("DynaPDF.SetDocInfo"; $pdf; "Title"; "Test PDF") ]
                    • #Render one page as Picture
                    • Set Variable [ $PDFData; Value:MBS("DynaPDF.Save"; $pdf; "hello.pdf") ]
                    • Set Variable [ $r; Value:MBS("DynaPDF.Release"; $pdf) ]
                    • #Put in Container
                    • Set Field [ OCR::PDF; $PDFData ]
                    • #Cleanup
                    • Set Variable [ $r; Value:MBS( "OCR.CleanUp") ]
                    • Set Variable [ $r; Value:MBS( "GMImage.Destroy"; $img) ]
                    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: [Run]Next Script: [InitDynaPDF]
                          Script NameTrace
                          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 [ $Trace; Value:MBS("Trace") ]
                              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: [Trace]
                                            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
                                              • Set Variable [ $databasePath; Value:Get(FilePath) ]
                                              • Set Variable [ $databasePath; Value:MBS("Path.FilemakerPathToNativePath"; $databasePath) ]
                                              • Set Variable [ $databasePath; Value:Substitute ( $databasePath ; ".fp7" ; ".fmp12") ]
                                              • Set Variable [ $databasePath; Value:Substitute ( $databasePath ; "/OCR/" ; "/DynaPDF/") ]
                                              • Set Variable [ $databasePath; Value:Substitute ( $databasePath ; "\OCR\\" ; "\DynaPDF\\") ]
                                              • 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) ]
                                              • If [ $r ≠ "OK" ]
                                              • Show Custom Dialog [ Title: "DynaPDF failed to initialize"; Message: $r; Default Button: “OK”, Commit: “No”; Button 2: “Abbrechen”, Commit: “No” ]
                                              • Else
                                              • Set Variable [ $$DynaPDFInited; Value:1 ]
                                              • 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: OCR with DynaPDF

                                                            Used functions:




                                                            Links
                                                            MBS FileMaker Plugins