Quick start

When you use Printing services, you work with pages, folios, printers, print jobs, and print job descriptions:

In its simplest form, printing in the CommonPoint application system requires three objects: a folio, a printer, and a print job description. To print a folio:

  1. The calling function passes you a printer.
  2. Create a print job description.
  3. Print your folio through the print job.
The following simple example shows how to write a short program that sends output to the printer. This example explicitly uses the print channel, which transports the print job to the appropriate printer.

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:

  1. Create the printer that you will use for printing.
  2. Create a print job description.
  3. Instantiate a print channel and start the job.
  4. Print the page(s).
  5. End the job.
    You must end the job for the document or pages to print.
Here is the entire sample program to print a graphic on a page.

      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;
      }
This example prints a circle on a single sheet of paper on the system printer as shown in Figure 79.


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
physical page.

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:

          TEllipse    page1(TGPoint(200,200),175);
    

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker