Page 1 of 1

Print to multiple printers at once, without opening PrintRequester

Posted: Fri May 14, 2021 2:34 am
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 ?

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

Posted: Fri May 14, 2021 10:52 am
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.

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

Posted: Fri May 14, 2021 7:31 pm
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?

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

Posted: Fri May 14, 2021 8:29 pm
by hoerbie
What model of thermal printers do you use? On port 9100 sometimes you can simply send the print data...

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

Posted: Fri May 14, 2021 10:58 pm
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.

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

Posted: Fri May 14, 2021 11:18 pm
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  


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

Posted: Sat May 15, 2021 11:20 am
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$

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

Posted: Sat May 15, 2021 11:22 am
by mk-soft
Missing Page Feed ?!

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

Posted: Sat May 15, 2021 1:23 pm
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?

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

Posted: Sat May 15, 2021 2:02 pm
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.

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

Posted: Sat May 15, 2021 3:43 pm
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 



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

Posted: Sat May 15, 2021 9:22 pm
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

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

Posted: Sun May 16, 2021 11:12 pm
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?