[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm printout.pl
raeburn
raeburn at source.lon-capa.org
Sat Nov 9 11:08:15 EST 2024
raeburn Sat Nov 9 16:08:15 2024 EDT
Modified files:
/loncom/interface lonprintout.pm printout.pl
Log:
- Bug 6880
- Reduce amount of vertical space at top of each page for RHEL/Oracle/CentOS
7 or later.
- Twelve combinations of orientation (portrait or landscape), columns (1 or 2),
paper (letter, legal or a4) now supported.
- Use pstops instead of psnup for 2-column landscape for newer psnup version 2
which does not support scale arg (RHEL/Oracle/Alma/Rocky/CentOS-Stream 9).
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.700 loncom/interface/lonprintout.pm:1.701
--- loncom/interface/lonprintout.pm:1.700 Sat Nov 9 15:40:00 2024
+++ loncom/interface/lonprintout.pm Sat Nov 9 16:08:15 2024
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.700 2024/11/09 15:40:00 raeburn Exp $
+# $Id: lonprintout.pm,v 1.701 2024/11/09 16:08:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1861,12 +1861,12 @@
my %page_formats=
('letter' => {
'book' => {
- '1' => [ '7.1 in','9.8 in', '-0.57 in','-0.57 in','0.275 in'],
- '2' => ['3.66 in','9.8 in', '-0.57 in','-0.57 in','0.275 in']
+ '1' => [ '7.1 in','9.7 in', '-0.57 in','-0.57 in','0.1 in'],
+ '2' => ['3.66 in','9.7 in', '-0.57 in','-0.57 in','0.1 in']
},
'album' => {
- '1' => [ '8.8 in', '6.8 in','-0.55 in', '-0.55 in','0.394 in'],
- '2' => [ '4.8 in', '6.8 in','-0.5 in', '-1.0 in','3.0 in']
+ '1' => [ '8.8 in', '6.8 in','-0.55 in', '-0.55 in','-0.5 in'],
+ '2' => [ '4.8 in', '6.7 in','-0.5 in', '-1.0 in','3.0 in']
},
},
'legal' => {
@@ -1876,7 +1876,7 @@
},
'album' => {
'1' => ['12 in','7.1 in',,'-0.57 in','-0.57 in','-0.5 in'],
- '2' => ['6.0 in','7.1 in','-1 in','-1 in','5 in']
+ '2' => ['5.7 in','7.1 in','-1 in','-1 in','5 in']
},
},
'tabloid' => {
@@ -1925,8 +1925,8 @@
'2' => [ '9.1 cm','27.2 cm','-1.397 cm','-2.11 cm','-1.27 cm']
},
'album' => {
- '1' => ['21.59 cm','19.558 cm','-1.397cm','-2.11 cm','0 cm'],
- '2' => ['9.91 cm','19.558 cm','-1.397 cm','-2.11 cm','-1 cm']
+ '1' => ['24.0 cm','18.0 cm','-1.0cm','-1.5 cm','-1.25 cm'],
+ '2' => ['9.91 cm','18.0 cm','-0.7 cm','-1.7 cm','-1.25 cm']
},
},
'a5' => {
Index: loncom/interface/printout.pl
diff -u loncom/interface/printout.pl:1.176 loncom/interface/printout.pl:1.177
--- loncom/interface/printout.pl:1.176 Fri Nov 1 00:08:03 2024
+++ loncom/interface/printout.pl Sat Nov 9 16:08:15 2024
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# CGI-script to run LaTeX, dvips, ps2ps, ps2pdf etc.
#
-# $Id: printout.pl,v 1.176 2024/11/01 00:08:03 raeburn Exp $
+# $Id: printout.pl,v 1.177 2024/11/09 16:08:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -161,6 +161,36 @@
}
}
+sub get_pstops_offsets {
+ my ($paper) = @_;
+ my ($origwidth,$origheight,$origunits,$ptype,$xoff,$yoffl,$yoffr);
+ $ptype = "-p$paper";
+ if ($paper eq 'letter') {
+ $origwidth = 11.0;
+ $origheight = 8.5;
+ $origunits = 'in';
+ $xoff = $origheight - 0.9;
+ $yoffl = 0.0;
+ } elsif ($paper eq 'legal') {
+ $ptype = '';
+ $origwidth = 14.0;
+ $origheight = 8.5;
+ $origunits = 'in';
+ $xoff = $origheight - 3.0;
+ $yoffl = 0.5;
+ } elsif ($paper eq 'a4') {
+ $origwidth = 29.7;
+ $origheight = 21.0;
+ $origunits = 'cm';
+ $xoff = $origheight;
+ $yoffl = 0.7;
+ }
+ if (($origwidth ne '') && ($yoffl ne '')) {
+ $yoffr = $origwidth/2 + $yoffl;
+ }
+ return ($ptype,$xoff,$yoffl,$yoffr,$origunits);
+}
+
$|=1;
if (! &LONCAPA::loncgi::check_cookie_and_load_env()) {
print <<END;
@@ -448,7 +478,8 @@
# Explicitly include a switch for papertype, otherwise dvips will default
# to whatever is listed first in config.ps (which in most cases is a4).
my $papera;
- unless (($paper eq '') || (($laystyle eq 'album') && ($numberofcolumns eq '1'))) {
+ unless (($paper eq '') ||
+ (($laystyle eq 'album') && ($numberofcolumns eq '1'))) {
$papera='-t'.$paper;
}
my $extra_ps_header = $perlvar{'lonLib'} .'/includepsheader.ps';
@@ -573,21 +604,32 @@
if (open(PIPE,"psnup --version 2>&1 |")) {
while (<PIPE>) {
chomp();
- if (/^psnup\s+release\s+(\d+)/) {
- if ($1 < 2) {
- $canscale = 1;
- }
- last;
- }
+ next if (/pstops:\s+invalid\s+option/);
+ if (/^psnup\s+release\s+(\d+)\s+patchlevel\s+(\d+)/) {
+ if (($1 == 1) && ($2 < 90)) {
+ $canscale = 1;
+ }
+ last;
+ } elsif (/^psnup\s+(\d+)\.(\d+)/) {
+ if (($1 == 1) && ($2 < 90)) {
+ $canscale = 1;
+ }
+ last;
+ }
}
close(PIPE);
}
if ($canscale) {
$comma = "psnup $papera -2 -s1.0 $new_name_file";
+ &debug("PSNUP command: $comma");
+ } elsif (($paper eq 'letter') || ($paper eq 'legal') || ($paper eq 'a4')) {
+ my ($ptype,$xoff,$yoffl,$yoffr,$units) = &get_pstops_offsets($paper);
+ $comma = "pstops $ptype '2:0L\@1.0($xoff$units,$yoffl$units)+1L\@1.0($xoff$units,$yoffr$units)' $new_name_file";
+ &debug("PSTOPS command: $comma");
} else {
$comma = "psnup $papera -2 $new_name_file";
+ &debug("PSNUP command: $comma");
}
- &debug("PSNUP command: $comma");
&busy_wait_command("$comma $tempo_file 1>/dev/null 2>/dev/null",
"for $status_statement now Modifying PS layout",
\%prog_state,$tempo_file);
More information about the LON-CAPA-cvs
mailing list