1. Sivaprakash BKR
  2. PowerBuilder
  3. Thursday, 7 March 2019 07:44 AM UTC

Hello,

PB 2017 R3, Postgresql 11.1

Need to print a label report in a Datamax barcode printer.   Different label sizes are possible.   Tried with

For 3 labels in a row, single label size 3 x 2 cm

1.  Created one label dw, retrieved required data.  tried with command dw_print().   NOTHING PRINTS.

2.  tried with PrintOpen(), PrintSend(),  PrintDatawindow(), PrintClose() commands.  Code 

Job = PrintOpen()

PrintSend(job, "n")
PrintSend(job, "M0500")
PrintSend(job, "KcLW0355;")
PrintSend(job, "O0220")
PrintSend(job, "d")
PrintSend(job, "L")
PrintSend(job, "D11")
PrintSend(job, "ySPM")
PrintSend(job, "A2")
PrintDataWindow(Job, dw_1)
//PrintSend(job, 'Siva')

// Send the job to the printer or spooler.
PrintClose(Job)

Code got from bartender software.    NOTHING PRINTS.

3.  Tried the full code, from bartender, including printing all required values

Long job

job = PrintOpen()

PrintSend(job, "n")
PrintSend(job, "M0500")
PrintSend(job, "KcLW0355;")
PrintSend(job, "O0220")
PrintSend(job, "d")
PrintSend(job, "L")
PrintSend(job, "D11")
PrintSend(job, "ySPM")
PrintSend(job, "A2")


PrintSend(job, "1911A12005400141Simple")
PrintSend(job, "1911A12005401322Sample")
PrintSend(job, "1911A12005402503Crimple")
PrintSend(job, "1W1D22000003100382,LA,12345678")
PrintSend(job, "1911A060013003112345678")
PrintSend(job, "1W1D22000003101562,LA,12345678")
PrintSend(job, "1911A060013014912345678")
PrintSend(job, "1W1D22000003102742,LA,12345678")
PrintSend(job, "1911A060013026712345678")
PrintSend(job, "Q0001")
PrintSend(job, "E")
PrintSend(job, "L")
PrintSend(job, "D11")
PrintSend(job, "ySPM")
PrintSend(job, "A2")
PrintSend(job, "1911A1200540014Sample Text")
PrintSend(job, "1W1D22000003100382,LA,12345678")
PrintSend(job, "1911A060013003112345678")
PrintSend(job, "1911A1200540132Sample Text")
PrintSend(job, "1W1D22000003101562,LA,12345678")
PrintSend(job, "1911A060013014912345678") */
PrintSend(job, "Q0001")
PrintSend(job, "E")
PrintSend(job, "")

// Send the job to the printer or spooler.
PrintClose(Job)

It prints the first column value, Simple

then prints the next values 1911A12005401322Sample continuously.

Would like to know what to do to print a label dw properly in Datamax barcode printer from powerbuilder.

* PrintSend command has been marked as Obsolete in Powerbuilder 2017 R3.  

Happiness Always
BKR Sivaprakash

 

 

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 7 March 2019 17:40 PM UTC
  2. PowerBuilder
  3. # 1

Hi BKR;

   Can you tell us ...

1) Did this code work in a previous version of PB?

2) Could the issue be that the printer is expecting and ANSI data stream?

    PB2017Rx is Unicode

3) Does the DataMax printer have an MS-Windows print driver or is this a directly connected USB or Serial port device?

Regards ... Chris

Comment
  1. Sivaprakash BKR
  2. Friday, 8 March 2019 10:25 AM UTC
Chris,

2. If it's expecting ANSI, how to (print)send in ANSI ?

How to print a dw in ANSI ?
  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 8 March 2019 20:18 PM UTC
The DWO only prints in Unicode. So you would have to use the low-level print commands as above.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 8 March 2019 20:29 PM UTC
For ANSI, try ....

Blob lblb_data

lblb_data = Blob ( "1911A12005400141Simple", EncodingANSI! )

PrintSend ( job, String ( lblb_data, EncodingANSI! )

  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 7 March 2019 18:56 PM UTC
  2. PowerBuilder
  3. # 2

The statement in the help file that this function is obsolete has been in there since PB 8.

Comment
  1. Sivaprakash BKR
  2. Friday, 8 March 2019 05:10 AM UTC
Roland,

Yes. help says

Obsolete function PrintSend is an obsolete function and is provided for backward compatibility only. The ability to use this function is dependent upon the printer driver.

  1. Helpful
  1. Roland Smith
  2. Friday, 8 March 2019 11:38 AM UTC
My point is that you shouldn't avoid the function just because of the obsolete comment in the help. They aren't going to remove it.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 8 March 2019 20:20 PM UTC
Correct ... Appeon is not enhancing the PrintSend() command but if you still need this low-level command ... its still there (and many of our customers still use it BTW).
  1. Helpful
There are no comments made yet.
Brad Mettee Accepted Answer Pending Moderation
  1. Friday, 8 March 2019 14:24 PM UTC
  2. PowerBuilder
  3. # 3

Create an alternate version of the printer using the same driver and send your code to a file instead of a printer (or modify the current printer to print to a file). This way you get to see what the output looks like. You'll need to use a text editor that can display the results in HEX (so you can see if there are unicode characters in your output).

The worst case would be that you need to open the printer directly (using winapi calls) and send data to it directly encoded as ANSI. We've had to do this in the past, so it is possible, but I don't have the source code available at the moment. Here's a link to someone doing a similar task: Send data directly to printer

 

Comment
  1. Chris Pollach @Appeon
  2. Friday, 8 March 2019 20:21 PM UTC
Hi Roland;

That is great suggestion!

FWIW: I have built many Apps in PB 12.x that uses this approach and it works great. Should be the same for PB2017Rx and PB2019 AFAIK.

Regards ... Chris
  1. Helpful
  1. Sivaprakash BKR
  2. Saturday, 9 March 2019 12:29 PM UTC
Roland,

Seems I've issue with printing with FileOpen and FileWrite. Tried with the following code. No success.



job = FileOpen('USB001', StreamMode!, Write!, Shared!, Append!, EncodingANSI!)



FileWrite(job, "n~r~n")

FileWrite(job, "M0500~r~n")

FileWrite(job, "KcLW0355;~r~n")

FileWrite(job, "O0220~r~n")

FileWrite(job, "d~r~n")

FileWrite(job, "L~r~n")

FileWrite(job, "D11~r~n")

FileWrite(job, "ySPM~r~n")

FileWrite(job, "A2~r~n")

FileClose(job)



Any suggestion ?
  1. Helpful
  1. Brad Mettee
  2. Saturday, 9 March 2019 14:41 PM UTC
I don't think you can't open a USB port directly like you could with an LPT: port. The base drivers work differently.



The suggestion I made about directing the printer to a file was only for debugging your output, not as a solution.
  1. Helpful
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Saturday, 9 March 2019 11:53 AM UTC
  2. PowerBuilder
  3. # 4

Thanks Chris, Roland, Brad Mettee

I could make a very good progress.  Yes ANSI seems to the requirement.

1.  Converting the data to Blob, then to string with ANSI Encoding, then PrintSend.  Works Fine.    Only issue is it sends one more set of empty labels at the end of the print.   Blank labels adds to wastage.

2.  Direct printing to printer from a text file, after encoding to ANSI, works fine.   It works perfectly with no label wastage.   [ Link given by Brad Mettee  code under Script Print EPL File:].     This is what I used to do in my previous applications,  create a text file and print it via dos print command.   Now instead of DOS print, I could print directly to the printer, which could avoid some petty issues that I used to face while printing via DOS print command.

3.  Don't know why Script Print Text:  is not working.   Same code works fine with PrintSend and file print.  

Could not debug with the output code from printer, as the printer doesn't send any output when there is some error in code, it seems.  

Seems I should go with method 2 above, as it gives me a small enhancement, to print the output file directly from powerbuilder instead of invoking some DOS commands.

Yet,

Should find a way to print a dw directly to such printers.  Is this falls under some enhancement(?) any way ?

Happiness Always
BKR Sivaprakash

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.