dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] Postscript support in System.Drawing


From: Rhys Weatherley
Subject: [Pnet-developers] Postscript support in System.Drawing
Date: Sun, 20 Jul 2003 13:30:03 +1000
User-agent: KMail/1.4.3

Hi all,

I've started adding support for Postscript printing under Unix to the 
System.Drawing library.  Just like the Xsharp and Win32 toolkits, the 
Postscript code is also organised as a loadable toolkit assembly: 
System.Drawing.Postscript in this case.

Right now, it always prints to the file "output.ps" in the current directory, 
but this will change to piping into "lpr" when the "Process" class is fixed.

Most of the difficult stuff is now done, and it remains to implement the 
various drawing primitives, pens, brushes, fonts, etc.  Since Postscript is 
just text, it shouldn't be difficult for other people with a minimum amount 
of C# knowledge to help complete the implementation.  The Postscript 
reference manual can be found here:

    http://partners.adobe.com/asn/developer/pdfs/tn/psrefman.pdf

Attached is a small test program that prints two crossed lines.  To print 
other kinds of things, modify the "PrintPage" method to call other "Graphics" 
methods, just like you would if you were drawing to a window in x11-winforms.  
Behind the scenes, the drawing requests are processed by the 
"PostscriptGraphics" class.  Page setup is managed by the 
"PostscriptPrintSession" class, if you need to modify the prolog.

Cheers,

Rhys.

---------------------------------
using System;
using System.Drawing;
using System.Drawing.Printing;

public class Print
{
    private static void PrintPage(Object sender, PrintPageEventArgs e)
    {
        Pen pen = new Pen(Color.Black, 1.0f);
        e.Graphics.DrawLine(pen, 10, 10, 100, 100);
        e.Graphics.DrawLine(pen, 100, 10, 10, 100);
        pen.Dispose();
    }

    public static void Main()
    {
        PrintDocument doc = new PrintDocument();
        doc.PrintPage += new PrintPageEventHandler(PrintPage);
        doc.Print();
    }
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]