use warnings;
use PDF::Reuse;
use PDF::Reuse::Barcode;
+use File::Temp;
BEGIN {
- use version; our $VERSION = qv('1.0.0_1');
+ use version; our $VERSION = qv('3.07.00.049');
}
sub _InitVars {
delete($opts{InitVars});
prDocDir($opts{'DocDir'}) if $opts{'DocDir'};
delete($opts{'DocDir'});
- prFile(%opts);
+
+ my $fh = File::Temp->new( UNLINK => 0, SUFFIX => '.pdf' );
+ $opts{Name} = $self->{filename} = "$fh"; # filename
+ close $fh; # we need just filename
+
+ prFile(\%opts);
bless ($self, $type);
return $self;
}
# if the pdf stream is utf8, explicitly set it to utf8; this avoids at lease some wide character errors -chris_n
utf8::encode($PDF::Reuse::stream) if utf8::is_utf8($PDF::Reuse::stream);
prEnd();
+
+ # slurp temporary filename and print it out for plack to pick up
+ local $/ = undef;
+ open(my $fh, '<', $self->{filename}) || die "$self->{filename}: $!";
+ print <$fh>;
+ close $fh;
+ unlink $self->{filename};
}
sub Add {
{ my ($iData, $iWidth, $iHeight, $iFormat,$aiData, $aiWidth, $aiHeight, $aiFormat) = @_;
my ($namnet, $utrad);
if (! $PDF::Reuse::pos) # If no output is active, it is no use to continue
- { return undef;
+ { return;
}
prJpegBlob($aiData, $aiWidth, $aiHeight, $aiFormat);
my $altObjNr = $PDF::Reuse::objNr;
{ my ($iData, $iWidth, $iHeight, $iFormat, $altArrayObjNr) = @_;
my ($iLangd, $namnet, $utrad);
if (! $PDF::Reuse::pos) # If no output is active, it is no use to continue
- { return undef;
+ { return;
}
my $checkidOld = $PDF::Reuse::checkId;
if (!$iFormat)
$namnet = 'Ig' . $PDF::Reuse::imageNr;
$PDF::Reuse::objNr++;
$PDF::Reuse::objekt[$PDF::Reuse::objNr] = $PDF::Reuse::pos;
- open (BILDFIL, "<$iFile") || errLog("Couldn't open $iFile, $!, aborts");
- binmode BILDFIL;
+ open (my $fh, '<', "$iFile") || errLog("Couldn't open $iFile, $!, aborts");
+ binmode $fh;
my $iStream;
- sysread BILDFIL, $iStream, $iLangd;
+ sysread $fh, $iStream, $iLangd;
$utrad = "$PDF::Reuse::objNr 0 obj\n<</Type/XObject/Subtype/Image/Name/$namnet" .
"/Width $iWidth /Height $iHeight /BitsPerComponent 8 " .
($altArrayObjNr ? "/Alternates $altArrayObjNr 0 R " : "") .
"/Filter/DCTDecode/ColorSpace/DeviceRGB"
. "/Length $iLangd >>stream\n$iStream\nendstream\nendobj\n";
- close BILDFIL;
+ close $fh;
$PDF::Reuse::pos += syswrite $PDF::Reuse::UTFIL, $utrad;
if ($PDF::Reuse::runfil)
{ $PDF::Reuse::log .= "Cid~$PDF::Reuse::checkId\n";