Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/Printing/NSPrintOperation
Function:
Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/Printing/NSPrintOperation
This example is the version from Fri, 12th Dec 2013.
Project "NSPrintOperation.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control TextArea1 Inherits TextArea
ControlInstance TextArea1 Inherits TextArea
EventHandler Sub Open() me.TextFont = "Helvetica" me.TextSize = 14 me.AppendText "Hello World" me.AppendText EndOfLine me.AppendText EndOfLine me.AppendText "Just a test." me.AppendText EndOfLine End EventHandler
End Control
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() dim v as NSViewMBS = TextArea1.NSViewMBS dim o as NSPrintOperationMBS = NSPrintOperationMBS.printOperationWithView(v) o.showsPrintPanel = true o.runOperationModalForWindow(Self) o = nil End EventHandler
End Control
Control PrintButton Inherits PushButton
ControlInstance PrintButton Inherits PushButton
EventHandler Sub Action() dim v as NSViewMBS = TextArea1.NSViewMBS dim o as NSPrintOperationMBS = NSPrintOperationMBS.printOperationWithView(v) 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 v as NSViewMBS = TextArea1.NSViewMBS dim o as NSPrintOperationMBS = NSPrintOperationMBS.PDFOperationWithView(v, v.bounds, PrintInfo, f) o.runOperationModalForWindow(Self) o = nil f.launch 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

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacCocoa Plugin.





Links
MBS Xojo blog