From 7f7cbb08e543fa1fcd549794f9b728d13d3907b1 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 22 Jan 2008 16:49:54 +0000 Subject: [PATCH] Funktion zum direkten Ausdrucken von PDF-Dokumenten aus dem ReportGenerator heraus auch mit mit der PDF::API2-Methode eingebaut. --- SL/ReportGenerator.pm | 49 +++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/SL/ReportGenerator.pm b/SL/ReportGenerator.pm index 2a40ab5e1..b02830230 100644 --- a/SL/ReportGenerator.pm +++ b/SL/ReportGenerator.pm @@ -601,12 +601,29 @@ sub render_pdf_with_pdf_api2 { } } - my $filename = $self->get_attachment_basename(); + my $content = $pdf->stringify(); - print qq|content-type: application/pdf\n|; - print qq|content-disposition: attachment; filename=${filename}.pdf\n\n|; + my $printer_command; + if ($params->{print} && $params->{printer_id}) { + $form->{printer_id} = $params->{printer_id}; + $form->get_printer_code($myconfig); + $printer_command = $form->{printer_command}; + } + + if ($printer_command) { + $self->_print_content('printer_command' => $printer_command, + 'content' => $content, + 'copies' => $params->{copies}); + $form->{report_generator_printed} = 1; + + } else { + my $filename = $self->get_attachment_basename(); + + print qq|content-type: application/pdf\n|; + print qq|content-disposition: attachment; filename=${filename}.pdf\n\n|; - print $pdf->stringify(); + print $content; + } } sub verify_paper_size { @@ -712,15 +729,9 @@ END unlink $cfg_file_name, $html_file_name; if ($printer_command && $content) { - foreach my $i (1 .. max $opt->{copies}, 1) { - my $printer = IO::File->new("| ${printer_command}"); - if (!$printer) { - $form->error($locale->text('Could not spawn the printer command.')); - } - $printer->print($content); - $printer->close(); - } - + $self->_print_content('printer_command' => $printer_command, + 'content' => $content, + 'copies' => $opt->{copies}); $form->{report_generator_printed} = 1; } @@ -730,6 +741,18 @@ END } } +sub _print_content { + my $self = shift; + my %params = @_; + + foreach my $i (1 .. max $params{copies}, 1) { + my $printer = IO::File->new("| $params{printer_command}"); + $main::form->error($main::locale->text('Could not spawn the printer command.')) if (!$printer); + $printer->print($params{content}); + $printer->close(); + } +} + sub generate_pdf_content { my $self = shift; -- 2.20.1