10 Replies Latest reply on May 17, 2018 8:07 AM by Zachary Bredeson

    Unable to Print Longer String to QLn420

    Zachary Bredeson

      Hello Everyone!

       

      I am currently unable to print a longer string to a Zebra QLn420, using a Generic / Text Only driver.

       

      Are there any recommendations, to add to this script/project, so a print is successful?

        • Re: Unable to Print Longer String to QLn420
          Robin West

          Hi Zachary, I was able to reproduce your problem with your code.  I'm now attempting to fix the code so it will work.

          1 of 1 people found this helpful
            • Re: Unable to Print Longer String to QLn420
              Zachary Bredeson

              Hey Robin,

               

              Thank you for taking time to look into this issue!

                • Re: Unable to Print Longer String to QLn420
                  Robin West

                  Hi Zachary,

                  So, It's been a while since I've done c++ coding.  Maybe If I share my thought process though, we can figure this out. Your code is sending something to the printer, just not all of it.

                   

                  First thing to do so you can see what is being output is to go to the generic text driver and in the properties, set the port to FILE:.  Now when you print using this code, it will prompt you for a file location to save the output.  You need to enter a FULL path including file name for it to work.

                   

                  Second is your Print(LPCTSTR pText) function is actually doing way too much and I was afraid it might be causing the issues.  I cleaned it up as below and got essentially the same output.  This unfortunately didn't solve the problem, but it does make it easier to check that the issue wasn't with the text formatting commands you had it going through.  They are not necessary for printing ZPL through this type of driver.

                   

                  My thoughts on a few things to check are:

                  1. Is the close document (EndDoc) coming too soon?  We see this often with slow communication methods where the OS doesn't always verify that a connection may still be writing something before it closes the connection and so the data get's cut off.  I was going to try and introduce a wait or delay at the beginning of the cleanup code to see if it processes more text that way.
                  2. In your Open() function, are you giving the printer handle a big enough buffer?

                   

                  bool CPrinter::Print(LPCTSTR pText)
                  {
                    if (!pText) return false;
                    if (!mhDC) return false;
                  
                    //////////////////// StartDoc
                    DOCINFO info = { sizeof(info), 0};
                    info.lpszDocName = _T("RFgenOutput");
                    if (StartDoc(mhDC, &info) <= 0) {
                      _tprintf(_T("StartDoc call failed\n"));
                      return false;
                    }
                  
                    //////////////////// Font setup
                    HGDIOBJ hFont=NULL;
                    if (mhFont) hFont = SelectObject(mhDC, mhFont);
                  
                    SIZE sz={0};
                    GetTextExtentPoint32(mhDC, _T("A"), 1, &sz);
                  
                    //////////////////// Output to DC
                    size_t len = _tcslen(pText);
                    TextOut(mhDC, 0, 0, pText, len);
                  
                    //////////////////// Cleanup / EndDoc
                    Sleep(5000);
                  
                    if (hFont) SelectObject(mhDC, hFont);
                  
                    bool bEndOK = (EndDoc(mhDC) > 0);
                  
                    _DELETEDC(mhDC);
                    _DELETEOBJECT(mhFont);
                  
                    memset(&mDevMode, 0, sizeof(DEVMODE));
                    miWidth = 0;
                  
                    if (!bEndOK) {
                      _tprintf(_T("EndDoc call failed\n"));
                      return false;
                    }
                    return true;
                  }
                  
              • Re: Unable to Print Longer String to QLn420
                Zachary Bredeson

                Hey Robin,

                 

                The Sleep suggestion did not resolve the issue on our end.

                 

                Also, I would like to relay, that if we break the string into multiple chunks we can print successfully.

                 

                However, this should not be a workaround for our customers using Zebra printers.

                 

                --

                 

                With this information, how should we proceed in resolving the issue?

                 

                I look forward to hearing from you!