Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7f7cbb08

Von Moritz Bunkus vor fast 17 Jahren hinzugefügt

  • ID 7f7cbb08e543fa1fcd549794f9b728d13d3907b1
  • Vorgänger ddda5f38
  • Nachfolger 222bbfe9

Funktion zum direkten Ausdrucken von PDF-Dokumenten aus dem ReportGenerator heraus auch mit mit der PDF::API2-Methode eingebaut.

Unterschiede anzeigen:

SL/ReportGenerator.pm
601 601
    }
602 602
  }
603 603

  
604
  my $filename = $self->get_attachment_basename();
604
  my $content = $pdf->stringify();
605 605

  
606
  print qq|content-type: application/pdf\n|;
607
  print qq|content-disposition: attachment; filename=${filename}.pdf\n\n|;
606
  my $printer_command;
607
  if ($params->{print} && $params->{printer_id}) {
608
    $form->{printer_id} = $params->{printer_id};
609
    $form->get_printer_code($myconfig);
610
    $printer_command = $form->{printer_command};
611
  }
612

  
613
  if ($printer_command) {
614
    $self->_print_content('printer_command' => $printer_command,
615
                          'content'         => $content,
616
                          'copies'          => $params->{copies});
617
    $form->{report_generator_printed} = 1;
618

  
619
  } else {
620
    my $filename = $self->get_attachment_basename();
621

  
622
    print qq|content-type: application/pdf\n|;
623
    print qq|content-disposition: attachment; filename=${filename}.pdf\n\n|;
608 624

  
609
  print $pdf->stringify();
625
    print $content;
626
  }
610 627
}
611 628

  
612 629
sub verify_paper_size {
......
712 729
    unlink $cfg_file_name, $html_file_name;
713 730

  
714 731
    if ($printer_command && $content) {
715
      foreach my $i (1 .. max $opt->{copies}, 1) {
716
        my $printer = IO::File->new("| ${printer_command}");
717
        if (!$printer) {
718
          $form->error($locale->text('Could not spawn the printer command.'));
719
        }
720
        $printer->print($content);
721
        $printer->close();
722
      }
723

  
732
      $self->_print_content('printer_command' => $printer_command,
733
                            'content'         => $content,
734
                            'copies'          => $opt->{copies});
724 735
      $form->{report_generator_printed} = 1;
725 736
    }
726 737

  
......
730 741
  }
731 742
}
732 743

  
744
sub _print_content {
745
  my $self   = shift;
746
  my %params = @_;
747

  
748
  foreach my $i (1 .. max $params{copies}, 1) {
749
    my $printer = IO::File->new("| $params{printer_command}");
750
    $main::form->error($main::locale->text('Could not spawn the printer command.')) if (!$printer);
751
    $printer->print($params{content});
752
    $printer->close();
753
  }
754
}
755

  
733 756
sub generate_pdf_content {
734 757
  my $self = shift;
735 758

  

Auch abrufbar als: Unified diff