[logo] JX Application Framework
   
Home     
* Cart

Introduction

Why use a framework?

Tutorial
    Class tree

    Open protocols

Download

GitHub

Vision
    API stability

    Code optimization

    Bibliography

Features
    Object messaging

    Extensibility

    Drag-and-Drop

    Networking

    3D Graphics

    Powerful tables

    Styled text editor

    Memory leak debugger

    Known bugs

    Future plans
    Projects

FAQ

Donate

Other software

What's new!

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 © 2012 New Planet Software