Chapter 29. Printing

REALbasic printing is simple. You are presented, in essence, with a blank sheet, a plane of pixels in the form of a Graphics object, like the Graphics property of a Canvas or a Picture; whatever you draw into this will be sent to the printer. This means that, except for some minor details, you already know how to print! The commands for drawing into a Graphics object were presented in Section 11.3; drawing styled text from an EditField was described in Section 13.6. That’s essentially all there is to it. REALbasic doesn’t give you much assistance in transforming data into the actual pixels of the drawing; on the other hand, since you are in charge of every pixel, there isn’t much that you can’t do.

The minor details have to do mostly with your interactions with the user, and with the computer’s printer driver. You need to be able to present the user with the customary Page Setup and Print dialogs; and in order to position and scale page elements as you print, you need to know the dimensions and resolution of the page you’re printing to. That’s what the rest of this chapter is about.

Page Setup

Before printing, you should give the user the opportunity to interact with the Page Setup dialog. This is where the user typically gets to make settings such as the size and orientation of the page. It is also your chance to get hold of a properly configured instance of the PrinterSetup class; this is something you’ll want to have on hand as you proceed ...

Get REALBasic: TDG, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.