GV 3.5.8 pdf wrapper patch 
Author Message
 GV 3.5.8 pdf wrapper patch

Greetings,

        Has anyone else run into a problem with Ghostview, v. 3.5.8,
the one that ships w/ Mandrake 7.2?  It works fine if viewing a
postscript file, but if viewing a PDF file, when I try to print it,
it tells me it can't find a tempory file.  There IS a temporary
file created, but with a slightly different number.  I hacked around
the problem by 1st converting the PDF to a temporary POSTSCRIPT file,
then viewing and then deleting it.  This Perl script is a wrapper
around GV to do this AND to accept PDF and PS mime-type files from
Netscape (urls).  Simply rename gv to gv0, and call this script "gv".
It is freely available from me, shown below.

---------------------- gv --------------------------------------------
#!/usr/local/bin/perl -s

#BY JIM TURNER
#THIS SCRIPT IS A WORKAROUND FOR A BUG IN "GV" WHICH DOESN'T KEEP TRACK OF
#IT'S TEMPORARY FILES WHEN ONE TRIES TO PRINT A "PDF" FILE.  THIS SCRIPT
#WORKS BY FIRST CONVERTING THE PDF FILE TO POSTSCRIPT VIA GHOSTSCRIPT TO
#A TEMPORARY POSTSCRIPT FILE, THEN INVOKES GHOSTVIEW ON *THAT* FILE, WHICH
#GHOSTVIEW *CAN* VIEW & PRINT WITHOUT FUSS.  IT ALSO HANDLES NETSCAPE MIMES
#FOR PDF AND PS FILES!

use LWP::Simple;

die "..usage:  gv pdf_file"  unless ($ARGV[0]);

$ENV{LD_LIBRARY_PATH} = '/usr/local/lib';

$ARGV[0] =~ s/^file://;
if ($ARGV[0] =~ /^https?\:\:/)
{
    $ENV{HTTP_PROXY} ||= ' http://www.*-*-*.com/ ';
        #$ENV{HTTP_PROXY} = ' http://www.*-*-*.com/ ';
        $ENV{HTTP_PROXY} = ''  
                if ($ARGV[0] =~ /(Merl|\.lmtas\.lmco\.com)/i);
        $_ = LWP::Simple::get($ARGV[0]);
        $ARGV[0] = '/tmp/xpstmp.ps';
        $ARGV[0] = '/tmp/xpdftmp.pdf'  if (/^\%PDF/);
        open (TMP,">$ARGV[0]") || die ('Could not open temp. file!'.

        print TMP $_;
        close TMP;

Quote:
}

#`/usr/X11R6/bin/ghostview $ARGV[0]`;

die "..gv: file \"$ARGV[0]\" does NOT exist!"  unless (-e $ARGV[0]);

$isapdf = 0;
if ($ARGV[0] =~ /pdf$/)
{
        $isapdf = 1;

Quote:
}

elsif ($ARGV[0] !~ /ps$/)
{
        open (F, "<$ARGV[0]")  ||

        $_ = <F>;
        $isapdf = 1  if (/^\%PDF/);
        close F;

Quote:
}

if ($isapdf)
{
        my $outfile = $ARGV[0];
        $outfile = $1  if ($outfile =~ m#([^\/]+$)#);
        $outfile =~ s/pdf$/ps/i;
        $outfile .= '.ps'  unless ($outfile =~ /\.ps$/i);
        $outfile = '/tmp/' . $outfile;

        #print "-gvpdf: in=$ARGV[0]= out=$outfile=\n";

        `gs -dNODISPLAY -dQUIET -sPDFname=$ARGV[0] -sDSCname=$outfile pdf2dsc.ps -c quit`;

        `/usr/X11R6/bin/gv0 $outfile`;

        `rm $outfile`  unless ($outfile eq $ARGV[0]);

Quote:
}

else
{
        `/usr/X11R6/bin/gv0 $ARGV[0]`;

Quote:
}

exit ($?);

__END__



Sat, 02 Aug 2003 12:46:10 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. GS/GV: What is highest res in PDF?

2. gv printing problem with pdf files

3. Printing PDF files with GhostView, GV.

4. gs 3.51 gv 1.5 and pdf -- problems

5. Official Patch 9 for Psroff 3.0 (emergency patch)

6. wrapper to print "Draft" on pages

7. PS Wrapper for color Tiff files

8. postscript/tiff wrapper

9. lp/lpr wrapper to allow ppd use?

10. TIFF to PS Wrapper

11. C wrapper library for creating Postscript files?

12. upload wrapper class

 

 
Powered by phpBB® Forum Software