printing a file to a print server prettily

C

ccc31807

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;
}
}
 
J

Jürgen Exner

ccc31807 said:
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
 
C

ccc31807

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.
 
A

A. Sinan Unur

ccc31807 said:
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/LaTeX-Driver-0.07/lib/LaTeX/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/support/SupportManual/bpl13210/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 <[email protected]>
(remove .invalid and reverse each component for email address)

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top