two-sided printing of invoice batches, #29927
[freeside.git] / FS / FS / bill_batch.pm
index fb41e0e..d4f2aec 100644 (file)
@@ -61,6 +61,8 @@ sub print_pdf {
   my @invoices = sort { $a->invnum <=> $b->invnum } $self->cust_bill_batch;
   return "No invoices in batch ".$self->batchnum.'.' if !@invoices;
 
+  my $duplex = FS::Conf->exists('invoice_print_pdf-duplex');
+
   my $pdf_out;
   my $num = 0;
   foreach my $invoice (@invoices) {
@@ -73,6 +75,13 @@ sub print_pdf {
     else {
       $pdf_out = CAM::PDF->new($part);
     }
+    if ( $duplex ) {
+      my $n = $pdf_out->numPages;
+      if ( $n % 2 == 1 ) {
+        # then insert a blank page so we end on an even number
+        $pdf_out->duplicatePage($n, 1);
+      }
+    }
     if($job) {
       # update progressbar
       $num++;