Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Printing Dialect

 [1/5] from: AJMartin:orcon at: 2-Oct-2003 22:55


Here's the start of my C# code for printing a report (Scribe). /* Name: Scribe Title: "Scribe" File: %Scribe.cs Purpose: "A C# printing interface for Rebol." Author: "Andrew Martin" Date: 2/October/2003 Version: 0.2.1 */ using System; using System.Windows.Forms; using System.Drawing; using System.Drawing.Printing; public class Scribe : Object { private static void pd_PrintPage (object sender, PrintPageEventArgs e) { Graphics g = e.Graphics; String sMessage = Environment.UserName; Font fMessage = new Font ("Arial", 24, GraphicsUnit.Point); g.DrawString (sMessage, fMessage, Brushes.Black, 100, 100); Font fHeader = new Font ("Arial", 12, GraphicsUnit.Point); Brush bHeader = Brushes.Black; Pen pHeader = new Pen (Color.Black, 1); Rectangle rHeader = new Rectangle (0, 200, 120, 50); g.DrawString ("Subject & Teacher", fHeader, bHeader, rHeader); g.DrawRectangle (pHeader, rHeader); rHeader.X += rHeader.Width; g.DrawString ("Attendance (14)", fHeader, bHeader, rHeader); g.DrawRectangle (pHeader, rHeader); rHeader.X += rHeader.Width; g.DrawString ("Equipment (7)", fHeader, bHeader, rHeader); g.DrawRectangle (pHeader, rHeader); rHeader.X += rHeader.Width; g.DrawString ("Work (10)", fHeader, bHeader, rHeader); g.DrawRectangle (pHeader, rHeader); rHeader.X += rHeader.Width; g.DrawString ("Social (10)", fHeader, bHeader, rHeader); g.DrawRectangle (pHeader, rHeader); rHeader.X += rHeader.Width; g.DrawString ("Academic (9)", fHeader, bHeader, rHeader); g.DrawRectangle (pHeader, rHeader); rHeader.X += rHeader.Width; g.DrawString ("Total (50)", fHeader, bHeader, rHeader); g.DrawRectangle (pHeader, rHeader); } public static void Main (string[] args) { PrintDocument pd = new PrintDocument (); pd.PrintPage += new PrintPageEventHandler (pd_PrintPage); PrintPreviewDialog ppd = new PrintPreviewDialog (); ppd.Document = pd; ppd.Icon = new Icon ("Scribe.ico"); ppd.ShowDialog (); } } /* End. */ And the lines needed to compile Scribe and run it: csc /target:winexe /out:Scribe.exe /reference:System.dll /reference:System.Windows.Forms.dll /reference:System.Drawing.dll /win32icon:Scribe.ico Scribe.cs Scribe (Note that I've got an icon file which is linked in the above line. One can substitute any convenient Window .ico file for this file.) I'd like to factor out the C# parts and write a simplistic or simple Page Description Dialect (or Language), so that I have Rebol generate most of the report while Scribe handles the printing part. I've thought of writing the dialect in C# then compiling and executing that in Scribe, but that leads to problems with security and being harder to understand for people not used to C#. I've also thought of using PostScript and PDF, but they seem more complex to me. I've also thought of using a special Rebol dialect something like this: PrintPreview [ Paper A4 Top Left %"Colenso Logo.png" Top Center "COLENSO HIGH SCHOOL" "2003 - Year 10 Diploma Results" "Term 2" Left Divider "Mr & Mrs Family" "123 Example Street" "Nelson Park" "NAPIER" Space "Name: Pupil Family" Right "Form Class: 10XY" Center Divider | "Subject & Teacher" | "Attendance (14)" | "Equipment (7)" | "Work (10)" | Social (10) | "Academic (9)" | "Total (50)" | Divider | "10 Textiles" | 12.5 | 6 | 10 | 10 | 9 | 47.5 | | "Mrs X Bafabt" | 12.5 | 7 | 5 | 10 | 6 | 40.5 | Divider ] For the above, I plan to use Rebol's 'compose function to insert each pupil's reported data and feed the entire result to scribe. But I think I've lost my way (HTML tables seems a better idea for describing a table). Is there an approach that you can see that I've failed to see? Perhaps you can think of a better and easier to understand printing dialect? One important point is that I'd like to see exact placement on the page (like the C# code shows), along with a few shortcuts (like the Rebol dialect does). Andrew J Martin Grail Jedi ICQ: 26227169 http://www.rebol.it/Valley/ http://valley.orcon.net.nz/ http://Valley.150m.com/

 [2/5] from: g:santilli:tiscalinet:it at: 2-Oct-2003 13:55


Hi Andrew, On Thursday, October 2, 2003, 12:55:20 PM, you wrote: AJM> understand for people not used to C#. I've also thought of using PostScript AJM> and PDF, but they seem more complex to me. How should the PDF Maker be simplified? So I can add to the to do list for version 2. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [3/5] from: maximo:meteorstudios at: 2-Oct-2003 9:15


provide a draw dialect to access it. not that draw is extremely genial, at least we could port from screen to paper really easily. -MAx --- You can either be part of the problem or part of the solution, but in the end, being part of the problem is much more fun.

 [4/5] from: greggirwin:mindspring at: 2-Oct-2003 11:40


Gabriele, Andrew et al AJM> Is there an approach that you can see that I've failed to see? Perhaps you AJM> can think of a better and easier to understand printing dialect? One AJM> important point is that I'd like to see exact placement on the page (like AJM> the C# code shows), along with a few shortcuts (like the Rebol dialect AJM> does). GS> How should the PDF Maker be simplified? So I can add to the to do GS> list for version 2. There are two sides to this coin as I see it: 1) The outer dialect; and parallel to VID 2) The underlying engine that provides primitives used in the dialect. The exact dividing line between the two isn't clear, because you may want to "print" to many different "devices" (printer, fax, email, HTML, TeX, XML/docbook, PDF, etc.) for many different purposes (documents, forms, envelopes, labels, bar codes, print-preview, mail merge, reports). Having specialized dialects seems like the best way to make those accessible. What's hard to account for is the different elements that are important in each one. For example, a government form, label, or envelope will require very specific positioning; a document will have "areas" and *may* specify page breaks (think WP vs Acrobat); a report may have a stream of items and page breaks should be handled automatically; text based formats have much coarser positioning than graphic devices. digression [ Anyone ever write stuff that had to print text that shows in a window on an envelope? Ever had to change code when a new envelope was used? :) What if your dialect had envelope styles (where you could specify the window offset and size) and you could tag the data that should show in the window? ] We may also want to think about things like sub-dialects (e.g. tbl, eqn, pic) that are used for elements. If we can identify the primitives that the low level dialect needs to support, then all the other dialects are built on top of that and new output formats just means writing a new "renderer" that supports the required primitives. I think a VID-like approach could work well, where you can define styles, layout attributes, and elements that are intelligently handled, but also allows you to override things for more control. Easier said than done though. :\ I think PDF-maker has lots of great elements, but the different coordinate system is kind of a pain and it can be pretty verbose if you have lots of inter-element changes. Can't beat it for flexibility and output quality though. === Primitive Thoughts :) text single-line multiline alignment /horizontal [left center right justified] /vertical [top middle bottom justififed font table/grid header rows columns shading/fill sub-layout (like LIST) data shapes line [width style] box [line-width fill] circle [line-width fill] images (BMP JPG PNG SVG EMF charts?) special (bullets, math symbols, etc.) -- Gregg

 [5/5] from: andrew:martin:colenso:school at: 3-Oct-2003 9:08


Hi, Gabriele. You wrote:
> AJM> understand for people not used to C#. I've also thought of using
PostScript and PDF, but they seem more complex to me.
> How should the PDF Maker be simplified? So I can add to the to do
list for version 2. Just to clear things up a bit, I don't think that Gabriele's PDF Maker is too complex. I think that PDF is a bit too complex to use by typing it out by hand. I haven't used Gabriele's PDF Maker much. Andrew J Martin Attendance Officer & Grail Jedi. Colenso High School Arnold Street, Napier. Tel: 64-6-8310180 ext 826 Fax: 64-6-8336759 http://colenso.net/scripts/Wiki.r?AJM http://www.colenso.school.nz/ DISCLAIMER: Colenso High School and its Board of Trustees is not responsible (or legally liable) for materials distributed to or acquired from user e-mail accounts. You can report any misuse of an e-mail account to our ICT Manager and the complaint will be investigated. (Misuse can come in many forms, but can be viewed as any material sent/received that indicate or suggest pornography, unethical or illegal solicitation, racism, sexism, inappropriate language and/or other issues described in our Acceptable Use Policy.) All outgoing messages are certified virus-free by McAfee GroupShield Exchange 5.10.285.0 Phone: +64 6 843 5095 or Fax: +64 6 833 6759 or E-mail: [postmaster--colenso--school--nz]