Bug 17600: Standardize our EXPORT_OK
[srvgit] / Koha / Patron / Discharge.pm
index 5add12d..8ad1696 100644 (file)
@@ -2,10 +2,11 @@ package Koha::Patron::Discharge;
 
 use Modern::Perl;
 use CGI;
-use File::Temp qw( :POSIX );
-use Carp;
+use File::Temp qw( tmpnam );
+use Carp qw( carp );
 
 use C4::Templates qw ( gettemplate );
+use C4::Letters qw( GetPreparedLetter );
 
 use Koha::Database;
 use Koha::DateUtils qw( dt_from_string output_pref );
@@ -117,7 +118,7 @@ sub generate_as_pdf {
     $letter->{'title'}   =~ s/<<today>>/$today/g;
     $letter->{'content'} =~ s/<<today>>/$today/g;
 
-    my $tmpl = C4::Templates::gettemplate('batch/print-notices.tt', 'intranet', new CGI);
+    my $tmpl = C4::Templates::gettemplate('batch/print-notices.tt', 'intranet', CGI->new);
     $tmpl->param(
         stylesheet => C4::Context->preference("NoticeCSS"),
         today      => $today,
@@ -141,7 +142,25 @@ sub generate_as_pdf {
     else {
         my $pdf = PDF::FromHTML->new( encoding => 'utf-8' );
         $pdf->load_file( $html_path );
-        $pdf->convert;
+
+        my $ttf = C4::Context->config('ttf');
+        if ( $ttf  && exists $ttf->{font} ) {
+
+            my $type2path;
+            foreach my $font ( @{ $ttf->{font} } ) {
+                    $type2path->{ $font->{type} } = $font->{content};
+            }
+
+            $pdf->convert(
+                FontBold          => $type2path->{'HB'} || 'HelveticaBold',
+                FontOblique       => $type2path->{'HO'} || 'HelveticaOblique',
+                FontBoldOblique   => $type2path->{'HBO'}|| 'HelveticaBoldOblique',
+                FontUnicode       => $type2path->{'H'}  || 'Helvetica',
+                Font              => $type2path->{'H'}  || 'Helvetica',
+            );
+        } else {
+            $pdf->convert();
+        }
         $pdf->write_file( $pdf_path );
     }