Hi,
because of a conversation this morning I decided to upgrade some old code I developed many years ago, and to share it here in our Community.
Even if it does not fit perfectly, maybe someone else has similar needs like discussed here:
What does this library called “PCLTCP” do?
It was needed to realize some (very restricted!) printing functionality from the PLC to a network printer: the goal was just bringing some lines of batch production information directly to paper.
Therefore I implemented the TCP/IP handling to send ASCII based strings + some PCL control commands to a TCP server (the printer).
To keep the functionality as generic as possible, the library just
- allocates some memory (the “virtual page” memory)
- provides some predefined constants (containing PCL command sequences like “feed forward”, “position cursor”, “set font”, a.s.o.) and some functions to add data (=ASCII Strings) to the memory
- and sends this “virtual page” to the printer when finished.
Printers that can be used have to have the following functionality:
- a TCP/IP network interface
- support of RAW printing (normally available if the printer offers printing via TCP port 9100)
- support of basic PCL commands (“Printer Common Language”)
- built-in font support (as I just send ASCII characters to the printer but no pixel information)
How does the usage look like?
Here’s a code snippet (I left out some FB call for initialization and so on, the following snippet is part of the download package at the end of this post).
The “yellow” part is about setting up the page content and adding some lines of text, the “green” part sends the finished page to the printer:
And this is what the printer prints:
Can I do a quick test to find out if my printer could be used?
If the printer meets the requirements listed above, the library has a function included to print a test page. Just setup the page, call the test function to add the test page to the virtual page memory, and send the “printjob” to the printer (same as above):
![]()
This test page includes the bold, italic, underline commands + most of the characters to check the printers font charset, and should lead to a printout looking somehow like that:
Is it still neccessary to make printouts from PLC directly?
Honestly spoken, I don’t know. Maybe the’re still use-cases about label printers, paper protocols, or similar.
At least I know that even actual network printers may still have the RAW print functionality + PCL command support onboard, as I tested the functionality after upgrade with one of our existing office printers ![]()
So if anyone has still such requests, here’s the code (library + sample inside a AS4.12 project).
PCLTCPSample.zip (1.7 MB)
Best regards!



