Bugzilla – Attachment 9893 Details for
Bug 7952
PDF::Reuse under plack writes to console STDOUT instead to browser
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7952 - PDF::Reuse under plack writes to console STDOUT instead to browser
Bug-7952---PDFReuse-under-plack-writes-to-console-.patch (text/plain), 2.16 KB, created by
Dobrica Pavlinusic
on 2012-06-01 19:24:49 UTC
(
hide
)
Description:
Bug 7952 - PDF::Reuse under plack writes to console STDOUT instead to browser
Filename:
MIME Type:
Creator:
Dobrica Pavlinusic
Created:
2012-06-01 19:24:49 UTC
Size:
2.16 KB
patch
obsolete
>From 001d06901ac885e38efb6cdf0e2b1460a1bc3873 Mon Sep 17 00:00:00 2001 >From: Dobrica Pavlinusic <dpavlin@rot13.org> >Date: Fri, 13 Apr 2012 00:20:00 +0200 >Subject: [PATCH] Bug 7952 - PDF::Reuse under plack writes to console STDOUT instead to browser >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Without name option to prFile, PDF::Reuse opens '-' file which is real >console STDOUT on plack so pdf file gets emited to terminal instead of >sending it to browser. > >This change creates temporary file using File::Temp, pass it to PDF::Reuse >and then reads it back and prints it out for plack (or CGI) to pick up. > >DEBUG=1 it will debugging output > >Test secenario: > >1. Home ⺠Tools ⺠Patron Card Creator ⺠Manage Card Batches >2. select batch checkbox and click Export >3. select template and click Export >4. click on pdf file to download it >--- > C4/Creators/PDF.pm | 16 +++++++++++++++- > 1 files changed, 15 insertions(+), 1 deletions(-) > >diff --git a/C4/Creators/PDF.pm b/C4/Creators/PDF.pm >index 0aae09c..b3dd1dd 100644 >--- a/C4/Creators/PDF.pm >+++ b/C4/Creators/PDF.pm >@@ -21,6 +21,7 @@ use strict; > use warnings; > use PDF::Reuse; > use PDF::Reuse::Barcode; >+use File::Temp; > > BEGIN { > use version; our $VERSION = qv('1.0.0_1'); >@@ -42,7 +43,13 @@ sub new { > 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 >+ warn "## Name [$opts{Name}] $fh"; >+ >+ prFile(\%opts); > bless ($self, $type); > return $self; > } >@@ -52,6 +59,13 @@ sub End { > # 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 { >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7952
:
9161
|
9893
|
10042
|
10090
|
10126
|
10278