NL2017, PrintJobStatus: Error (maycaused by wrong encoded variables)

Label printing integration (NiceWatch middleware and ActiveX programming interface)

Moderators: Georges, milos, NiceLabel Support Team

Post Reply
snoooze
Newcomer
Posts: 2
Joined: Fri Jan 05, 2018 4:16 pm
Contact:

NL2017, PrintJobStatus: Error (maycaused by wrong encoded variables)

Post by snoooze » Fri Jun 29, 2018 3:53 pm

Hi people,

i'm new to the Nice Label 2017 SDK and run into problems with my printer service. The printer service is a windows service which controls the printer jobs and wraps a WCF webservice to which external clients can connect and print labels.

This works great but under some circumstances the printer engine logs a non-meaningful error:

Code: Select all

PrintJob = Error
The code which logs this error is

Code: Select all

(sender as IPrintRequest).SpoolJobStatus.ToString ()
Is there any way to get a more verbose error message?

After a little debugging I found the reason why it won't print. Some values on the label does have whitespaces or other "special" characters. A few labels use a ISO_IEC_15434 data matrix code with values like
[)><RS><GS>10D1826<GS>P3EST000235-7030<GS>2P01A<GS>2P01A<GS>20PDCE 4533<GS>SB45 18260000344<GS>23SC03580001F1A<GS>13V303723761<GS>14V354297301<RS><EOT>

Those values seems to produce the print error but I cannot get why. Probably the vars need a certain encoding? I mean even a whitespace triggers a print error?

Code which assigns the variables

Code: Select all

foreach ( Wave.Lang.IVariable item in data )
{
  // ignore null values
  if ( item.name == null || item.value == null ) continue;
  // assignment is done -> the exception is not throwing
  try {
    label.Variables[item.name].SetValue(item.value);
  }
  catch ( ArgumentException )
  {
    ...
  }
}
...
// printing
ILabel label = PrintEngineFactory.PrintEngine.OpenLabel(pathToLabel);
label.PrintSettings.MonitorSpoolJobStatus = true;
IPrintRequest printRequest = label.PrintAsync(quantity);
printRequest.PrintJobStatusChanged += _onPrintStatusChange;
printRequest.SpoolJobStatusChanged += _onSpoolStatusChange;

There must be a trick to do this because if I load the values from a mysql backend it works fine.

Is anywhere a official SDK API documentation out there? I just want to look which functions/objects/etc are available.

Thanks in advance,

best regards from Austria, Christoph

User avatar
Hoemalrocks
Valued Contributor
Posts: 43
Joined: Thu Mar 19, 2009 5:38 pm
Location: Vienna

Re: NL2017, PrintJobStatus: Error (maycaused by wrong encoded variables)

Post by Hoemalrocks » Thu Jul 05, 2018 8:14 am

Is there any way to get a more verbose error message?

Code: Select all

private void Request_SpoolJobStatusChanged(object sender, EventArgs e)
        {
		IPrintRequest request = sender as IPrintRequest;
		string exmsg = "Detailed Exception: " + request.PrintException;        
	}
Is anywhere a official SDK API documentation out there? I just want to look which functions/objects/etc are available.
C:\Program Files\NiceLabel\NiceLabel 2017\Help\SDK\SDK Reference.chm

snoooze
Newcomer
Posts: 2
Joined: Fri Jan 05, 2018 4:16 pm
Contact:

Re: NL2017, PrintJobStatus: Error (maycaused by wrong encoded variables)

Post by snoooze » Fri Jul 13, 2018 3:43 pm

Thanks a lot Hoemalrocks!

After I got the error message everything was clear and I could fix it!

Post Reply