« Two weeks with Xojo 2… | Home | MonkeyBread Software … »

Tip fo the day: Print to PDF for WebView

If you like to print a HTMLViewer in Xojo 2020r1 and you look for a replacement to PrintToPDFFileMBS function, you can use this code with NSPrintOperationMBS and WKWebViewMBS:

Dim browser As WKWebViewMBS = browser.WKWebView // your web viewer Dim pi As NSPrintInfoMBS = NSPrintInfoMBS.sharedPrintInfo Dim po As NSPrintOperationMBS = browser.printOperation(pi) Dim file As FolderItem = SpecialFolder.Desktop.Child("test.pdf") pi.SetSaveDestination(file) pi.horizontalPagination = pi.NSAutoPagination pi.verticalPagination = pi.NSAutoPagination po.showsPrintPanel = False po.showsProgressPanel = True po.runOperationModalForWindow(Self)

This prints to a file as destination and asks for auto pagination of the pages. We disable print panel, but show a progress panel.

The biggest plugin in space...
15 09 20 - 08:39