Lines 5-10
Link Here
|
5 |
# Initial implementation |
5 |
# Initial implementation |
6 |
# 1.10 - 2006-09-27/Bl |
6 |
# 1.10 - 2006-09-27/Bl |
7 |
# Alternatively, use Adobe Reader in place of Xpdf's pdftops |
7 |
# Alternatively, use Adobe Reader in place of Xpdf's pdftops |
|
|
8 |
# 1.20 - 2007-12-03/Bl |
9 |
# Safe temp file creation (fix gentoo bug # 201042) |
8 |
# |
10 |
# |
9 |
# Copyright: Helge Blischke / SRZ Berlin 2004-2006 |
11 |
# Copyright: Helge Blischke / SRZ Berlin 2004-2006 |
10 |
# This program is free seoftware and governed by the GNU Public License Version 2. |
12 |
# This program is free seoftware and governed by the GNU Public License Version 2. |
Lines 93-99
Link Here
|
93 |
$default_app = 'use-pdftops'; # the default if both are configured |
95 |
$default_app = 'use-pdftops'; # the default if both are configured |
94 |
# ---------------------------------------------------------------------------------- |
96 |
# ---------------------------------------------------------------------------------- |
95 |
|
97 |
|
96 |
use File::Copy; |
98 |
use File::Temp qw( tempfile ); |
97 |
|
99 |
|
98 |
# |
100 |
# |
99 |
# Check which app to use - pdftops or acroread |
101 |
# Check which app to use - pdftops or acroread |
Lines 149-163
Link Here
|
149 |
# as the PDF consumer needs a seekable input. |
151 |
# as the PDF consumer needs a seekable input. |
150 |
if (! defined $pdffile) |
152 |
if (! defined $pdffile) |
151 |
{ |
153 |
{ |
152 |
my $tmpfile = $ENV{TMPDIR} . "pdfin.$$.tmp"; |
154 |
my $template = "pdfinXXXXXX"; |
153 |
open (TEMP, ">$tmpfile") || die ("ERROR: pdftops wrapper: $tmpfile: $!\n"); |
155 |
my $tmpdir = $ENV{TMPDIR}; |
154 |
if (! copy (STDIN, TEMP)) |
156 |
my ($bytes, $buffer); |
|
|
157 |
my ($tmpfh, $tmpfile) = tempfile ($template, OPEN => 1, DIR => $tmpdir, UNLINK => 0, SUFFIX => '.tmp'); |
158 |
while (($bytes = read (STDIN, $buffer, 1024)) > 0) |
155 |
{ |
159 |
{ |
156 |
close (TEMP); |
160 |
print $tmpfh "$buffer"; |
|
|
161 |
} |
162 |
if ($bytes < 0) |
163 |
{ |
164 |
close ($tmpfh); |
157 |
unlink $tmpfile; |
165 |
unlink $tmpfile; |
158 |
die ("ERROR: pdftops wrapper: $tmpfile: $!\n"); |
166 |
die ("ERROR: pdftops wrapper: $tmpfile: $!\n"); |
159 |
} |
167 |
} |
160 |
close (TEMP); |
168 |
close ($tmpfh); |
161 |
$pdffile = $tmpfile; |
169 |
$pdffile = $tmpfile; |
162 |
$delete_input = 1; # for deleting the temp file after converting |
170 |
$delete_input = 1; # for deleting the temp file after converting |
163 |
} |
171 |
} |