Unable to print the bill using ethernet Printing in qt.



  • 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();
    }@


  • Lifetime Qt Champion

    Hi,

    Can you tell us what you are getting/expecting ?

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



  • 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.


  • Lifetime Qt Champion

    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 ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.