Diff for /loncom/interface/printout.pl between versions 1.142.6.3 and 1.149

version 1.142.6.3, 2010/05/11 12:10:25 version 1.149, 2011/05/18 11:26:44
Line 44  use LONCAPA::Configuration; Line 44  use LONCAPA::Configuration;
 use strict;  use strict;
   
 my $busy_wait_timeout = 30;   my $busy_wait_timeout = 30; 
   my $pdfs_converted    = 0; # non zero if PDF includes (need to fixps).
   
 my $debugging = 0;  my $debugging = 0;
   
Line 178  my %perlvar=%{&LONCAPA::Configuration::r Line 178  my %perlvar=%{&LONCAPA::Configuration::r
 &Apache::lonlocal::get_language_handle();  &Apache::lonlocal::get_language_handle();
 &Apache::loncommon::content_type(undef,'text/html');  &Apache::loncommon::content_type(undef,'text/html');
 $env{'request.noversionuri'} = '/cgi-bin/printout.pl';  $env{'request.noversionuri'} = '/cgi-bin/printout.pl';
 print(&Apache::loncommon::start_page('Creating PDF'));  # Breadcrumbs
   #FIXME: Choose better/different breadcrumbs?!? Links?
   my $brcrum = [{'href' => '',
                  'text' => 'Helper'}, #FIXME: Different origin possible than print out helper?
                 {'href' => '',
                  'text' => 'Preparing Printout'},
                 {'href' => '',
                  'text' => 'Creating PDF'}];
   print(&Apache::loncommon::start_page('Creating PDF',
                                        undef,
                                        {'bread_crumbs' => $brcrum,}));
   
 my $identifier = $ENV{'QUERY_STRING'};  my $identifier = $ENV{'QUERY_STRING'};
 my $texfile = $env{'cgi.'.$identifier.'.file'};  my $texfile = $env{'cgi.'.$identifier.'.file'};
Line 467  foreach $texfile (@texfile) { Line 477  foreach $texfile (@texfile) {
       my $ps_file = my $tempo_file = $1.'temporar.ps';        my $ps_file = my $tempo_file = $1.'temporar.ps';
       my $pdf_file = $1.'.pdf';        my $pdf_file = $1.'.pdf';
       $papera=~s/t/p/;        $papera=~s/t/p/;
               $comma = "fixps --force $new_name_file";  #----
               &debug("FIXPS command: $comma");  # The code below uses fixps to make pdf include in sequences work.
               &busy_wait_command("$comma 1>/dev/null 2>/dev/null",  #
                                  "for $status_statement now validating PS",  #              $comma = "fixps --force $new_name_file";
                                  \%prog_state,$tempo_file);  #              &debug("FIXPS command: $comma");
   #              &busy_wait_command("$comma 1>$tempo_file  2>/dev/null",
   #                                 "for $status_statement now validating PS",
   #                                 \%prog_state,$tempo_file);
   
   #--- 
   #  The code below uses gs to make pdf includes in sequences work
   
         # Use gs to fix the postscript -> level 1.5 
         # .. if pdfs were included
   
         if ($pdfs_converted > 0) {
     $comma = "gs -sDEVICE=pswrite -dLanguageLevel=1.5 ";
     &busy_wait_command("$comma -o $tempo_file $new_name_file 2>/dev/null 1>/dev/null",
        "for $status_statement now validating PS",
        \%prog_state, $tempo_file);
     
   #---
     &busy_wait_command("mv $tempo_file $new_name_file",
        'File move', \%prog_state, $new_name_file);
         }
       if ($laystyle eq 'album' and $numberofcolumns eq '2') {        if ($laystyle eq 'album' and $numberofcolumns eq '2') {
   $comma = "psnup $papera -2 -s1.0 $new_name_file";    $comma = "psnup $papera -2 -s1.0 $new_name_file";
   &debug("PSNUP command: $comma");    &debug("PSNUP command: $comma");
                   &busy_wait_command("$comma 1>$tempo_file 2>/dev/null",    &busy_wait_command("$comma $tempo_file 1>/dev/null 2>/dev/null",
      "for $status_statement now Modifying PS layout",       "for $status_statement now Modifying PS layout",
      \%prog_state,$tempo_file);       \%prog_state,$tempo_file);
           &busy_wait_command("mv $tempo_file $new_name_file",  
      'File move', \%prog_state, $new_name_file);  
       } elsif ($laystyle eq 'book' and $numberofcolumns eq '2') {        } elsif ($laystyle eq 'book' and $numberofcolumns eq '2') {
   $comma = 'pstops '.$papera.' "2:0+1(0.48w,0)" '.$new_name_file;    $comma = 'pstops '.$papera.' "2:0+1(0.48w,0)" '.$new_name_file;
   &debug("PSTOPS command: $comma ");    &debug("PSTOPS command: $comma ");
Line 901  sub convert_figure { Line 929  sub convert_figure {
  $not_eps =~ s/^\s+//;   $not_eps =~ s/^\s+//;
  $not_eps =~ s/\s+$//;   $not_eps =~ s/\s+$//;
  $not_eps =~ s/ /\\ /g;   $not_eps =~ s/ /\\ /g;
       my $prettyname=$not_eps;
  if ($advanced_role) {   if ($advanced_role) {
     my $prettyname=$not_eps;  
     $prettyname=~s|/home/([^/]+)/public_html|/priv/$1|;      $prettyname=~s|/home/([^/]+)/public_html|/priv/$1|;
     $prettyname=~s|$perlvar{'lonDocRoot'}/|/|;      $prettyname=~s|$perlvar{'lonDocRoot'}/|/|;
     &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state,      &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state,
Line 923  sub convert_figure { Line 951  sub convert_figure {
   
     &debug("Converting pdf $not_eps to postscript: $eps_f");      &debug("Converting pdf $not_eps to postscript: $eps_f");
     system("pdftops $not_eps $eps_f");      system("pdftops $not_eps $eps_f");
       $pdfs_converted++; # Need to fix ps in last pass.
  } else {   } else {
     system("convert $not_eps $eps_f");      system("convert $not_eps $eps_f");
           if($? and $advanced_role){
               print "<p class=\"LC_warning\">"
                     .mt("An error occured during the conversion of [_1].[_2]"
                     ."If possible try to save this image using different settings and republish it.",
                     "<span class=\"LC_filename\">".$prettyname."</span>", "<br/>")
                     ."</p>";
           }
  }   }
   
  if (not -e $eps_f) {   if (not -e $eps_f) {

Removed from v.1.142.6.3  
changed lines
  Added in v.1.149


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>