Using Distiller from the network 
Author Message
 Using Distiller from the network

Maybe anybody is interessed in this perl script. I use it to convert
ps to pdf with a Mac on the net

--------------- Cut here -----------------------------------
# $Id: distiller,v 0.5 1997/05/19 17:49:22 ramge Exp ramge $
# ps to pdf filter using a Macintosh running Distiller

use POSIX;
use Getopt::Long;

$help =
"Usage:\n" .
"  $0 --distillerin dir --distillerout dir \\\n" .
"    < STDIN > STDOUT\n" .
"or\n" .
"  $0 -f outfile.pdf\n";

$version =
'distiller $Revision: 0.5 $' . "\n" .

$result = GetOptions(qw(debug|d help|h version|v wait|w=i output|f=s distillerin|i=s distillerout|o=s));

$DEBUG = $opt_debug ? 1 : 0;
if ($opt_help) {print STDERR $help; exit(0);}
if ($opt_version) {print STDERR $version; exit(0);}
$waittime = $opt_wait ? $opt_wait : 1200; # Time to wait for Distiller
$output = $opt_output ? ">" . $opt_output : ">-"; # Where to write the PDF-File
                                # default: STDOUT
$dist_in = $opt_distillerin ? $opt_distillerin : "/home/bettina/Distiller/In/";
$dist_out = $opt_distillerout ? $opt_distillerout : "/home/bettina/Distiller/Out/";

$dist_in = $dist_in . "/";    # are two slashes at the end of a dir
$dist_out = $ dist_out . "/"; # correct? Anyway, it works for me.

if ($#ARGV == -1) {
    $input = '-';

} elsif ($#ARGV == 0) {

    $input = $ARGV[0];
} else {

    die "You should give me one filename\n";


print STDERR "Input is $input\n" if ($DEBUG);

print STDERR "Writing $input to " . $tmpfile . "\n" if ($DEBUG);
($filename = $tmpfile) =~ s|.*/||;
print STDERR "Pure Filename is " . $filename . "\n" if ($DEBUG);

open(TMPFILE,"> $tmpfile"); # save INPUT in temporary file
while (<INPUT>) {
    print TMPFILE;


close TMPFILE;
close INPUT;

if (! (`file $tmpfile` =~ /postscript/)) { # is it really Postscript?
    die "Input ($tmpfile) was not a PostScript file\n";

} else {                        # it's Postscript

    print STDERR "Input ($tmpfile) is PostScript\n" if ($DEBUG);
    $psin=$dist_in . $filename . ".ps"; # copy tmpfile to in-directory
    print STDERR "Will use $psin as Distillers In file\n" if ($DEBUG);
    open PSIN, "> $psin";
    open TMPFILE, "$tmpfile";
    print PSIN <TMPFILE>;
    close TMPFILE;
    close PSIN;

    while($timer<$waittime) {        # Give Distiller some time to do his job
        if (! -f $psin) {       # In file is gone...
            open PDFOUT,  $dist_out . $filename . ".pdf";
            print STDERR "Output to $output\n" if ($DEBUG);
            while (<PDFOUT>) {
                print OUTPUT;
            exit 0;             # Normal termination
        if (-f $dist_out . $filename . ".log") { # Distiller error, logfile
            die "Distiller made " . $dist_out . $filename . ".log,\n normally Distiller should be quiet\n Check the logfile\n";
        sleep(1);               # Wait another second for Distiller


die "Something went wrong, sorry\n";

sub cleanup {
    close TMPFILE;
    unlink $tmpfile;
    unlink $dist_out . $filename . ".ps" || die "Couldn't delete", $dist_out . $filename . ".ps, Distiller will probably give up next time" ;
    unlink $dist_out . $filename . ".pdf" || die "Couldn't delete", $dist_out . $filename . ".pdf" ;


=head1 NAME

distiller - converts ps to pdf using a Macintosh on the net running Distiller


S<[ B<--help> ]>
S<[ B<--version> ]>
S<[ B<--debug> ]>
S<[ B<--distillerin> I<dir> ]>
S<[ B<--distillerin> I<dir> ]>
S<[ B<--output> I<outfile> ]>
S<[ I<infile> ]>


B<distiller> converts a given Postscript file to PDF. It uses a Macintosh Computer
running Adobe Acrobat Distiller somewhere on the network.

B<distiller> copies the given I<infile> or I<STDIN> to the Mac's "In" directory and waits until the Mac has written the PDF file to the "Out" directory. After that the resulting PDF-file is written to the destination file I<outfile> or, if not given, to I<STDOUT>.

=head2 OPTIONS

=over 4

=item B<-h --help>

Display a help screen and quit.

=item B<-v --version>

Display version information.

=item B<-d --debug>

Turn on debugging. Any produced (temporary) files are left where they are.

=item B<-i --distillerin> I<dir>

The directory where the Mac running Adobe Acrobat Distiller is looking for incoming PS-files.

B<Note:> You should probably edit B<distiller> so that the default directories are matching your site. Look for I<C<$dist_in>> and I<C<$dist_out>>.

=item B<-o --distillerout> I<dir>

Directory where the Mac is putting the resulting PDF-file. B<Attention:> B<distiller> assumes that the given PS-file and any logfiles are also written to this directory, so configure your Mac accordingly.

=item B<-f --output> I<outfile>

Where to write the resulting PDF-file. If no such option is given, I<STDOUT> is assumed.


=head1 USAGE

As a filter:

B<distiller> -i /usr/share/amacbox/In \
  -o /usr/share/amacbox/Out \
  < > outfile.pdf

Here's another example, using the output of F<dvips>:

dvips -f < foo.dvi | B<distiller> > foo.pdf

Simple invocation without using I<STDIN> or I<STDOUT>:

B<distiller> -f bar.pdf

=head1 AUTHOR

------------------- Cut here --------------------------------


Sat, 06 Nov 1999 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. ps2pdf vs distiller 4 (vs distiller 3.02)

2. setcolor behavior differ on GS and Distiller (was : OK with Distiller, error with GS)

3. using FSO over network drives using NETBIOS

4. Adding new fonts to be used by Distiller

5. Maintaining Page Size after using Distiller 3.01 to create PDF

6. ___ Q: PS => PDF using Distiller 3.0 ___

7. many -> 1 using distiller

8. using samba/linux as a drag and drop pdf server on a windows network

9. Problems using network drives on ghostscript 6.50 command line (windows NT)

10. Not using NT authentication but Requiring Network Userid

11. GS printing recommends using network adress as lptx:?!?

12. Access to network drive using FileSystemObject


Powered by phpBB® Forum Software