Platforms to show: All Mac Windows Linux Cross-Platform
/MacControls/NSPrintOperation HTMLViewer
Required plugins for this example: MBS MacBase Plugin, MBS Mac64bit Plugin, MBS Main Plugin, MBS MacCocoa Plugin, MBS MacControls Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/NSPrintOperation HTMLViewer
This example is the version from Sun, 5th Nov 2022.
Project "NSPrintOperation HTMLViewer.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control PageSetupButton Inherits PushButton
ControlInstance PageSetupButton Inherits PushButton
EventHandler Sub Action()
NSPageLayoutMBS.runPageLayout
End EventHandler
End Control
Control PrintDialogButton Inherits PushButton
ControlInstance PrintDialogButton Inherits PushButton
EventHandler Sub Action()
'PrintInfo.horizontalPagination = PrintInfo.NSAutoPagination
printinfo.verticalPagination = PrintInfo.NSAutoPagination
dim o as NSPrintOperationMBS = NSPrintOperationMBS.printOperationWithView(HTMLViewer1, PrintInfo)
o.showsPrintPanel = true
o.runOperationModalForWindow(Self)
o = nil
End EventHandler
End Control
Control PrintButton Inherits PushButton
ControlInstance PrintButton Inherits PushButton
EventHandler Sub Action()
dim o as NSPrintOperationMBS = NSPrintOperationMBS.printOperationWithView(HTMLViewer1)
o.showsPrintPanel = false
o.runOperationModalForWindow(Self)
o = nil
End EventHandler
End Control
Control PrintPDFButton Inherits PushButton
ControlInstance PrintPDFButton Inherits PushButton
EventHandler Sub Action()
dim f as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
Dim w As WKWebViewMBS = HTMLViewer1.WKWebViewMBS
Dim o As NSPrintOperationMBS = NSPrintOperationMBS.PDFOperationWithView(w, w.bounds, PrintInfo, f)
o.runOperationModalForWindow(Self)
o = Nil
f.launch
End EventHandler
End Control
Control HTMLViewer1 Inherits HTMLViewer
ControlInstance HTMLViewer1 Inherits HTMLViewer
EventHandler Sub Open()
me.LoadURL "http://www.mbs-plugins.de"
'me.LoadURL "file:///Users/cs/Desktop/test.html"
End EventHandler
End Control
EventHandler Sub Open()
if TargetCocoa then
PrintInfo = NSPrintInfoMBS.sharedPrintInfo
else
MsgBox "Please run as Cocoa Mac app."
end if
PrintInfo.HorizontallyCentered = false
PrintInfo.VerticallyCentered = false
PrintInfo.verticalPagination = PrintInfo.NSAutoPagination
End EventHandler
Property PrintInfo As NSPrintInfoMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project
The items on this page are in the following plugins: MBS MacControls Plugin.