Generally, you will not interact with the print channel because the system provides Desktop framework objects that provide robust printing services for CommonPoint documents. However, you need to use the print channel if you want to print individual pages you have explicitly created.
The print channel captures the individual pages of a print job as MGraphics.
NOTE Currently, you must construct the printer before you can use it. Future releases of the system will provide TPrinter objects.
To use the print channel to print a page:
Here is the entire sample program to print a graphic on a page.
You must end the job for the document or pages to print.
This example prints a circle on a single sheet of paper on the system printer as shown in Figure 79. Copyright (C) 1994 Taligent, Inc. All rights reserved.
File: LowLevelPrinting.C
#ifndef Taligent_PRINT
#include <Taligent/Print.h>
#endif
#ifndef Taligent_MEMORYHEAP
#include <Taligent/MemoryHeap.h>
#endif
int main(int argc, char* argv[])
{
void* heap = TMemoryHeap::GetDefaultHeap(); // a heap to work with
// 1. Create a printer (Required in this interim release
TPrinter printer(TPrinter::kSystemPrinter);
// 2. Create a page description to use. This example uses the default description
TDeleterFor<TPageDescription>
pageDescription = printer.CreateDefaultPageDescription();
// Create a print job description to use. This example uses the default description
TGenericClientJobDescription* clientPart = new (heap) TGenericClientJobDescription;
TPrintJobDescriptionjob(printer.CreateJobDescription(),clientPart);
// Simple graphics serve as pages. Anything that's MDrawable will work.
TEllipse page1(TGPoint(200,150),175);
// Now do the actual printing
3. // Instantiate the print channel
TPrintChannelchannel;
channel.BeginJob(job);
4. // Print the page
channel.PrintPage(page1,*pageDescription);
5. // You must end the job for the page to print.
channel.EndJob();
return 0;
}
In this example, the circle is clipped on the left side. The clipping occurs because the graphics coordinates are independent of the default printable area of the page. The origin (0,0) for the page is always the upper-left corner of the
The simplest way to get the entire circle to print would be to change the location or diameter of the circle so that the entire circle appears in the printable area of the page. For example, the following line would move the center of the circle to the right enough for the entire circle to print:
physical page.
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.