Author Topic: Printing to Zebra thermal printers  (Read 2621 times)

0 Members and 1 Guest are viewing this topic.

Offline JohnUKresults

  • Newbie
  • Posts: 40
    • View Profile
Printing to Zebra thermal printers
« on: July 19, 2020, 11:44:20 am »
Hi.

Anyone had any success printing to Zebra or similar thermal printers from QB64?

I know you can't use printer control codes as in the "olden days of escape characters", but I just want to print some plain text and don't want to spend the best part of £300 on a printer only to find I can't do it!

It's just to do quick printouts for people at race events, to confirm finish times and positions etc, so no fancy graphics required.

Thanks for any tips.

John

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Printing to Zebra thermal printers
« Reply #1 on: July 19, 2020, 10:23:56 pm »
@JohnUKresults The Printronix SDK can work with any printer. You can send ZPL/ZGL commands to a printer. Let me dig up my code for Printronix printers and you can have it. All you need is the openport() and sendcommand() functions. Download the attached DLL to use it. I can't remember if you need to terminate the printer name and command with CHR$(0). Do some tests. It works with both networked and local printers. Alternatively, if your printer is simply just networked, just open a TCP/IP client in QB64 on port 9100 (the printing port) and send your raw data.

Code: QB64: [Select]
  1. FUNCTION DLLinit ALIAS PTXA_DLLinit
  2. FUNCTION DLLexit ALIAS PTXA_DLLexit
  3. FUNCTION openport (printername AS STRING
  4. FUNCTION closeport
  5. FUNCTION sendcommand (printercommand AS STRING)
  6.  
  7.  
  8. PRINT DLLinit 'initialize the DLL
  9. PRINT openport ("whatever you printer is named as it appears in Devices/Printers in Control Panel")
  10. PRINT sendcommand ("whatever the string is for the code of your label")
  11. PRINT closeport 'close the port
  12. PRINT DLLexit 'exit the DLL
  13.  
« Last Edit: July 19, 2020, 10:39:34 pm by SpriggsySpriggs »
Shuwatch!

Offline Juanjogomez

  • Forum Regular
  • Posts: 117
    • View Profile
Re: Printing to Zebra thermal printers
« Reply #2 on: July 21, 2020, 02:17:45 am »
@JohnUKresults The Printronix SDK can work with any printer. You can send ZPL/ZGL commands to a printer. Let me dig up my code for Printronix printers and you can have it. All you need is the openport() and sendcommand() functions. Download the attached DLL to use it. I can't remember if you need to terminate the printer name and command with CHR$(0). Do some tests. It works with both networked and local printers. Alternatively, if your printer is simply just networked, just open a TCP/IP client in QB64 on port 9100 (the printing port) and send your raw data.

Code: QB64: [Select]
  1. FUNCTION DLLinit ALIAS PTXA_DLLinit
  2. FUNCTION DLLexit ALIAS PTXA_DLLexit
  3. FUNCTION openport (printername AS STRING
  4. FUNCTION closeport
  5. FUNCTION sendcommand (printercommand AS STRING)
  6.  
  7.  
  8. PRINT DLLinit 'initialize the DLL
  9. PRINT openport ("whatever you printer is named as it appears in Devices/Printers in Control Panel")
  10. PRINT sendcommand ("whatever the string is for the code of your label")
  11. PRINT closeport 'close the port
  12. PRINT DLLexit 'exit the DLL
  13.  


Hi SpriggsySpriggs!!.
This dll would also work to print on matrix printers, with Esc codes?

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Printing to Zebra thermal printers
« Reply #3 on: July 21, 2020, 06:47:07 am »
@Juanjogomez I've not tried it with matrix printers but I know the escape codes work on label printers such as form feed. I would imagine they would work on the matrix printers as well.
Shuwatch!

Offline JohnUKresults

  • Newbie
  • Posts: 40
    • View Profile
Re: Printing to Zebra thermal printers
« Reply #4 on: July 26, 2020, 03:41:50 pm »
Hi

Thanks - will have a close look at that code to see how it works. I will be connecting via usb in all probability but networking could be a secondary option I suppose.

Would this also enable escape codes to be used on other printers too?

I have had to make changes to an old QB4.5 program ported to QB64, which output via LPT to parallel printers by making them print out to rtf documents instead of directly to the printers as previously, because I couldnt use the escape codes directly in QB64 according to the Lprint information.

Grateful for your responses.

John

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Printing to Zebra thermal printers
« Reply #5 on: July 26, 2020, 04:19:52 pm »
Hi

Thanks - will have a close look at that code to see how it works. I will be connecting via usb in all probability but networking could be a secondary option I suppose.

Would this also enable escape codes to be used on other printers too?

I have had to make changes to an old QB4.5 program ported to QB64, which output via LPT to parallel printers by making them print out to rtf documents instead of directly to the printers as previously, because I couldnt use the escape codes directly in QB64 according to the Lprint information.

Grateful for your responses.

John

@JohnUKresults You should be able to use the ESCAPE characters by just sending them like CHR$(12) for formfeed and whatnot. It should work, as long as you are able to send the string correctly.
Shuwatch!