0
votes

This problem concerns a thermal receipt printer. I have downloaded C# EPSON OPOS receipt printing examples in attempt to implement such a printer in my current project, all is working well but when I print a bitmap logo, successive text is being printed under it, and I need to print some text to the right side of it. Here is an approximation of what it does now: Before This is what I need it to do: After My current code, pretty much as-is from EPSON's samples:

private void btnReceipt_Click(object sender, System.EventArgs e)
{
    //<<<step8>>>--Start
    //Initialization
    DateTime nowDate = DateTime.Now;                            //System date
    DateTimeFormatInfo dateFormat = new DateTimeFormatInfo();   //Date Format
    dateFormat.MonthDayPattern = "MMMM";
    string strDate = nowDate.ToString("MMMM,dd,yyyy  HH:mm",dateFormat);
    int iRecLineSpacing;
    int iRecLineHeight;
    bool bBuffering = true;

    bool bBitmapPrint = false;
    int iPrintRotation = 0;


    string strCurDir = Directory.GetCurrentDirectory();
    string strFilePath = strCurDir.Substring(0, 
    strCurDir.LastIndexOf("Step8") + "Step8\\".Length);
    strFilePath += "bitmap_logo.bmp";


    Cursor.Current = Cursors.WaitCursor;

    Rotation[] arBitmapRotationList = m_Printer.RecBitmapRotationList;
    Rotation[] arBarcodeRotationList = m_Printer.RecBarCodeRotationList;

    //Check rotate bitmap
    for (int i = 0; i < arBitmapRotationList.Length; i++)
    {
        if (arBitmapRotationList[i].Equals(Rotation.Left90))
        {
            bBitmapPrint = true;
            iPrintRotation = (iPrintRotation | (int)PrintRotation.Left90)
                | ((int)PrintRotation.Bitmap);
        }
    }

    iRecLineSpacing = m_Printer.RecLineSpacing;
    iRecLineHeight = m_Printer.RecLineHeight;

    if (m_Printer.CapRecPresent == true)
    {
        try
        {
            m_Printer.TransactionPrint(PrinterStation.Receipt, PrinterTransactionControl.Transaction);

            m_Printer.RotatePrint(PrinterStation.Receipt, (PrintRotation)iPrintRotation);


            if (bBitmapPrint == true)
            {
                m_Printer.PrintBitmap(PrinterStation.Receipt, strFilePath, m_Printer.RecLineWidth, PosPrinter.PrinterBitmapCenter);
            }

            m_Printer.PrintNormal(PrinterStation.Receipt,"\u001b|4C" + "\u001b|bC" + "   Receipt     ");

            m_Printer.PrintNormal(PrinterStation.Receipt,"\u001b|3C" + "\u001b|2uC" + "       Mr. Brawn\n");

            m_Printer.PrintNormal(PrinterStation.Receipt,"\u001b|2uC" + "                                                  \n\n");

            m_Printer.PrintNormal(PrinterStation.Receipt,"\u001b|2uC" + "\u001b|3C" + "        Total payment              $" +"\u001b|4C" + "21.00  \n");

            m_Printer.PrintNormal(PrinterStation.Receipt,"\u001b|1C\n" );

            m_Printer.PrintNormal(PrinterStation.Receipt,strDate + " Received\n\n");

            m_Printer.RecLineHeight = 24;
            m_Printer.RecLineSpacing = m_Printer.RecLineHeight;

            m_Printer.PrintNormal(PrinterStation.Receipt,"\u001b|uC" + " Details               \n");

            m_Printer.PrintNormal(PrinterStation.Receipt,"\u001b|1C" + "                          " + "\u001b|2C" + "OPOS Store\n");

            m_Printer.PrintNormal(PrinterStation.Receipt,"\u001b|uC" + " Tax excluded    $20.00\n");

            m_Printer.PrintNormal(PrinterStation.Receipt,"\u001b|1C" + "                          " + "\u001b|bC" + "Zip code 999-9999\n");

            m_Printer.PrintNormal(PrinterStation.Receipt,"\u001b|uC" + " Tax(5%)        $1.00" + "\u001b|N" + "    Phone#(9999)99-9998\n");
        }
        catch(PosControlException ex)
        {
            if(ex.ErrorCode == ErrorCode.Illegal && ex.ErrorCodeExtended == 1004)
            {
                MessageBox.Show("Unable to print receipt.\n", "Printer_SampleStep8", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                // Clear the buffered data since the buffer retains print data when an error occurs during printing.
                m_Printer.ClearOutput();
                bBuffering = false;
            }
        }

        try
        {
            m_Printer.RotatePrint(PrinterStation.Receipt, PrintRotation.Normal);

            if(bBuffering == true)
            {
                m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|fP");
            }

            m_Printer.TransactionPrint(PrinterStation.Receipt, PrinterTransactionControl.Normal);
        }
        catch(PosControlException)
        {
            // Clear the buffered data since the buffer retains print data when an error occurs during printing.
            m_Printer.ClearOutput();
        }
    }

    m_Printer.RecLineSpacing = iRecLineSpacing;
    m_Printer.RecLineHeight = iRecLineHeight;
    Cursor.Current = Cursors.Default;
    //<<<step8>>>--End
}

If there is a method to do absolute text positioning or being able to write to the same line where the bitmap is, it would solve my issue. Any directions appreciated!

1

1 Answers

1
votes

Please ask EPSON whether you can print with the layout you want with one set of RotatePrint.

As an alternative, consider dividing it into two sets of RotatePrint.

If you first set of RotatePrint with Bitmap and "Some other text", and the second set of RotatePrint with "Sample text 1" to "Sample text 3", it will be close to the layout you want.


In addition:

Epson OPOS seems to support PageMode, so can you print it?

As for explanation of Japanese, please look through google translation etc.