[logo] JX Application Framework
   
Home     
* Cart

Introduction

Why use a framework?

Download

Vision
    API stability

    Code optimization

    Bibliography

Features
    Object messaging

    Extensibility

    Drag-and-Drop

    Networking

    3D Graphics

    Powerful tables

    Styled text editor

    Memory leak debugger

    Tutorial
    Class tree

    Open protocols

    Known bugs

    Next release
    Future plans

    Projects

FAQ

Other software

Log in  

   
     

Printing

Printing to both PostScript and Encapsulated PostScript (EPS) files works exactly the same way as drawing to the screen.

All the Page Setup and Print Setup dialog windows are extensible so you can add extra features to your classes derived from JXPSPrinter, JXEPSPrinter, and JXPTPrinter. (As a suggestion, it is a good idea to provide "Print again" and possibly also "Print all" menu items in addition to the standard "Page setup" and "Print..." options.)

Here is what the code for PostScript printing looks like:

    // p is declared as a JPagePrinter&

    if (p.OpenDocument())
        {
        JBoolean done      = kFalse;
        JBoolean cancelled = kFalse;
        while (!done)
            {
            if (!p.NewPage())
                {
                cancelled = kTrue;
                break;
                }

            // your code -- call p.LockHeader() before returning

            DrawHeader(printer);

            // your code -- call p.LockFooter() before returning

            DrawFooter(printer);

            // your code -- get page number from p.GetPageInfo()

            done = DrawPage(p);
            }

        if (!cancelled)
            {
            p.CloseDocument();
            }
        }

Printing to an EPS file is even easier than printing to a PostScript file:

    // p is declared as JEPSPrinter&

    const JRect bounds = GetBoundsRect();

    if (p.ShouldPrintPreview())
        {
        JPainter& p1 = p.GetPreviewPainter(bounds);
        DrawStuff(p1);
        }

    if (p.OpenDocument(bounds))
        {
        DrawStuff(p);
        p.CloseDocument();
        }

Copyright © 2008 New Planet Software