Skip to content

Commit

Permalink
Bug 8007: Replace HTML::HTMLDoc with PDF::FromHTML
Browse files Browse the repository at this point in the history
Signed-off-by: Lucie <lucie.rousseaux@dracenie.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
  • Loading branch information
joubu authored and tomascohen committed Apr 30, 2015
1 parent 5d7aae6 commit a72cda3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions C4/Installer/PerlDependencies.pm
Original file line number Diff line number Diff line change
Expand Up @@ -737,10 +737,10 @@ our $PERL_DEPS = {
'required' => '0',
'min_ver' => '5.61',
},
'HTML:HTMLDoc' => {
'PDF::FromHTML' => {
'usage' => 'Discharge generation',
'required' => '0',
'min_ver' => '0.07',
'min_ver' => '0.31',
},
};

Expand Down
16 changes: 11 additions & 5 deletions Koha/Borrower/Discharge.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package Koha::Borrower::Discharge;
use Modern::Perl;
use CGI;
use File::Temp qw( :POSIX );
use HTML::HTMLDoc;
use PDF::FromHTML;

use C4::Members qw( GetPendingIssues );
use C4::Reserves qw( GetReservesFromBorrowernumber CancelReserve );
Expand Down Expand Up @@ -108,10 +108,16 @@ sub generate_as_pdf {
messages => [$letter],
);

my $pdf_path = tmpnam();
my $htmldoc = new HTML::HTMLDoc();
$htmldoc->set_html_content($tmpl->output);
$htmldoc->generate_pdf()->to_file($pdf_path);
my $html_path = tmpnam() . '.html';
my $pdf_path = tmpnam() . '.pdf';
my $html_content = $tmpl->output;
open my $html_fh, '>', $html_path;
say $html_fh $html_content;
close $html_fh;
my $pdf = PDF::FromHTML->new( encoding => 'utf-8' );
$pdf->load_file( $html_path );
$pdf->convert;
$pdf->write_file( $pdf_path );

return $pdf_path;
}
Expand Down

0 comments on commit a72cda3

Please sign in to comment.