[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm printout.pl

raeburn raeburn at source.lon-capa.org
Thu Mar 12 00:21:40 EDT 2026


raeburn		Thu Mar 12 04:21:40 2026 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm printout.pl 
  Log:
  - Bug 6121
    When using ps2pdf to create a PDF with Form Fields set CompatibilityLevel
    to 1.5 to support additional PDF viewers besides Adobe Acrobat Reader. 
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.713 loncom/interface/lonprintout.pm:1.714
--- loncom/interface/lonprintout.pm:1.713	Fri Feb  6 20:30:06 2026
+++ loncom/interface/lonprintout.pm	Thu Mar 12 04:21:40 2026
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.713 2026/02/06 20:30:06 raeburn Exp $
+# $Id: lonprintout.pm,v 1.714 2026/03/12 04:21:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3760,7 +3760,10 @@
 				"cgi.$identifier.courseid" => $cnum,
 				"cgi.$identifier.coursedom" => $cdom,
 				"cgi.$identifier.resources" => $resources_printed});
-	
+    if (&can_use_pdfforms($helper) && $pdfFormFields) {
+        &Apache::lonnet::appenv({'cgi.'.$identifier.'.pdfFormFields' => $pdfFormFields});
+    }
+
     my $end_page = &Apache::loncommon::end_page();
     my $continue_text = &mt('Continue');
     # If there's been an unrecoverable SSI error, report it to the user
@@ -3784,6 +3787,19 @@
     }                                     # endif ssi errors.
 }
 
+sub can_use_pdfforms {
+    my ($helper) = @_;
+    my $canuseforms;
+    if ($helper->{VARS}->{'construction'}) {
+        if ($helper->{VARS}->{'filename'} =~ m{^/priv/($LONCAPA::match_domain)/}) {
+            my %domdefs = &Apache::lonnet::get_domain_defaults($1);
+            return $domdefs{'canuse_pdfforms'};
+        }
+    } elsif ($env{'request.course.id'}) {
+        return &Apache::loncommon::pdfforms_allowed();
+    }
+    return;
+}
 
 sub get_CODE {
     my ($all_codes,$num,$seed,$size,$type)=@_;
@@ -5369,15 +5385,7 @@
 sub render {
     my $self = shift;
     my $helper = Apache::lonhelper::getHelper();
-    my $canuseforms;
-    if ($helper->{VARS}->{'construction'}) {
-        if ($helper->{VARS}->{'filename'} =~ m{^/priv/($LONCAPA::match_domain)/}) {
-            my %domdefs = &Apache::lonnet::get_domain_defaults($1);
-            $canuseforms = $domdefs{'canuse_pdfforms'};
-        }
-    } elsif ($env{'request.course.id'}) {
-        $canuseforms = &Apache::loncommon::pdfforms_allowed();
-    }
+    my $canuseforms = &Apache::lonprintout::can_use_pdfforms($helper);
     my $result = '';
     my $var = $self->{'variable'};
     my $PageLayout=&mt('Page layout');
Index: loncom/interface/printout.pl
diff -u loncom/interface/printout.pl:1.178 loncom/interface/printout.pl:1.179
--- loncom/interface/printout.pl:1.178	Sun Dec  7 21:27:06 2025
+++ loncom/interface/printout.pl	Thu Mar 12 04:21:40 2026
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # CGI-script to run LaTeX, dvips, ps2ps, ps2pdf etc.
 #
-# $Id: printout.pl,v 1.178 2025/12/07 21:27:06 raeburn Exp $
+# $Id: printout.pl,v 1.179 2026/03/12 04:21:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -227,6 +227,7 @@
 my $laystyle = $env{'cgi.'.$identifier.'.layout'};
 my $numberofcolumns = $env{'cgi.'.$identifier.'.numcol'};
 my $paper = $env{'cgi.'.$identifier.'.paper'};
+my $pdfFormFields = $env{'cgi.'.$identifier.'.pdfFormFields'};
 my $selectionmade = $env{'cgi.'.$identifier.'.selection'};
 my $tableofcontents = $env{'cgi.'.$identifier.'.tableofcontents'};
 my $tableofindex = $env{'cgi.'.$identifier.'.tableofindex'};
@@ -686,7 +687,11 @@
                   }
               }
               $ps_file=$new_ps_file;
-	      &busy_wait_command("ps2pdf13 $ps_file $pdf_file 1>/dev/null 2>/dev/null",
+              $comma = 'ps2pdf13';
+              if ($pdfFormFields eq 'yes') {
+                  $comma = 'ps2pdf -dCompatibilityLevel=1.5';
+              }
+              &busy_wait_command("$comma $ps_file $pdf_file 1>/dev/null 2>/dev/null",
 				 "for $status_statement now Converting PS to PDF",
 				 \%prog_state,$pdf_file);
               # unlink ps file after use as it can be large




More information about the LON-CAPA-cvs mailing list