News from the MBS Xojo Plugins Version 21.3
In this article I want to introduce you the new functionalities from the MBS Xojo Plugins in version 21.3.
OCR
I want to start with the new classes for OCR. With the TessEngineMBS class we can now use the newer Tesseract 4.x and 5.x versions. With the method Initialize we initialize tesseract. In the parameters we set the path to the tesseract library and the language we want to detect. With the shared method LibraryLoaded we then can test whether the library was initialized.
In the class we find some methods that allow us to recognize text.
The other new classes from this section will also help you with this. With the new version you can recognize multiple languages in the same text and pass a picture directly to the engine.
Dim OCR As new TessEngineMBS // your instance of tesseract
If Not ocr.Initialize("C:\Program Files\Tesseract-OCR\tessdata", "eng") Then
MsgBox "failed to initialize"
Quit
End If
Dim f As FolderItem = SpecialFolder.Desktop.Child("test.jpg")
Dim p As Picture = f.OpenAsPicture
OCR.SetImage(p)
// get the text
Dim OCRText As String = OCR.GetText
CURL
For CURL we added the support for pre-signed URLs. You can use our examples for Amazon S3 to upload files and then generate time limited URLs to access those files with AWSPresignURL. This method exists for the classes CURLMBS, CURLNMBS and CURLSMBS. In the parameters of this method we specify the access key for AWS, the secret access key, the used region, the used service, the path for the URL and the domain. Additionally, if needed, we can set the HTTP operation we want to perform, the time after which the request will be aborted, a list of parameters that are needed for the desired query, and an extra HTTP header.
An example call can look like this:
Dim URL As String = CURLMBS.AWSPresignURL( _
"AKIAIOSFODNN7EXAMPLE", _
"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", _
"us-east-1", _
"s3", _
"/test.txt", _
"examplebucket.s3.amazonaws.com", _
"GET", _
86400 )
This functionality also works for other compatible S3 services beside Amazon's like the one from Wasabi or Dell ECS.
We also have some new properties for this classes. With the OptionCAInfoBlob property we sets CAInfo as a blob value. We pass information about a memory block with binary data of PEM encoded content holding one or more certificates to verify the HTTPS server with.
The OptionProxyCAInfoBlob property sets the CAInfo for the HTTPS proxy.
The new gsaslVersion Property holds the version string of the GNU SASL Library version.
SatSolver from Lingune
Since a while we have the class LGLMBS in our MBS Xojo Tools Plugin for Xojo. This class is for the SAT solver from lingeling, which solves the satisfiability problem. We have added some new methods this version which allow you to pass data to threads. So that you can realize several operations in parallel. The work is performed on a preemptive thread, so this functionality does not block the application and can yield time to other Xojo threads. It must be called in a Xojo thread to enjoy the benefits.
To calculate the system with the help of threads we have then the appropriate method SatMT.
Dyna PDF
There are also innovations in the DynaPDF area. With the new methods DeleteNamedDest and DeleteNamedDestByIndex from the DynaPDFMBS class you can delete previously defined namespaces. In the parameters of this methods you define the namespace by name or by index. If you specify an empty string or an index < 0, all namespaces will be removed from the document.
With the latest version you can also rename Optional Content Groups (OCG). The ChangeOCGName method from DynaPDFMBS Class is available for this purpose. In the parameters, first enter the OCG handle reference number and then the new name of the OCG.
Barcodes
Until now we could read barcodes with the plugin only with the zxing library. This is built-in the plugin and does not need to be loaded. With the new class ZBarMBS you can now also use the library zBar to read your barcodes. We have to load the appropriate library first. You can also download the library on our website. You can load this library with LoadLibrary. With the method LibraryLoaded you can check if the library was loaded. As return you get a boolean value. With the property Version you can then query the version.
Call ZBarMBS.LoadLibrary "/Users/sj/Desktop/libzbar.0.dylib"
Dim loaded As Boolean= ZBarMBS.LibraryLoaded
Dim version As String= ZBarMBS.Version
Use the Scan method to read the information from the barcode.
Dim f As New FolderItem("/Users/sj/Desktop/test.png")
Dim p As Picture = Picture.Open(f)
If p <> Nil Then
// scan it
Dim symbols() As ZBarMBS = ZBarMBS.Scan(p)
// show results
For Each symbol As ZBarMBS In symbols
MsgBox symbol.Name+": "+symbol.Text
Next
End If
There is also the new method OuterBorder from the DynaPDF area from the DynaPDFBarcode2MBS class. This method optionally draws a border around the barcode. The width of the border is determined by the size difference between the scaled barcode and the size of the object of the DynaPDFRectMBS class that is passed in the parameters.
New functionalities for Mac and iOS users
The MBS Xojo Plugins in version 21.3 offers some more new features for Mac and iOS users
Barcodes in Vision
The Vision Framework can also recognize barcodes. The types of barcodes have now been extended by the following types:
- Codabar
- GS1 DataBar
- GS1 DataBar Expanded
- GS1 DataBar Limited
- MicroPDF417
- MicroQR
MapKit
The MapKit integration got new classes for multi polygons and poly lines.
You can now draw multiple polygons into your map. To do this, you pass, for example, an array of several polygon objects (MKPolygonMBS) to the constructor of class MKMultiPolygonMBS. The object of this class, that can contain multiple polygons that should be drawn in the same style, is then passed to the MKMultiPolygonRendererMBS class. Here the polygons are then displayed in the map. This works similarly for poly lines. Here we can render multiple line paths into one map. The individual polylines are passed as an array of MKPolylineMBS objects to the constructor of the MKMultiPolylineMBS class. This new object can then pass to the constructor of the MKMultiPolylineRendererMBS class. It renders the poly lines on the map.
CollectionView
For our collection view, which we introduced earlier this year, we now have the new class NSCollectionViewSectionHeaderViewMBS. With this class we define a button to control the collapse of a collection view’s section. A collection view can support a section that can collapse into a single horizontally scrollable row, similar to the groupings in the icon view in Finder. To ensure that the collection view can communicate with the button that controls the collapsing of a section, the section header view object connects to the button via sectionCollapseButton property. The new method toggleSectionCollapse collapses the section in which the sender resides into a single horizontally scrollable row.
We have added a lot of new events for the NSCollectionViewControlMBS class that deal with the appearance of the collection view. So for example the event insetForSectionAtIndex asks you for the margins to apply to content in the specified section. We implement it when we want to provide margins for sections in the flow layout. Our implementation can return the same margins for all sections or it can return different margins for different sections. We can also adjust the margins of each section dynamically each time that we update the layout.
CloudKit
Also in this version we want to extend cloud sharing. For this reason we have added the shared method NSSharingServiceNameCloudSharing to the class NSSharingServiceMBS which is used for sharing content on iOS X to simplify cloud sharing in your applications.
Sharing object can now also be defined by a specified record zone in your database. A shared record zone must have the CKRecordZoneCapabilityZoneWideSharing capability. Custom record zones that you create in the user’s private database have this capability by default. A record zone, and the records it contains, can take part in only a single share. After accepting a share invite, CloudKit adds the records of the shared record zone to a new zone in the participant’s shared database.
Appropriately, there is the new method registerCloudKitShare from the class CKContainerMBS which registers a CloudKit share for the user to modify. We use this method when the CloudKit share already exists on the server and we want to update it. The behavior of the sharing service depends on the role of the current user. An owner can edit the share’s configuration, which includes managing participants and their permissions. A participant can view the share’s configuration and choose to stop participating.
The new registerCloudKitShareWithPreparationHandler method registers a handler that prepares a new CloudKit share. We use this method to share a hierarchy of CloudKit records with other iCloud users. This method calls the new event registerCloudKitShareWithPreparationHandler.
New information about your Mac
Also new in macOS we have the new isMonterey method for SystemInformationMBS to detect the upcoming macOS version. The isLowPowerModeEnabled property in NSProcessInfoMBS lets you detect low power mode.
New Chromium Browser functionalities for Windows users
Last but not least I want to introduce the new Chromium Browser functionalities for Windows users.
The same-origin policy restricts how scripts, hosted from different origins (scheme + domain + port), can communicate. By default, scripts can only access resources with the same origin. Scripts hosted on the HTTP and HTTPS schemes (but no other schemes) can use the "Access-Control-Allow-Origin" header to allow cross-origin requests. For example, https://source.example.com can make XMLHttpRequest requests on http://target.example.com if the http://target.example.com request returns an "Access-Control-Allow-Origin: https://source.example.com" response header.
The new method AddCrossOriginWhitelist from the class ChromiumBrowserMBS add an entry to this cross-origin access whitelist. The method RemoveCrossOriginWhitelist removes an entry from this whitelist and ClearCrossOriginWhitelist remove all entries from the list.
We hope you will also find some interesting new features. We wish you a lot of fun with MBS Xojo Plugins version 21.3. If you need a license or have any questions, please contact us.