Home Page RTextPrinter for .NET
Home
                  RTextPrinter for .NET
                • Introduction
                • User Guide
                • Download
                • Pricing & Purchase
                • License
                • Related products
                • Java version
                • User Guide
                  TextPrinter

                  TextPrinter for .NET

                  Introduction

                  The .NET platform provides a printing api which can be used for printing text and graphics. .NET printing api always prints in graphic mode which can result in very slow printing if you use a dot matrix printer. TextPrinter is an assembly developed to overcome this problem.

                  When to use TextPrinter:

                  • If you are going to print text and lines only.
                  • If you require fast printing.
                  • If you use a dot matrix printer.

                  TextPrinter does not only send the text you want to print but it also sends the appropiate printer commands for using bold and italic fonts, selecting font types, size of the font, character sets etc...

                  Note that each printer family will use a different set of commands for this reason you must check if your printer is supported. Some of the supported printer are:

                  • Epson printers or compatible that support the ESC P command set
                  • HP printers or compatible that support the PCL 3 (also known as Laser Jet Plus emulation)
                  • HP printers or compatible that support the PCL 5
                  • IBM proprinters or compatible
                  • IBM laser printers that support the PPDS command set
                  • Diablo printers

                  You can also use the so called "Plain" printer, but in this case you will not be able to use italic and bold fonts, or any other feature other than printing text.

                   

                  Installation

                   

                  The product and the examples can be executed by just unzipping the downloaded file into an empty directory and running the appropiate EXE file.

                  If you need compile a program which uses TextPrinter you must add the rtextpr.dll file to your project.

                   

                  API Tutorial

                  The following tutorial provides an introduction to the main classes of the package.

                   

                  PrinterFactory

                  The PrinterFactory class is used to get a TextPrinter implementation for the type of printer you specify:

                  TextPrinter printer=PrinterFactory.getPrinter(printertype);

                  where printertype can be:

                  • IBM-PROPRINTER
                  • EPSON-ESCP2
                  • EPSON-ESCP
                  • IBM-PPDS
                  • HP-PCL3
                  • HP-PCL5
                  • DIABLO
                  • PLAIN (default if any other value passed)

                   

                  PrinterPort

                  The PrinterPort interface is used to physically access the printer. There are 2 classes implementing the PrinterPort interface:

                  • FilePort: writes into operating system file. Example of use:

                    FilePort port=new FilePort("c:\\myoutput.txt");

                  • WindowsPrinter: access the printer using windows api. Example of use:

                    WindowsPrinter port=new WindowsPrinter("printerName");

                  The PrinterPort class is passed to the TextPrinter.startJob() method as described in the next section.

                   

                  TextPrinter

                  The TextPrinter object returned by the PrinterFactory is the core of the printing process. It must be used in the following way:


                  [c#]
                  // create the properties of your job
                  JobProperties job= printer.getDefaultJobProperties();
                  // start job with given properties on given port
                  printer.startJob(port,job);

                  // print your text here

                  // end printing
                  printer.endJob();

                  You need to call the startJob() method providing the port object (see previous section) and the properties you request for your job. The JobProperties include properties like paper size and format.

                  The printing finishes when you execute endJob().

                  Printing of you text can be performed in 2 manners:

                  1. You can specify the absolute possition of the text you want to print. For example:


                    [c#]
                    prop=printer.getDefaultTextProperties();
                    printer.printString("Hello",10,0,prop); // print at row 10, columns 0
                    printer.printString(....)
                    ....
                    // print page when done
                    printer.newPage();




                  2. or you can continuosly print:


                    [c#]
                    prop=printer.getDefaultTextProperties();
                    printer.printString("Hello",prop);
                    printer.newLine();
                    printer.printString("Hello",prop);
                    printer.newLine();
                    ......


                  The TextProperties class is used to set the appearance of your text (font, size ....).


                  JobProperties

                   

                  The JobProperties class is used in the startJob method to some global properties. The most important are:

                  • Size of the page (JobProperties.rows and JobProperties.cols properties).
                  • Margins of the page (JobProperties.topMargin, JobProperties.bottomMargin, JobProperties.leftMargin and JobProperties.right Margin properties).
                  • Page orientation ( JobProperties.landscape). Note that not all printers support landscape printing.

                   

                  TextProperties

                   

                  Whenever you print a text you must pass a TextProperties object which is used to specify the following properties:

                  • Style of the font (TextProperties.italic , bold, underlined , subscript , superscript, doubleStrike and doubleWide). Note that not all printers will support all styles.
                  • Font type (TextProperties.fontName). The names of the fonts depend on the printer.
                  • Font size (TextProperties.pitch). Possible values are 10 , 12 and 15 characters per inch.
                  • Character set (TextProperties.characterSet). The names of the character sets depend on the printer.

                   

                   

                  Examples

                   

                  The following example can be used to test the capabilities of your printer:


                  [c#]

                  TextPrinter printer=PrinterFactory.getPrinter("HP-PCL3"); // use the correct printer type here
                  JobProperties job= printer.getDefaultJobProperties();
                  printer.startJob(port,job);

                  // plain style
                  TextProperties prop=printer.getDefaultTextProperties();
                  printer.printString("This must be NORMAL",prop);
                  printer.newLine();

                  // bold style
                  prop=printer.getDefaultTextProperties();
                  prop.bold=true;
                  printer.printString("This must be BOLD",prop);
                  printer.newLine();

                  // italic style
                  prop=printer.getDefaultTextProperties();
                  prop.italic=true;
                  printer.printString("This must be ITALIC",prop);
                  printer.newLine();

                  // underlined
                  prop=printer.getDefaultTextProperties();
                  prop.underlined=true;
                  printer.printString("This must be UNDERLINED",prop);
                  printer.newLine();

                  // double wide
                  prop=printer.getDefaultTextProperties();
                  prop.doubleWide=true;
                  printer.printString("This must be double wide",prop);
                  printer.newLine();

                  // double strike
                  prop=printer.getDefaultTextProperties();
                  prop.doubleStrike=true;
                  printer.printString("This must be double strike",prop);
                  printer.newLine();

                  // subscript
                  prop=printer.getDefaultTextProperties();
                  prop.subscript=true;
                  printer.printString("This must be subscript",prop);
                  printer.newLine();

                  // superscript
                  prop=printer.getDefaultTextProperties();
                  prop.superscript=true;
                  printer.printString("This must be superscript",prop);
                  printer.newLine();

                  printer.endJob();

                   

                  Supported printers' features

                   

                  The following tables show the features supported by each printer:

                   
                  Epson-ESC P and P2
                  HP-PCL3 and 5
                  IBM-Proprinter
                  Bold
                  Yes
                  Yes
                  Yes
                  Italic
                  Yes
                  Yes
                  Underlined
                  Yes
                  Yes
                  Yes
                  Font types
                  Roman, SansSerif, Courier , Prestige, Script , OCR-B, OCR-A , Orator, Orator-S
                  Univers, LinePrinter, CG Times, Courier, Albertus Antique Olive, Clarendon, Coronet, Garamond Antiqua, Letter Gothic, Marigold, CG Omega, Arial, Times New Roman, Symbol, Wingdings
                  Character sets
                  437 (USA), ISO-IR-69 (France), ISO-IR-21 (Germany), ISO-IR-4 (England), Denmark (Denmark), Sweden (Sweden), ISO-IR-15 (Italy), ISO-IR-17 (Spain), Japan (Japan), ISO-IR-60 (Norway), Denmark II (Denmark II), ISO-IR-85 (Spain II), Latin America (Latin America), Korea (Korea), 932 (Japanese), 850 (Multilingual), 851 (Greek), 853 (Turkish), 855 (Cyrillic), 860 (Portugal), 863 (Canada-French), 865 (Norway), 852 (East Europe), 857 (Turkish II), 862 (Hebrew), 864 (Arabic), 866 (Russian), ISO8859-7 (Latin/Greek), ISO8859-1 (Latin 1), ISO8859-2 (Latin 2), 862 (Iceland)
                  ISO-IR-60 (Norwegian 1), ISO-IR-61 (Norwegian 2), ISO-IR-4 (United Kingdom), ISO-IR-69 (French), ISO-IR-21 (German), ISO-IR-15 (Italian), ISO-IR-14 (JIS ASCII), ISO-IR-57 (Chinese), ISO-8859-1 (Latin 1), ISO-IR-11 (Swedish), ISO-IR-17 (Spanish 1), ISO-IR-10 (Swedish 2), ISO-IR-16 (Portuguese 1), IISO-IR-84 (Portuguese 2), ISO-IR-85 (Spanish 2), ISO-IR-6 (ASCII) ISO-IR-2 (IRV), ROMAN8, 1252 (Windows), PC-8 (437 USA default), 850
                  437 (USA), 850 (Multilingual), 860 (863), 865 (Norway), 858, ISO-IR-6 (ASCII), ISO-IR-69 (French), ISO-IR-21 (German), ISO-IR-4 (United Kingdom), ISO-IR-17 (Spanish 1), ISO-IR-15 (Italian), ISO-IR-17 (Spanish 1), ISO-IR-60 (Norwegian 1), ISO-IR-85 (Spanish 2)
                  Double strike
                  Yes
                  Yes
                  Double wide
                  Yes
                  Yes
                  Condensed fonts
                  Yes
                  Size (chars per inch)
                  10, 12, 15
                  10, 12, 15
                  10, 12
                  Superscript / Subscript
                  Yes
                  Yes
                  Landscape
                  Yes
                  Quality draft
                  Yes
                  Line interscape
                  6, 8
                  1,2,3,4,6,8,12,16,24,48
                  8,12,18,24

                   

                   
                  IBM-PPDS
                  Diablo
                  Plain
                  Bold
                  Yes
                  Yes
                  Italic
                  Underlined
                  Yes
                  Yes
                  Font types
                  Character sets
                  Double strike
                  Yes
                  Double wide
                  Yes
                  Condensed fonts
                  Size (chars per inch)
                  10, 12 , 17.1
                  Superscript / Subscript
                  Yes
                  Landscape
                  Yes
                  Quality draft
                  Line interscape
                  8,12,18,24