Changeset 10357
- Timestamp:
- 2005-07-29T14:37:55+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/gsConvert.pl
r10282 r10357 137 137 my $stored_dir = cwd(); 138 138 chdir ($dirname) || die "Unable to change to directory $dirname"; 139 139 140 # Select convert utility 140 141 if (!defined $input_type) { … … 293 294 294 295 my $success = 0; 296 $output_type =~ s/.*\-(.*)/$1/i; 297 # Attempt coversion to Image 298 if ($output_type =~ /jp?g|gif|png/i) { 299 $success = &pdf_to_img($dirname, $input_filename, $output_filestem, $output_type); 300 if ($success){ 301 return "item"; 302 } 303 } 295 304 296 305 # Attempt conversion to HTML … … 335 344 sub convertPPT { 336 345 my ($input_filename, $output_filestem, $output_type) = @_; 337 338 346 my $success = 0; 347 339 348 my $ppt_convert_type = ""; 340 349 if (!$output_type || $windows_scripting ||($output_type !~ /html/i)){ … … 351 360 352 361 $cmd = ""; 353 #if ($timeout) {$cmd = "ulimit -t $timeout;";} 354 #$cmd .= "$vbScript \"$input_filename\" \"$output_filestem.html\""; 355 #$cmd .= "$vbScript $input_filename $output_filestem.html"; 362 if ($timeout) {$cmd = "ulimit -t $timeout;";} 356 363 # if the converting directory has already existed 357 364 if (-d $output_filestem) { … … 377 384 $cmd .= " 2>\"$output_filestem.err\"" 378 385 if ($ENV{'GSDLOS'} !~ /^windows$/i || $is_winnt_2000); 379 386 380 387 # execute the command 381 388 $!=0; … … 500 507 $cmd .= " 2> \"$output_filestem.err\"" 501 508 if ($ENV{'GSDLOS'} !~ /^windows$/i || $is_winnt_2000); 502 503 509 # execute the command 504 510 $!=0; … … 557 563 } 558 564 565 559 566 # Attempt to convert a word document to html with the word2html scripting program 560 567 sub native_doc_to_html { … … 628 635 return 0; 629 636 } 630 631 632 637 633 638 # Attempt to convert an RTF document to html with rtftohtml … … 805 810 return 0; 806 811 } 807 812 813 &util::rm("$output_filestem.err") if (-e "$output_filestem.err"); 814 &util::rm("$output_filestem.out") if (-e "$output_filestem.out"); 815 return 1; 816 } 817 818 # Convert a pdf file to various types of image with the convert command 819 820 sub pdf_to_img { 821 my ($dirname, $input_filename, $output_filestem, $output_type) = @_; 822 823 $cmd = ""; 824 if ($timeout) {$cmd = "ulimit -t $timeout;";} 825 $output_type =~ s/.*\_(.*)/$1/i; 826 $cmd .= "perl -S pdftoimg.pl -convert_to $output_type $input_filename $output_filestem"; 827 if ($ENV{'GSDLOS'} !~ /^windows$/i || $is_winnt_2000) { 828 $cmd .= " > \"$output_filestem.out\" 2> \"$output_filestem.err\""; 829 } else { 830 $cmd .= " > \"$output_filestem.err\""; 831 } 832 833 #print STDERR "*** gsConvert pdf_to_img Command =$cmd\n"; 834 835 # don't include path on windows (to avoid having to play about 836 # with quoting when GSDLHOME might contain spaces) but assume 837 # that the PATH is set up correctly 838 839 $!=0; 840 my $retval=system($cmd); 841 if ($retval!=0) 842 { 843 print STDERR "Error executing pdftohtml.pl"; 844 if ($!) {print STDERR ": $!";} 845 print STDERR "\n"; 846 } 847 848 #make sure the converter made something 849 #if ($retval!=0 || ! -s "$output_filestem.html") 850 #if ($retval !=0) || ! -s "$output_filestem") 851 if ($retval !=0) 852 { 853 &util::rm("$output_filestem.out") if (-e "$output_filestem.out"); 854 #print out the converter's std err, if any 855 if (-s "$output_filestem.err") { 856 open (ERRLOG, "$output_filestem.err") || die "$!"; 857 print STDERR "pdftohtml error log:\n"; 858 while (<ERRLOG>) { 859 print STDERR "$_"; 860 } 861 close ERRLOG; 862 } 863 &util::rm("$output_filestem.html") if (-e "$output_filestem.html"); 864 if (-e "$output_filestem.err") { 865 if ($faillogfile ne "" && defined(open(FAILLOG,">>$faillogfile"))) 866 { 867 open (ERRLOG, "$output_filestem.err"); 868 while (<ERRLOG>) {print FAILLOG $_;} 869 close ERRLOG; 870 close FAILLOG; 871 } 872 &util::rm("$output_filestem.err"); 873 } 874 return 0; 875 } 808 876 &util::rm("$output_filestem.err") if (-e "$output_filestem.err"); 809 877 &util::rm("$output_filestem.out") if (-e "$output_filestem.out"); … … 897 965 $cmd .= "gs -q -dNODISPLAY -dNOBIND -dWRITESYSTEMDICT -dSIMPLE -c save "; 898 966 $cmd .= "-f ps2ascii.ps \"$input_filename\" -c quit > \"$output_filestem.text\""; 967 #$cmd .= "pstotext -output \"$output_filestem.text\" $input_filename\""; 899 968 $cmd .= " 2> $output_filestem.err"; 900 969 $!=0; 970 901 971 my $retcode=system($cmd); 902 972 $retcode = $? >> 8; # see man perlfunc - system for this...
Note:
See TracChangeset
for help on using the changeset viewer.