Hoping someone can help by pointing me in the right direction

OS: openSUSE leap 15

Network Printer: HP CP2025n, Static IP Addess: 10.1.1.25 Port: 9100 Upto date firmware

HTML Webform sends data to cgi script which produces one or more PDF docs, the same script then sends qualifying PDF docs to someone by email as required

At the mo i am manually printing out a number of these docs as required when needed

I would to try and automatically have these printed out for me as they are created instead. The web server is on the same LAN as the printer.

I'm working with a much smaller script here for the purpose of testing the print process which is failing and i have no idea why

The printer spits out what is largely a blank sheet of paper, with a smiley followed by "HP Network Printer", or ideed anything i place within the variable $PrinterName

The PDF doc or the string of text does not get printed onto the paper

Either it's not getting sent to the printer in the first place or when it reaches the printer, the printer can't do anything with it, i'm guessing

The Web Servers Error Log records two errors detaled below, tried googling these error messages and i've failed to find anything that helps, the errors refer to the code on line 51 as marked which as i understand this code this is where the script actually sends either the PDF doc or the string of text to the printer for printing

These error messages sugest that there is an error in my code on line 51 but i can't work it out, i'm stumped "not OK" and "not ready" but the printer does print. Are the "not OK" and "not ready" messages generated because the printer is sleeping and it's taking too long to wake up, but does wake up in time to actually print something? Do the "not OK" and "not ready" messages mean that the printer is incompatible with what i'm trying to achieve in some way?

#!/usr/bin/perl use strict; use CGI ':standard'; #use PDF::API2; #use MIME::Lite; use Net::Printer; #use utf8; my ( $WeekNumber, $DocumentUID, $CheckInDate, $BookingReference, $OutstandingBalance, $TypeOfForm, $PathToTestDocument, $TestDocument, $TestString, $PrinterName, $NetworkPrinter, $PrintDocument ); $WeekNumber = "41"; $DocumentUID ="1067"; $CheckInDate = "Sat 5th Oct 2019"; $BookingReference = "WTBA234C4"; $OutstandingBalance = 0; $TypeOfForm = "Registration Document"; $PathToTestDocument = "/*****/*****"; $TestDocument = "$WeekNumber\_$DocumentUID \($CheckInDate\) $BookingRe +ference $TypeOfForm.pdf"; $TestString = "I Will get This Perl Script to Print Something, i will! +?"; $PrinterName = " HP Network Printer"; $NetworkPrinter = new Net::Printer( printer => "$PrinterName", # Printer's Name! server => "10.1.1.25", # IP Address of Pri +nter port => 9100, # Printer's Port Nu +mber lineconvert => "Yes", ); print "Content-Type:text/html\n\n"; if ( (($OutstandingBalance <= 0) && ($TypeOfForm ne "Cancelled Booking +")) && ( -e "$PathToTestDocument/$TestDocument") ) { ##### Print a PDF Document to Printer # ##### Line 51 ##### $PrintDocument = $NetworkPrinter->printfile("$Pat +hToTestDocument/$TestDocument"); # FAILS! ##### Line 51 ##### # ##### Print a String of text to Printer # #$PrintDocument = $NetworkPrinter->printstring($TestString); # FAI +LS! (If uncommented) # print " <html> <body> <br> <center><b>Something should get printed out of the printer!?</b></cent +er> <br /> <center>Network Printer's Name: $PrinterName</center> <br /> <center>Test Document Path: $PathToTestDocument</center> <br /> <center>Test Document Name: $TestDocument</center> <br /> <center>Test String: $TestString</center> <br /> <center>Type Of Form: $TypeOfForm</center> <br /> <center>Contents of VarName PrintDocument: $PrintDocument</center> <!- +- Empty!? --> </body> </html> "; } else { print " <html> <body> <body> <center><b>Something went wrong!?</b></center> <br /> <center>Network Printer's Name: $PrinterName</center> <br /> <center>Test Document Path: $PathToTestDocument</center> <br /> <center>Test Document Name: $TestDocument</center> <br /> <center>Test String: $TestString</center> <br /> <center>Type Of Form: $TypeOfForm</center> <br /> <center>Contents of VarName PrintDocument: $PrintDocument</center> <! +-- Empty!? --> </body> <html> "; }; exit;

##### Web Servers Error Log Entries

Wed May 01 18:36:17.636352 2019 cgi:error pid 22045 client ***.***.***.***:50537 AH01215: ERROR:Net::Printer719: Printer HP Network Printer on Server 10.1.1.25 not okay: /*****/*****/cgi-bin/testprint.cgi

Wed May 01 18:36:17.636508 2019 cgi:error pid 22045 client ***.***.***.***:50537 AH01215: at /*****/*****/cgi-bin/testprint.cgi line 51.: /*****/*****/cgi-bin/testprint.cgi

Wed May 01 18:36:17.636609 2019 cgi:error pid 22045 client ***.***.***.***:50537 AH01215: ERROR:Net::Printer252: Printer HP Network Printer on 10.1.1.25 not ready!: /*****/*****/cgi-bin/testprint.cgi

Wed May 01 18:36:17.636668 2019 cgi:error pid 22045 client ***.***.***.***:50537 AH01215: at /*****/*****/cgi-bin/testprint.cgi line 51.: /*****/*****/cgi-bin/testprint.cgi


In reply to NET::Printer Module not printing to local printer by akwe-xavante

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.