Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSPrintInfoMBS class.

NSPrintInfoMBS.Constructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Printing MBS MacCocoa Plugin 12.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initializes the print info with a new instance.
Example
// get Xojo printer setup
Var p as new PrinterSetup

// now put it into NSPrintInfo to manipulate
Var n as new NSPrintInfoMBS
n.SetupString = p.SetupString

// change destination to file
Var f as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
n.SetSaveDestination(f)

// move back
p.SetupString = n.SetupString

// and print as usual
Var g as Graphics = OpenPrinter(p)
g.DrawString "Hello World", 20, 20

See also:

NSPrintInfoMBS.Constructor(attributes as Dictionary)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Printing MBS MacCocoa Plugin 12.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initialize the print info with the parameters in the specified dictionary.

See also:

NSPrintInfoMBS.Constructor(Data as Memoryblock)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Printing MBS MacCocoa Plugin 14.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initialize the print info with serialized dictionary or NSPrintInfo.
Example
Var p as new PrinterSetup
Var info as new NSPrintInfoMBS(p.SetupString)
MsgBox info.paperName

See also:

NSPrintInfoMBS.copy as NSPrintInfoMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Printing MBS MacCocoa Plugin 12.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates a copy of the object.

NSPrintInfoMBS.objectForKey(key as String) as Variant   New in 25.3

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Printing MBS MacCocoa Plugin 25.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Get or set an entry in the underlaying dictionary.
Example
Var n As New NSPrintInfoMBS

Var d1 As Dictionary = n.Dictionary

// add a custom key
n.objectForKey("test") = 123

Var d2 As Dictionary = n.Dictionary

// and remove it
n.removeObjectForKey "test"

Var d3 As Dictionary = n.Dictionary

// inspect dictionaries in debugger
Break

(Read and Write computed property)

NSPrintInfoMBS.removeObjectForKey(key as String)   New in 25.3

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Printing MBS MacCocoa Plugin 25.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Removes an entry from the underlaying dictionary.
Example
Var n As New NSPrintInfoMBS

Var d1 As Dictionary = n.Dictionary

// add a custom key
n.objectForKey("test") = 123

Var d2 As Dictionary = n.Dictionary

// and remove it
n.removeObjectForKey "test"

Var d3 As Dictionary = n.Dictionary

// inspect dictionaries in debugger
Break

This allows you to remove settings.

NSPrintInfoMBS.SetSaveDestination(file as folderitem)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Printing MBS MacCocoa Plugin 14.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Sets the print job to go to a PDF file.
Example
// print to PDF in Xojo Cocoa app

// change print info to go to
Var s as NSPrintInfoMBS = NSPrintInfoMBS.sharedPrintInfo
Var d as MemoryBlock = s.data // save old
s.SetSaveDestination SpecialFolder.Desktop.Child("test.pdf")

// now print something
Var g as Graphics = OpenPrinter
if g<>Nil then
g.DrawString "Hello World PDF", 20, 20
end if


s.data = d // restore original settings

// now print something to regular printer
g = OpenPrinter
if g<>Nil then
g.DrawString "Hello World Printer", 20, 20
end if

Some examples using this method:

NSPrintInfoMBS.setUpPrintOperationDefaultValues

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Printing MBS MacCocoa Plugin 12.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Validates the attributes encapsulated by the receiver.

Invoked when the print operation is about to start. Subclasses may override this method to set default values for any attributes that are not set.

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


The biggest plugin in space...