Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unable to print the bill using ethernet Printing in qt.

Unable to print the bill using ethernet Printing in qt.

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    seethanellai
    wrote on last edited by
    #1

    Problem in ethernet Printing(LAN)

    I have 3 modules in my project.

    1. Main Application 2) Server Module (Plugin Library.It is used for getting the db details from server. This will act like .net web services) 3) Printer Module (DLL) - It will take care of all printing related stuff

    I am able to print the bill using print module (calling DLL function from application), when it calls from main application. But i am unable to print the bill when it calls from server.

    I have two types of bill printing. one is Receipt Printing and another is KOT printing.Receipt print should come from main application. Kot print should come from server. Currently my KOT printing not printing anything. Both will call the below function for printing.

    Call from Main application:

    @QByteArray data = m_pPrintBrowser->toPlainText().toUtf8();

    m_pPrintLib.PrintData(data,m_pPrinterDetail);@
    

    Call from Server:

    @void ServerFunctionThread::printdetail()
    {
    PrintLib test;
    QByteArray testtxt;

    testtxt.append(test.formatString("KOT PRINTING TEST",40,0) + "\n");
    testtxt.append(test.formatString("KOT PRINTING TEST",40,1) + "\n");
    testtxt.append(test.formatString("KOT PRINTING TEST",40,2) + "\n");
    
    testtxt.append(test.formatString("KOT PRINTING TEST",40,0) + "\n");
    testtxt.append(test.formatString("KOT PRINTING TEST",40,1) + "\n");
    testtxt.append(test.formatString("KOT PRINTING TEST",40,2) + "\n");
    
    testtxt.append(test.formatString("KOT PRINTING TEST",40,0) + "\n");
    testtxt.append(test.formatString("KOT PRINTING TEST",40,1) + "\n");
    testtxt.append(test.formatString("KOT PRINTING TEST",40,2) + "\n");
    
    PrinterMaster printerDtl;
    
    printerDtl.IP_Address = "192.168.1.227";
    printerDtl.port_No = 9100;
    printerDtl.printer_Type = "E";
    printerDtl.printer_Name = "Ethernet";
    
    test.PrintData(testtxt,printerDtl);
    
    tcpSocket.waitForDisconnected();
    
    qDebug()<<Q_FUNC_INFO<<"Exits";
    return;
    

    }@

    Below is the code for print. This code is presented in DLL.

    @//LAN Printing
    else if(printMasterDtl.printer_Type.contains('E'))
    {
    m_pLanPrinter.write(data,printMasterDtl.IP_Address,printMasterDtl.port_No);
    }@

    @void LanPrinter::write(QByteArray data,QString ipAddress,int port_No)
    {
    const int Timeout = 5 * 1000;
    m_pSocket->connectToHost(ipAddress,port_No);
    if (!m_pSocket->waitForConnected(Timeout))
    {
    qDebug ("error in waitForConnected()");
    qDebug (qPrintable(m_pSocket->errorString()));
    m_ConnectStatus = false;
    return;
    }
    m_ConnectStatus = true;
    QDataStream out(&data, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_4_0);
    qDebug (qPrintable("Test KOT Printing"));
    if(m_pSocket->state() == QTcpSocket::ConnectedState)
    {
    qDebug (qPrintable("Connected"));
    qDebug() << "Data is:" << data;
    }
    else if(m_pSocket->state() == QTcpSocket::UnconnectedState)
    {
    qDebug (qPrintable("Not Connected"));
    }
    else
    {
    qDebug (qPrintable("Connecting"));
    }
    qDebug (qPrintable(m_pSocket->errorString()));
    m_pSocket->write(data);
    m_pSocket->write("\n\n\n\n\n\r");
    m_pSocket->write(PARTIAL_PAPER_CUT);
    m_pSocket->disconnectFromHost();
    }@

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you tell us what you are getting/expecting ?

      On which OS are you running ? Which Qt version are you using ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        seethanellai
        wrote on last edited by
        #3

        I am using windows 8. QT creator version 3.1.

        I am expecting to print the bill on printer (POS printer). I am using bixolon printers for printing the bill. When i am calling that DLL print function from my main application , i am able to print that bill. But when i am calling that dll function from my server, that printing is not happening.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The version of Qt Creator doesn't really help. The version of Qt that you are using currently is the point of interest.

          Are you getting any error on the console when running your application ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved