Changeset 10401


Ignore:
Timestamp:
2005-08-03T12:36:02+12:00 (19 years ago)
Author:
chi
Message:

Modifications to allow PDF documents being converted to various image files (e.g. gif, jpg, png)
through 'convert' utility, Then, PagedImgPlug could be used to demonstrate the documents. So now,
the user can set up the type of conversion in -convert_to option. For example,
-convert_to html: through pdftohtml.pl
-convert_to pagedimg_gif(jpg/png): through pdftoimg.pl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/gsConvert.pl

    r10357 r10401  
    215215    if (!$output_type || ($output_type =~ /html/i)){
    216216    if ($windows_scripting) {
    217         print STDERR "***** Calling VB Script!\n";
    218217        $success = &native_doc_to_html($input_filename, $output_filestem);
    219218    }
    220219    else {
    221         print STDERR "**** Calling wvWare\n";
    222220        $success = &doc_to_html($input_filename, $output_filestem);   
    223221    }
     
    820818sub pdf_to_img {
    821819    my ($dirname, $input_filename, $output_filestem, $output_type) = @_;
    822  
     820
     821    # Check that ImageMagick is installed and available on the path (except for Windows 95/98)
     822    if (!($ENV{'GSDLOS'} eq "windows" && !Win32::IsWinNT())) {
     823    my $result = `identify 2>&1`;
     824    if ($? == -1 || $? == 256) {  # Linux and Windows return different values for "program not found"
     825        #ImageMagick is not installed, thus the convert utility is not available.
     826        print STDERR "*** ImageMagick is not installed, the convert utility is not available\n";
     827        return 0;
     828    }
     829    }
     830
    823831    $cmd = "";
    824832    if ($timeout) {$cmd = "ulimit -t $timeout;";}
     
    831839    }
    832840
    833     #print STDERR "*** gsConvert pdf_to_img Command =$cmd\n";
    834    
    835841    # don't include path on windows (to avoid having to play about
    836842    # with quoting when GSDLHOME might contain spaces) but assume
    837843    # that the PATH is set up correctly
    838    
    839844    $!=0;
    840845    my $retval=system($cmd);
    841846    if ($retval!=0)
    842847    {
    843     print STDERR "Error executing pdftohtml.pl";
     848    print STDERR "Error executing pdftoimg.pl";
    844849    if ($!) {print STDERR ": $!";}
    845850    print STDERR "\n";
     
    847852
    848853    #make sure the converter made something
    849     #if ($retval!=0 || ! -s "$output_filestem.html")
    850854    #if ($retval !=0) || ! -s "$output_filestem")
    851855    if ($retval !=0)
     
    855859    if (-s "$output_filestem.err") {
    856860        open (ERRLOG, "$output_filestem.err") || die "$!";
    857         print STDERR "pdftohtml error log:\n";
     861        print STDERR "pdftoimg error log:\n";
    858862        while (<ERRLOG>) {
    859863        print STDERR "$_";
Note: See TracChangeset for help on using the changeset viewer.