Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Autoflushing Laser printer

by Popcorn Dave (Abbot)
on Nov 16, 2004 at 01:22 UTC ( [id://408014]=perlquestion: print w/replies, xml ) Need Help??

Popcorn Dave has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,

I'm trying to send output to my laser printer. All well and good except I can't get it to actually eject the page. What happens is that the text is sent, and the light is flashing on the laser printer showing there is a page waiting to be ejected and that's it. If I physically push the button to eject the page, it will give me the page. I've tried setting autoflush but it's not working.

Here's what I was playing with:

use strict; use FileHandle; STDOUT->autoflush(1); #$| = 1; my $text = "Printing test...\n"; open FH, ">LPT1:"; print FH "$text\n";

Neither $++ or use FileHandle seems to be doing the trick. Should I be sending an eject code instead of or in addition to autoflush?

Thanks in advance!

Update: Adding .chr(12) to the string $text kicks the page out like I was after.

Thanks to ikegami for pointing out my output file error.

Useless trivia: In the 2004 Las Vegas phone book there are approximately 28 pages of ads for massage, but almost 200 for lawyers.

Replies are listed 'Best First'.
Re: Autoflushing Laser printer
by ikegami (Patriarch) on Nov 16, 2004 at 01:40 UTC

    STDOUT->autoflush(1); makes STDOUT autoflush, not FH. $| = 1 make the currently selected file handle autoflush, which isn't FH in your snippet.

    my $text = "Printing test...\n"; open FH, ">LPT1:"; select(*FH); $| = 1; # Turn on autoflush for FH select(*STDOUT); print FH "$text\n";
Re: Autoflushing Laser printer
by chromatic (Archbishop) on Nov 16, 2004 at 03:34 UTC

    As you've discovered, you need to send the printer a formfeed character. Otherwise, the unfinished page may sit in the buffer forever, silently drop, or stick around with the next print job.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://408014]
Approved by Happy-the-monk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-03-28 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found