Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > printing a file to a print server prettily

Reply
Thread Tools

printing a file to a print server prettily

 
 
ccc31807
Guest
Posts: n/a
 
      04-25-2008
I generate a series of paper files every morning, anywhere from a few
dozen to a couple of thousand. I have copied the function that I use
below. This function takes a file name, which is an ASCII file with a
name like 'john_doe.txt' with a number of fields (name, address,
previous college, enrollment date, etc., maybe 30 in all) and the
resulting output is distriubted to personnel for further processing
and filing (in a physical file folder -- which is one reason why we
need to actually print the file).

We have an employee who has been used to getting output from an Access
database. The field names are printed in italic, the values are
printed in san-serif, and the values have nice little boxes drawn
around them. She has convinced everyone that they all need pretty
output rather than a plain ASCII output.

So ... I'm sitting here wondering how I can convince the printer to
print some part in italics, some part in sans-serif, and draw pretty
boxes. Any ideas?

Thanks, CC.

use File::Copy;
....
sub print_file
{
$print_file = shift;
$print_test = copy($print_file, '//serprintserver/SERITS') or
warn "could not print, $!";
if ($print_test == 1)
{
print "Printed $print_file\n";
unlink $print_file;
}
}
 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      04-25-2008
ccc31807 <(E-Mail Removed)> wrote:
>So ... I'm sitting here wondering how I can convince the printer to
>print some part in italics, some part in sans-serif, and draw pretty
>boxes. Any ideas?


You need to create a document in a format that supports those elements,
e.g. PS or DVI or HTML or PDF or RTF or DOC or DOCX or any of many
others, and is understood by your printer or can be converted by a
printer driver into a format that is understood by your printer.

jue
 
Reply With Quote
 
 
 
 
ccc31807
Guest
Posts: n/a
 
      04-25-2008
On Apr 25, 2:28 pm, Jürgen Exner <(E-Mail Removed)> wrote:
> You need to create a document in a format that supports those elements,
> e.g. PS or DVI or HTML or PDF or RTF or DOC or DOCX or any of many
> others, and is understood by your printer or can be converted by a
> printer driver into a format that is understood by your printer.


Thanks. After looking at PDF and RTF, I got RTF-Writer (because it
looked a lot simpler) and have created bunches and bunches of RTF
files.

Unfortunately, the files are not printing. We have several categories,
New, Update, Change, etc., and I modified the New files to 'rtf'. Now,
the 'txt' file print just like they did before, but the rtf files are
not printing. You note that the function unlinks the file after
printing. The print message is appearing, but the rtf files are not
coming out of the printer, and the files are not being deleted. This
is curious because either the print message appears and the files are
deleted, or the error message prints and the files are not deleted. I
get the print message but the files are not deleted.

It's not a Perl problem, I don't think. I'm not asking for help, just
complaining. It's 4:35 p.m. on a Friday afternoon, and I'm looking at
coming in tomorrow, so if you can think of anything off the top of
your head, please buzz me.

Thanks, CC.
 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      04-25-2008
ccc31807 <(E-Mail Removed)> wrote in news:(E-Mail Removed):

> We have an employee who has been used to getting output from an Access
> database. The field names are printed in italic, the values are
> printed in san-serif, and the values have nice little boxes drawn
> around them. She has convinced everyone that they all need pretty
> output rather than a plain ASCII output.


I have read your response to Jurgen as well. I feel your pain

>
> So ... I'm sitting here wondering how I can convince the printer to
> print some part in italics, some part in sans-serif, and draw pretty
> boxes. Any ideas?
>
> Thanks, CC.
>
> use File::Copy;
> ...
> sub print_file
> {
> $print_file = shift;
> $print_test = copy($print_file, '//serprintserver/SERITS') or
> warn "could not print, $!";


What language does the printer speak? There are, by an large,
two alternatives:

1) The printer speaks Postscript

a) In this case, you can probably insert POD directives in the file
and use pod2ps before sending it to the printer.

b) Use HTML::Template or any other templating module to fill
in a LaTeX template. Run latex and dvips to get the file to print.
(http://search.cpan.org/~andrewf/LaTe...aTeX/Driver.pm
might be useful here, although I have not used it).

2) The printer speaks PCL. All you really need is PCL 1.
Embed text format switching escape codes in the file. Send file to printer.
Again, a template based approach ought to work here.

The specs are at http://h20000.www2.hp.com/bc/docs/su...0/bpl13210.pdf

Just out of curiosity, I tried the following:

#!/usr/bin/perl

use strict;
use warnings;

use HTML::Template;

my $PRINTER = q{\\\\AARDVARKVI\\HL2070N};

my $ESC = "\033";

my %c = (
BOLD => "${ESC}(s3B",
_BOLD => "${ESC}(s0B",
ITALIC => "${ESC}(s1S",
_ITALIC => "${ESC}(s0S",
);

my $tmpl = <<EO_TMPL;
<TMPL_LOOP RECIPIENTS>
$c{BOLD}Name:$c{_BOLD} $c{ITALIC}<TMPL_VAR NAME>$c{_ITALIC}
</TMPL_LOOP RECIPIENTS>
EO_TMPL

my $ht = HTML::Template->new( scalarref => \$tmpl );

$ht->param( RECIPIENTS => [
{ NAME => 'No Nonsense' },
{ NAME => 'The Daily Whatever' },
{ NAME => 'Donald Duck' },
]);

open my $PRN, '>', $PRINTER
or die "Cannot open '$PRINTER': $!";

print $PRN $ht->output;

close $PRN or die "Cannot close '$PRINTER': $!";

__END__

This works fine with my Brother laser printer which understands PCL. (Can
you tell I wrote some dot matrix printer drivers in the 80s

Anyway, choose the approach that works best for you. Use plain
text for data storage and use a prettified version for the clerks to
put in hanging file folders.

Good luck.

Sinan

--
A. Sinan Unur <(E-Mail Removed)>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:50 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:28 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-18-2007 10:11 AM
Problem - I want to print Current Output of Pdf file and should print once.I get print dialog box but it is not working keto Java 0 05-30-2007 11:27 AM
Unlarging the print to print using PDF file to print Bun Mui Computer Support 3 09-13-2004 03:15 AM



Advertisments