Print to multiple printers at once, without opening PrintRequester

Just starting out? Need help? Post your questions and find answers here.
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 627
Joined: Fri Dec 04, 2015 9:26 pm

Print to multiple printers at once, without opening PrintRequester

Post by skinkairewalker »

Hello guys, I have 3 wifi thermal printers, I need them to be just connected to the wifi and receive impressions from a central server without needing any human operator to click OK or display any request that stops the automation process ...

it is possible ?
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Print to multiple printers at once, without opening PrintRequester

Post by mk-soft »

Unfortunately, the creation and saving of different printers is still not supported.

We have been wishing for this for a long time.

It should be possible via API. But then everything via API.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 627
Joined: Fri Dec 04, 2015 9:26 pm

Re: Print to multiple printers at once, without opening PrintRequester

Post by skinkairewalker »

I noticed that the printers are linked to an IP and port 9100, will it be that if I make a request on the IP: 9100 something happens?
hoerbie
Enthusiast
Enthusiast
Posts: 119
Joined: Fri Dec 06, 2013 11:57 am
Location: DE/BY/MUC

Re: Print to multiple printers at once, without opening PrintRequester

Post by hoerbie »

What model of thermal printers do you use? On port 9100 sometimes you can simply send the print data...
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Print to multiple printers at once, without opening PrintRequester

Post by mk-soft »

Port 9100 is the default port for network printers.
You can send and receive print data via this port as if it were a serial printer. So you need to know how to handle the print commands.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 627
Joined: Fri Dec 04, 2015 9:26 pm

Re: Print to multiple printers at once, without opening PrintRequester

Post by skinkairewalker »

hoerbie wrote: Fri May 14, 2021 8:29 pmhoerbie
i am using : TANca - TP-650 ( termal ) and Epson L365 ( not termal )
mk-soft wrote: Fri May 14, 2021 10:58 pm Port 9100 is the default port for network printers.
You can send and receive print data via this port as if it were a serial printer. So you need to know how to handle the print commands.
I tested the 2 ways to send commands via ESC but when the Epson printer starts printing, the paper hangs and does not come out alone

Code: Select all



If InitNetwork() = 0
  MessageRequester("Error", "Can't initialize the network !", 0)
  End
EndIf

Global Close = 0
Port = 9100

ConnectionID = OpenNetworkConnection("192.168.1.5", Port)
If ConnectionID
  OpenConsole("")
  PrintN("Client connected to server...")
  
  SendNetworkString(ConnectionID, "Hello, this is a test print", #PB_UTF8)
  SendNetworkString(ConnectionID, "another line", #PB_UTF8)
  SendNetworkString(ConnectionID, Chr(27) + Chr(100), #PB_UTF8)
  SendNetworkString(ConnectionID, Chr(27) + #CRLF$ , #PB_UTF8)
  
  CloseNetworkConnection(ConnectionID)
Else
  PrintN("Can't find the server (Is it launched ?).")
EndIf


Repeat
  
  
Until Close = 1  

Code: Select all



If InitNetwork() = 0
  MessageRequester("Error", "Can't initialize the network !", 0)
  End
EndIf

Global Close = 0
Port = 9100

ConnectionID = OpenNetworkConnection("192.168.1.5", Port)
If ConnectionID
  OpenConsole("")
  PrintN("Client connected to server...")
  For i = 0 To 100
  SendNetworkString(ConnectionID, "Hello, this is a test print", #PB_UTF8)
  Next i
  CloseNetworkConnection(ConnectionID)
Else
  PrintN("Can't find the server (Is it launched ?).")
EndIf


Repeat
  
  
Until Close = 1  

infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Print to multiple printers at once, without opening PrintRequester

Post by infratec »

You know that you have to send a FormFeed to go to the next page/end a page :?:

A ForrmFeed is ASCII $0C or PB constant #FF or #FF$
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Print to multiple printers at once, without opening PrintRequester

Post by mk-soft »

Missing Page Feed ?!
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 627
Joined: Fri Dec 04, 2015 9:26 pm

Re: Print to multiple printers at once, without opening PrintRequester

Post by skinkairewalker »

wow, it worked guys, thank you very much!

but I have another question, how do I send images or pdf to be printed?
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Print to multiple printers at once, without opening PrintRequester

Post by mk-soft »

This is where it starts to get complicated. This is usually done by the printer drivers and the protocols vary from printer manufacturer to printer manufacturer.
Perhaps it is easier to print with RunProgramm and an external programme. For example, Adobe supports the printing of PDF files with the specification of the printer via parameters.

Otherwise, most printers support the PS (PostScript v6) protocol.

Finally, I have programmed printer drivers in the DOS era to print graphics using ESG sequences. The effort is too great.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
fluent
User
User
Posts: 68
Joined: Sun Jan 24, 2021 10:57 am

Re: Print to multiple printers at once, without opening PrintRequester

Post by fluent »

To print a pdf, give this a try: (replace the ip address with the one of your printer)
It should work with some printers.

Code: Select all



Procedure SendBinaryFile(socket0, filename$)
  If FileSize(filename$) <= 0 : ProcedureReturn : EndIf 
  
  FileID.i = OpenFile(#PB_Any,filename$)
  If FileID.i
    *memory = AllocateMemory(FileSize(filename$))
    If *memory
      ReadData(FileID.i,*memory,FileSize(filename$))
      CloseFile(FileID.i)
    Else
      End
    EndIf
  EndIf
  Delay(1000)
  
  SendComplete.i = SendNetworkData(socket0,*memory,MemorySize(*memory))
  While (SendComplete.i < MemorySize(*memory))
    SendComplete.i + SendNetworkData(socket0,*memory + SendComplete.i,MemorySize(*memory) - SendComplete.i)
    If SendComplete.i >= MemorySize(*memory)
      Break  
    EndIf
  Wend
  
EndProcedure


InitNetwork()
prid= OpenNetworkConnection("192.168.100.1",9100,#PB_Network_TCP, 1000)
Delay(1000)

If prid
  SendBinaryFile(prid,"c:\temp\test.pdf")
  Delay(1000)
EndIf 


Last edited by fluent on Sat May 15, 2021 11:27 pm, edited 1 time in total.
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Print to multiple printers at once, without opening PrintRequester

Post by infratec »

You can use GhostScript to print the file with a specific driver (which works with your printer) to a file.
Then send this file to the printer.

https://www.ghostscript.com/doc/9.25/Devices.htm

Not tested:

Code: Select all

gs -sDEVICE=epson -sOutputFile=epson.dat test.pdf
Or you can send directly to a network printer:

Code: Select all

gsprint -printer "\\ps1\epson" -dPDFFitPage "pdf.pdf"
If it is not running on a server you can use this for free:
http://www.lvbprint.de/html/printmulti1.html
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 627
Joined: Fri Dec 04, 2015 9:26 pm

Re: Print to multiple printers at once, without opening PrintRequester

Post by skinkairewalker »

infratec wrote: Sat May 15, 2021 9:22 pm You can use GhostScript to print the file with a specific driver (which works with your printer) to a file.
Then send this file to the printer.

https://www.ghostscript.com/doc/9.25/Devices.htm

Not tested:

Code: Select all

gs -sDEVICE=epson -sOutputFile=epson.dat test.pdf
Or you can send directly to a network printer:

Code: Select all

gsprint -printer "\\ps1\epson" -dPDFFitPage "pdf.pdf"
If it is not running on a server you can use this for free:
http://www.lvbprint.de/html/printmulti1.html
does it work on thermal prints?
Post Reply