Unable to Print Longer String to QLn420

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?

Anonymous (not verified)
Hi Zachary, I was able to

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

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Zachary Bredeson
Hey Robin,Thank you for

Hey Robin,

Thank you for taking time to look into this issue!

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hi Zachary,So, It's been a

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;

}

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Zachary Bredeson
Hey Robin,Thanks for the

Hey Robin,

Thanks for the response, detail, and thought process of this issue.

--

The developer working on this issue is currently out of the office.

However, once he is back, I will check in and respond with any questions we may have.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Zachary Bredeson
Hey Robin,The Sleep

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!

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Zachary Bredeson
Hey Robin,The Sleep


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!

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hi Zachary, Sorry I missed

Hi Zachary, Sorry I missed your earlier reply.  I'm guessing based on the fact that chunking the file works that it may be a buffer issue.  When I stepped through the print function, it seemed to indicate the print buffer was only about 200 bytes.  I'll have to look more into it to find out how to change this. 

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Zachary Bredeson
Hey Robin,Did you find

Hey Robin,

Did you find additional information on why this problem is happening?

Any updates I could give to our development team to hopefully resolve the issue on our end?

Thanks!

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Zachary Bredeson
Hello Robin,I am following up

Hello Robin,

I am following up as we still have the issue on our end.

Did you find a cause or a possible resolution?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Zachary Bredeson
Hey Robin,Have you had

Hey Robin,

Have you had success in trying to troubleshoot this issue?

Please let us know, as we are ready for suggestions!

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments