Dot-Matrix Printer

How to insert ESC code for Dot-matrix printer in FastReport.net?

Comments

  • Hi

    You can add, the fallowing into file ( ...\FastReport.Net\Source\FastReport\Export\Text folder in ( filename )TextExport.cs )

    (TextExportPrinterCommand)


    /// <summary>
    /// Initializes a new instance of the <see cref="TextExport"/> class.
    /// </summary>
    public TextExport()
    {
    FPageBreaks = true;
    FEmptyLines = false;
    FFrames = true;
    FTextFrames = false;
    FEncoding = Encoding.UTF8;
    FDataOnly = false;
    FScaleX = 1.0f;
    FScaleY = 1.0f;
    FPreviewMode = false;
    FDataLossBreak = false;
    FAvoidDataLoss = true;
    FPrinterTypes = new List<TextExportPrinterType>();

    TextExportPrinterType printer = new TextExportPrinterType();
    printer.Name = "Epson ESC/P2";
    FPrinterTypes.Add(printer);

    TextExportPrinterCommand command = new TextExportPrinterCommand();
    command.Name = "Reset";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(64);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Normal";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(120);
    command.SequenceOn.Add(0);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Pica";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(120);
    command.SequenceOn.Add(1);
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(107);
    command.SequenceOn.Add(0);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Elite";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(120);
    command.SequenceOn.Add(1);
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(107);
    command.SequenceOn.Add(1);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Condenced";
    command.SequenceOn.Add(15);
    command.SequenceOff.Add(18);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Bold";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(71);
    command.SequenceOff.Add(27);
    command.SequenceOff.Add(72);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Italic";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(52);
    command.SequenceOff.Add(27);
    command.SequenceOff.Add(53);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Wide";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(87);
    command.SequenceOn.Add(1);
    command.SequenceOff.Add(27);
    command.SequenceOff.Add(87);
    command.SequenceOff.Add(0);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "12cpi";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(77);
    command.SequenceOff.Add(27);
    command.SequenceOff.Add(80);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Linefeed 1/8\"";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(48);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Linefeed 7/72\"";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(49);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Linefeed 1/6\"";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(50);
    printer.Commands.Add(command);

    printer = new TextExportPrinterType();
    printer.Name = "HP PCL";
    FPrinterTypes.Add(printer);

    command = new TextExportPrinterCommand();
    command.Name = "Reset";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(69);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Landscape";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(38);
    command.SequenceOn.Add(108);
    command.SequenceOn.Add(49);
    command.SequenceOn.Add(79);
    command.SequenceOff.Add(27);
    command.SequenceOff.Add(38);
    command.SequenceOff.Add(108);
    command.SequenceOff.Add(48);
    command.SequenceOff.Add(79);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Italic";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(40);
    command.SequenceOn.Add(115);
    command.SequenceOn.Add(49);
    command.SequenceOn.Add(83);
    command.SequenceOff.Add(27);
    command.SequenceOff.Add(40);
    command.SequenceOff.Add(115);
    command.SequenceOff.Add(48);
    command.SequenceOff.Add(83);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Bold";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(40);
    command.SequenceOn.Add(115);
    command.SequenceOn.Add(51);
    command.SequenceOn.Add(66);
    command.SequenceOff.Add(27);
    command.SequenceOff.Add(40);
    command.SequenceOff.Add(115);
    command.SequenceOff.Add(48);
    command.SequenceOff.Add(66);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Draft EconoMode";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(40);
    command.SequenceOn.Add(115);
    command.SequenceOn.Add(49);
    command.SequenceOn.Add(81);
    command.SequenceOff.Add(27);
    command.SequenceOff.Add(40);
    command.SequenceOff.Add(115);
    command.SequenceOff.Add(50);
    command.SequenceOff.Add(81);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Condenced";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(40);
    command.SequenceOn.Add(115);
    command.SequenceOn.Add(49);
    command.SequenceOn.Add(50);
    command.SequenceOn.Add(72);
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(38);
    command.SequenceOn.Add(108);
    command.SequenceOn.Add(56);
    command.SequenceOn.Add(68);
    command.SequenceOff.Add(27);
    command.SequenceOff.Add(40);
    command.SequenceOff.Add(115);
    command.SequenceOff.Add(49);
    command.SequenceOff.Add(48);
    command.SequenceOff.Add(72);
    printer.Commands.Add(command);

    printer = new TextExportPrinterType();
    printer.Name = "Canon/IBM";
    FPrinterTypes.Add(printer);

    command = new TextExportPrinterCommand();
    command.Name = "Reset";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(64);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Normal";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(120);
    command.SequenceOn.Add(0);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Pica";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(48);
    command.SequenceOn.Add(73);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Elite";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(56);
    command.SequenceOn.Add(73);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Condenced";
    command.SequenceOn.Add(15);
    command.SequenceOff.Add(18);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Bold";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(71);
    command.SequenceOff.Add(27);
    command.SequenceOff.Add(72);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "Italic";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(52);
    command.SequenceOff.Add(27);
    command.SequenceOff.Add(53);
    printer.Commands.Add(command);

    command = new TextExportPrinterCommand();
    command.Name = "12cpi";
    command.SequenceOn.Add(27);
    command.SequenceOn.Add(77);
    command.SequenceOff.Add(27);
    command.SequenceOff.Add(80);
    printer.Commands.Add(command);
    //sample (add 17 CPI into (Canon / IBM))
                command = new TextExportPrinterCommand();
                command.Name = "17cpi";
                command.SequenceOn.Add(27);
                command.SequenceOn.Add(77);
                command.SequenceOff.Add(27);
                command.SequenceOff.Add(80);
                printer.Commands.Add(command);
    
    FPrinterType = 0;
    FCopies = 1;

    OpenAfterExport = false;
    FPrintAfterExport = false;

    Res = new MyRes("Export,Misc");
    }

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.