« MBS Xojo Plugins, ver… | Home | Upload lots of record… »

News from the MBS Xojo Plugin version 26.4

In this article I want to introduce you the new functionalities from the MBS Xojo Plugins in version 26.4.

DynaPDF

There are also several new features in the DynaPDF area. Using the HaveOpenPath property from the DynaPDFMBS class, we can check whether there is an open path in memory that has not yet been consumed by a ClosePath or ClipPath function call. To discard the path, you can call the new AbortPath method from the same class.

We also have new features related to vector graphics. For example, you can insert your company logo if it is available as an SVG file in an PDF. Using the LoadSVG method, you can load an existing SVG either as a folder item or via a path provided as a string. If you have the SVG available as a memory block or as a data string, please use LoadSVGFromBuffer. All of these methods return an instance of the new DynaPDFSVGMBS class. An SVG file can consist of multiple embedded SVG graphics. You can retrieve the number of these using the SymbolCount property of the instance. The SymbolName and SymbolNames methods return the names of the SVG symbols.

Using the InsertSVG method from the DynaPDFMBS class, you can then place and scale the graphic in your PDF. The function uses a native SVG-to-PDF converter that translates SVG graphics directly into PDF drawing operations and resources. Vector graphics remain vector-based whenever possible, preserving their scalability and rendering quality.

Var pdf As New DynaPDFMBS
Call pdf.CreateNewPDF

// load a SVG
var file as FolderItem = SpecialFolder.Desktop.Child("dinosaur.svg")
Var svg As DynaPDFSVGMBS = pdf.LoadSVG(file)

// add page and place SVG
Call pdf.Append
Call pdf.InsertSVG(svg, 50, 50, 500, 500)
Call pdf.EndPage

// save it
Call pdf.OpenOutputFile(SpecialFolder.Desktop.Child("dinosaur.pdf"))
Call pdf.CloseFile

MongoDB

We've added a new class, MongoBulkOperationMBS. This allows us to perform bulk operations on a MongoDB database. Bulk operations modify multiple records simultaneously. This results in significant time savings and improved performance, especially when dealing with large amounts of data. First, you can create an object of this class and then call the various methods to modify the data in the database. The methods available for this are Insert, RemoveMany, RemoveOne, ReplaceOne, UpdateMany, and UpdateOne. The Execute method executes all operations queued in the bulk operation. You can combine this with a transaction to roll back in case of an error.

Phidgets

The new PhidgetDataAdapterMBS class allows you to interface third-party devices and microcontrollers with Phidgets. This class provides various properties that you can use to read information from the device as well as set values. For example, you can configure the number of data bits used for communication or the frequency at which data is transmitted. The methods offer various communication options to choose from; for example, you can use both synchronous and asynchronous communication. This new class opens up many new possibilities for you, so feel free to take a look.

Llama

In the Llama section, with which you can run a Local Language Model, we have a few new features for you. With the new Text method from the LlamaVocabMBS class, you can retrieve the text associated with a token that you specify in the parameters of this method. In the example you'll see here, 100 tokens are read in a loop and assembled into a text.

Var vocab As LlamaVocabMBS = model.Vocab

var words() as string
For i As Integer = 30000 To 30100
  words.Add vocab.Text(i)
Next
Var List As String = Join(words, ", ")
break 

Using the FType property from the LlamaModelMBS class, we can retrieve the type of the model. The return value is an integer; to convert this into a human-readable string, feel free to use the shared method FTypeName from the LlamaModelQuantizeParametersMBS class, which returns the name of the FType associated with the integer. It can also be useful to retrieve the version number of the Llama library. To do this, use the Version property from the LlamaMBS class.

Llama chat example showing what the LLM knows about Xojo.

PCRE

Let's now turn to the topic of regular expressions. PCRE2 includes several performance optimizations that are applied to make searches more efficient. By default, all of these optimizations are enabled. However, there are rare cases where these optimizations are not welcome. With the new SetOptimize method from the PCRE2CompilerMBS class, you now have the option to decide whether you want to enable all optimizations, no optimizations, or only specific optimizations. This gives you the freedom to decide for yourself which optimizations to use.

In addition, there are a few new properties for this class. For example, you can use CaselessRestrict to enable or disable mixed ASCII/non-ASCII case folding, or use EffectiveLinksize to specify how many bytes are used for the link size.You'll find these and a few other features in this release.

PKCS 12

There is also a new method in the Encryption and Hash section. You can now write a PKCS#12 file. To do this, use the WriteToPkcs12 method from the X509MBS class. In this method, you can specify all the necessary information in the parameters and will then receive the PKCS#12 file as a string.

Var file As FolderItem = SpecialFolder.Desktop.Child("signer.p12")
Var bstream As BinaryStream = BinaryStream.Open(file)
Var bdata As String = bstream.Read(bstream.Length)
Var cert As X509MBS
Var pKey As PKeyMBS
Var others() As X509MBS
var password as string = "12345"

If X509MBS.ReadFromPkcs12(bdata, password, pKey, cert, others) Then
  
  var output as string = X509MBS.WriteToPkcs12("Test Certificate", password, pKey, cert, others)
  Var newFile As FolderItem = SpecialFolder.Desktop.Child("other.p12")
  bstream = BinaryStream.Create(newFile, True)
  bstream.Write output
  bstream.Close
  
  Break // check result
End If

Barcodes

When reading barcodes using the ZXing barcode scanning library, we welcome a new barcode type: Telepen, with its subtypes TelepenAlpha and TelepenNumeric.

Alpha Channel for TIFF and PNG

In every release, we also include small helper functions that may seem almost insignificant at first glance but might be exactly the tool some readers need right now. Perhaps this also applies to the two properties I'd like to introduce to you now. First, there's the HasAlpha property from the PNGReaderMBS class, which indicates whether the PNG image has an alpha channel. The other property has the same name but comes from the TiffPictureMBS class and performs this task for TIFF images.

var f as FolderItem = SpecialFolder.Desktop.Child("test alpha.tif")
Var t As New TiffPictureMBS

If t.Open(f) Then
  
  MessageBox "Has alpha: "+t.HasAlpha.ToString
  
End If

New functionalities for Mac

The MBS Xojo Plugins in version 26.4 offers some more new features for Mac users.

Google MobileAd

We have upgraded the classes for the Google MobileAd framework for iOS.The new framework introduces new loadWithAdResponseString methods in the classes GADBannerViewMBS, GADInterstitialAdMBS, GADRewardedAdMBS, and GADRewardedInterstitialAdMBS. These methods load the corresponding ad. When loading is complete, the loadCompleted event is triggered. A property placementID has also been added to each of these classes. This property serves as an identifier for a placement in reporting.

In the GADBannerViewMBS class, we have also added the Collapsible property, which indicates whether the last loaded ad is a collapsible banner.

AV Audio

This release also includes a few interesting properties for the AV Audio area. These new properties can be found in the AVAudioUnitMBS class. First, we can query the fullState. This is, for example, a dictionary containing information about preferences provided by the Audio Unit's developer. You can retrieve the dictionary using fullState, and with fullStateJSON, you can get the entire dictionary as JSON.

In addition, we can retrieve the full state for a document using the fullStateForDocument and fullStateForDocumentJSON properties. It is a persistable snapshot of the audio unit's properties and parameters that are suitable for saving in a user's document. These properties are distinct from fullState in that some state is suitable for saving in user presets, while other state is not. For example, a synthesizer's master tuning setting could be considered global, inappropriate for storing in reusable presets, but desirable for storing in a document for a specific live performance.

Lossless CGI Copy

The new CopyImageSource method from the CGImageDestinationMBS class losslessly copies the contents of the image source to the destination. The image data will not be modified. The image's metadata can be modified by adding keys and values to the parameters.

New functionalities for Windows

Last but not least we offer new features for Windows users

Extract the Icon

Using the new ExtractIconMBS method from the FolderItem class, you can extract an icon from a DLL or EXE file. The method returns a picture object that you can process as needed.

Var file As FolderItem = SpecialFolder.System.Child("imageres.dll")

If file.Exists Then
  Const id = 3
  Me.Backdrop = file.ExtractIconMBS(512, id)
Else
  Break // file missing
End If

WebView

We also have new features in the WebView2 area. We have added a new method, PrintToPdf, to each of the classes DesktopWebView2ControlMBS, WebView2ControlMBS, and WebView2BrowserMBS. This method prints a page to a PDF document. You can define the file where the PDF is saved, as well as the printer settings, in the parameters. The method operates asynchronously. Once the PDF has been written to the corresponding file, the PrintCompleted event is triggered.

In addition, we've added new settings for the WebView. Using the DefaultBackgroundColor property from the WebView2BrowserMBS class, you can select a default background color. This means that wherever the webpage is transparent or no background color has been specified in the CSS settings, this color will be used as the background color when no other color is available.

We've also added the new ZoomFactor property, which allows you to set and retrieve the zoom factor.

We hope you will also find some interesting new features. We wish you a lot of fun with MBS Xojo Plugins version 26.4. If you have any Ideas for new cool features, need a license or have any questions, please contact us.

Translated with the help of AI.

20 10 26 - 07:53