I want to print a specific NSView. When I do this, I wish to add content to the header of the print page.
e.g. If the NSView contains a picture of a cat, when I press print, print preview shows up with the picture of the cat. I want the print out to be a picture of a cat, with the caption: “Cat” in the header, which I do not want visible on the original NSView.
Also, if this is possible, is it also possible to add images too?
Thanks!
You can overwrite the method
- (NSAttributedString *)pageHeaderin yourNSViewsubclass. See Apple’s documentation here.Note that headers are generated only if the user defaults contain the key
NSPrintHeaderAndFooterwith the value YES.As for images, those can be added to a
NSAttributedStringusing aNSTextAttachment.