D3 tip & question...

147 views
Skip to first unread message

Gene Buckle

unread,
Jan 19, 2012, 10:05:18 AM1/19/12
to mvd...@googlegroups.com
If you've ever wanted to directly email pdf files right from the system,
you can do it like this:

First set up a printer entry:

STARTSHP <ptr#>,<ptr#>,0,S<port>,LP.UNIX,(/usr/local/bin/print_to_pdf)

The print_to_pdf script looks like this:

----
/usr/local/bin/enscript -e -Z -B --non-printable-format=questionmark -h -H
--font=Courier-Bold7.5 --ps-level=1 --media=Letter > /tmp/print_pdf.ps

/usr/bin/ps2pdf /tmp/print_pdf.ps /tmp/print_pdf.pdf

/usr/local/bin/mail_pdf <user>@<domain> /tmp/print_pdf.pdf Printed_PDF_Report
----

You'll need to grab enscript & ps2pdf to create the PDF output - both are
open source packages.

The mail_pdf is a perl script:

----
#!/usr/bin/perl -w

use strict;
use MIME::Lite;
use Getopt::Std;

#------------------------------
# main
#------------------------------
sub main {
my %opts;

### Get options:
getopts('', \%opts) or die "usage error\n";
my $addr = $ARGV[0] || die "Missing email address.\n";
my $fpath = $ARGV[1] || die "Missing filename to attach.\n";
my $subj = $ARGV[2] || die "Missing Subject.\n";

my $msg = MIME::Lite->new(From => '<user>@<domain>',
To => $addr,
Subject => $subj,
Type => "multipart/mixed");

$msg->attach(Type => "application/pdf",
Path => $fpath,
Disposition => "attachment");

MIME::Lite->send("smtp","<outgoing mail server addr>", Timeout=>60);

$msg->send;

}
exit(&main ? 0 : -1);
1;
__END__

----

The perl script requires that you have the MIME::Lite package installed
(this can be done via CPAN).

This will allow you to send PDF files to a single user.

Two questions - is it possible to pass a parameter through STARTSHP (say
the user name) in order to allow specifying the destination address? I
haven't found anything in the docs that mentions this. (I don't want to
make mods to STARTSHP itself if it can be avoided)

My second question, is it possible to make the system NOT kick a page
before starting the print job? All my PDF files start with a blank page.
:)

Thanks all - hopefully some of you might find this useful. :)

g.


--
Proud owner of F-15C 80-0007
http://www.f15sim.com - The only one of its kind.
http://www.diy-cockpits.org/coll - Go Collimated or Go Home.
Some people collect things for a hobby. Geeks collect hobbies.

ScarletDME - The red hot Data Management Environment
A Multi-Value database for the masses, not the classes.
http://www.scarletdme.org - Get it _today_!

Political correctness is a doctrine, fostered by a delusional, illogical
minority, and rabidly promoted by an unscrupulous mainstream media, which
holds forth the proposition that it is entirely possible to pick up a turd
by the clean end.

Steve Douglas

unread,
Jan 19, 2012, 11:34:33 AM1/19/12
to mvd...@googlegroups.com
Gene,
 
Try the (S option at the end of your STARTSHP.....  It is not documented in the STARTSHP options in my (admittedly older) D3 reference manual.  But it is documented in the STARTPTR and seems to work the same for us in STARTSHP (although not with pdf).
 
Steve

geneb

unread,
Jan 23, 2012, 9:51:33 AM1/23/12
to Pick and MultiValue Databases
Thanks Steve, I'll give that a shot!

g.

fwinans

unread,
Feb 12, 2012, 11:13:11 PM2/12/12
to mvd...@googlegroups.com
You've elected to convert a text document to a   postscript intermediate document,
then feed that to  ps2pdf.

Another route might be to feed the text document to gs  {from the ghostscript package}
which can honor  pcl printer language syntax {not that I've tested that part}  and spit
out a  .pdf  file  if desired.   Google turned up this example command <very much untested>;
gs  -sDEVICE=ljet4  -sOutputFile=test.pcl  -q  -dBATCH  -sPAPERSIZE=a4  -dNOPAUSE   test.pdf

With any luck that will honor hardcoded escape strings any legacy progs have been putting in your reports for special printing effects that are tailored for pcl printer language, not postscript language.

towerjon

unread,
Feb 13, 2012, 3:47:12 PM2/13/12
to Pick and MultiValue Databases
I've tested PCL to PDF with Ghostscript and it seems to work well as
long as you have a recent version. My CentOS install had to be
updated manually.

That command should be more like:

gs -sDEVICE=pdfwrite -sOutputFile=<YOUR OUTPUT FILENAME>.pdf -q -
dBATCH -dNOPAUSE <YOUR INPUT FILENAME>

Here's a good link: http://www.troubleshooters.com/linux/gs.htm

For me, a PCL file is in the input, the PDF is output. You can also
use postscript files (and other types) as an input.

By the way, thanks for the earlier tip on STARTSHP!

Jon

fwinans

unread,
Feb 16, 2012, 8:52:14 AM2/16/12
to Pick and MultiValue Databases
fwinans wrote:
> Another route might be to feed the text document to gs
> which can honor  pcl printer language syntax and spit
> out a  .pdf  file  if desired.

Argh! I had that totally backwards; on checking my old notes,
gs is good for, among other things,
_eating_ existing .pdf files and can if requested
_emit_ printer output to, say, printers that like PCL,
instead of buying fancier printers that like PS.

Sorry about that misinformation. Ages ago, back in our d3/sco days,
it was really nice to have found a command to print out archived .pdf
files from a nongraphical environment, but I hadn't used
ghostscript aka gs since then, and just totally misremembered it in
my last post.
Reply all
Reply to author
Forward
0 new messages