From a72cda3d9d5a89957c2b86d841da97f34c38b6a8 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 18 Dec 2014 15:39:46 +0100 Subject: [PATCH] Bug 8007: Replace HTML::HTMLDoc with PDF::FromHTML Signed-off-by: Lucie Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- C4/Installer/PerlDependencies.pm | 4 ++-- Koha/Borrower/Discharge.pm | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm index 0853ef357d..79cbc14a2d 100644 --- a/C4/Installer/PerlDependencies.pm +++ b/C4/Installer/PerlDependencies.pm @@ -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', }, }; diff --git a/Koha/Borrower/Discharge.pm b/Koha/Borrower/Discharge.pm index 6027e7ecc0..1665bc74e6 100644 --- a/Koha/Borrower/Discharge.pm +++ b/Koha/Borrower/Discharge.pm @@ -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 ); @@ -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; } -- 2.39.5