Revision 7f7cbb08
Von Moritz Bunkus vor etwa 17 Jahren hinzugefügt
SL/ReportGenerator.pm | ||
---|---|---|
}
|
||
}
|
||
|
||
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 {
|
||
... | ... | |
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;
|
||
}
|
||
|
||
... | ... | |
}
|
||
}
|
||
|
||
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;
|
||
|
Auch abrufbar als: Unified diff
Funktion zum direkten Ausdrucken von PDF-Dokumenten aus dem ReportGenerator heraus auch mit mit der PDF::API2-Methode eingebaut.