Printing a PDF Document to a Network Printer using PERL or BASH

I have a webform that sends data to a perl script that then creates a PDF document before sending it off by email to someone.

I need to print out some of these PDF Documents. At the mo i’m finding, opening and then printing manually. Simple and straight forward process.

However it would be great if it was printed automatically as required. One in four require printing and i occasionally forget causing problems later on!

The perl script can establish which do and don’t need printing.

What would be the best way to achieve this?

Add the Perl NET:: Printer module
Add Bash code to print the document to the printer.

Yast (openSUSE 15 Leap) fails to find the perl-net-printer module, how do i install this module?

You would need to configure and use cpan on your system as there is no perl-net-printer available for Leap (and Tumbleweed it’s in the CPAN staging repository, not in the release).

Thank you so much,

I think this is my best way forward.

Thank you

I sucessfully installed the NET:: Printer module after resolving a few issues along the way and when i print a PDF document (from within a perl script) to the printer i just get a blank sheet of paper!!

So i thought i would try the NET::CUPS:: Destination Module instead…

Stumped, the module attempts install and fails with a message saying cups/cups.h is missing… #include <cups/cups.h>. The file is missing, compilation terminated.

libcups2 is installed, i can’t find cups.h anywhere on the system.

I can open a PDF Document and print it to the HP Network Printer OK, it’s a CP2025n at the IP address port 9100.

Where am i going wrong?

Should i try removing libcups2 and then re-installing it? whereis libcups returns libcups:

So it looks as though it’s not installed.

Installed cups-devel and cups-filters and NET:: CUPS :: Destination seems to have installed ok.

Just need to now work out how to print a PDF Document to the printer from within a perl script, something to have a go at tomorrow.

Take a look at this: <>.

  • Assuming that, the Line Printer daemon conforms to RFC 1179 …

BTW, .PDF files are (mostly) text files …

Thank you to those that have responded.

I have given up on getting cpan’s NET:: Printer module to print files to a local network printer.

I have however managed to get a PDF document sent to the printer and printed out from a perl script by invoking a shell command instead.

Given that the webform and the perl script is UserName and PassWord protected on a secure web server and things are setup in a way that these specific files are only accessible from specific devices with static ip addresses on the local network only. They are not accessible via the WAN. I’ve decided this is a controlled and accepteable risk to take.