Index: main/trunk/greenstone2/bin/script/gsConvert.pl
===================================================================
--- main/trunk/greenstone2/bin/script/gsConvert.pl	(revision 32263)
+++ main/trunk/greenstone2/bin/script/gsConvert.pl	(revision 32273)
@@ -61,4 +61,5 @@
 
 my $use_strings;
+my $pdf_tool;
 my $pdf_complex;
 my $pdf_nohidden;
@@ -77,8 +78,9 @@
     print STDERR "  options:\n\t-type\tdoc|dot|pdf|ps|ppt|rtf|xls\t(input file type)\n";
     print STDERR "\t-errlog\t<filename>\t(append err messages)\n";
-    print STDERR "\t-output\tauto|html|text|pagedimg_jpg|pagedimg_gif|pagedimg_png\t(output file type)\n";
+    print STDERR "\t-output\tauto|html|paged_html|text|pagedimg_jpg|pagedimg_gif|pagedimg_png\t(output file type)\n";
     print STDERR "\t-timeout\t<max cpu seconds>\t(ulimit on unix systems)\n";
     print STDERR "\t-use_strings\tuse strings to extract text if conversion fails\n";
     print STDERR "\t-windows_scripting\tuse windows VB script (if available) to convert Microsoft Word and PPT documents\n";
+    print STDERR "\t-pdf_tool\tpdftohtml|xpdftools|pdfbox (not all output types are supported by every pdf_tool)\n";
     print STDERR "\t-pdf_complex\tuse complex output when converting PDF to HTML\n";
     print STDERR "\t-pdf_nohidden\tDon't attempt to extract hidden text from PDF files\n";
@@ -120,10 +122,11 @@
 			 "type/$type_re/", \$input_type,
 			 '/errlog/.*/', \$faillogfile,
-			 'output/(auto|html|text|pagedimg).*/', \$output_type,
+			 'output/(auto|html|text|pagedimg).*/', \$output_type, # regex includes html_multi and paged_html besides html
 			 'timeout/\d+/0',\$timeout,
 			 'verbose/\d+/0', \$verbose,
 			 'windows_scripting',\$windows_scripting,
 			 'use_strings', \$use_strings,
-			 'pdf_complex', \$pdf_complex,
+			 'pdf_tool/(pdftohtml|pdfbox|xpdftools)/', \$pdf_tool, # the old pdftohtml tool, pdfbox extensions or the newer xpdf-tools
+			 'pdf_complex', \$pdf_complex, # options for pdf_tool = pdftohtml (the old pdftohtml tool)
 			 'pdf_ignore_images', \$pdf_ignore_images,
 			 'pdf_allow_images_only', \$pdf_allow_images_only,
@@ -315,4 +318,11 @@
     my $success = 0;
     $output_type =~ s/.*\-(.*)/$1/i;
+
+    # First determine which pdf conversion tool we're using among pdftohtml/pdfbox/xpdftools
+    # and then decide which conversion command to run based on the output type 
+    # (pdfbox does not currently go through gsConvert.pl
+    # as PDFBoxConverter inherits from AutoLoadConverters)
+    
+  if ($pdf_tool eq "pdftohtml" ) { # old pdftohtml tool
     # Attempt coversion to Image
     if ($output_type =~ m/jp?g|gif|png/i) {
@@ -333,28 +343,46 @@
     }
 
-    # Attempt conversion to (paged) HTML using the newer pdftohtml of Xpdftools. This
-    # will be the new default for PDFs when output_type for PDF docs is not specified
-    # (once our use of xpdftools' pdftohtml has been implemented on win and mac).
-    #if ($output_type =~ m/paged_html/i) {
-    if (!$output_type || ($output_type =~ m/paged_html/i)) {
-	$success = &xpdf_to_html($dirname, $input_filename, $output_filestem);
-	if ($success) {
-	    return "paged_html";
-	}
-    }
-
-    # Attempt conversion to TEXT
+    # Attempt conversion to TEXT (not for Windows, but PDFPlugin/PDFv1Plugin takes care of that
     if (!$output_type || ($output_type =~ m/text/i)) {
-		$success = &xpdf_to_text($dirname, $input_filename, $output_filestem);
-		#if ($ENV{'GSDLOS'} =~ m/^windows$/i) { # we now have pdf to text support for windows by using xpdf tools
-		#	$success = &xpdf_to_text($dirname, $input_filename, $output_filestem);
-		#} else {
-		#	$success = &pdf_to_text($dirname, $input_filename, $output_filestem);
-		#}
+	$success = &pdf_to_text($dirname, $input_filename, $output_filestem);
+
 	if ($success) {
 	    return "text";
 	}
     }
-
+  }
+    
+  elsif ($pdf_tool eq "xpdftools" ) {
+	# default to html output
+	if (!$output_type) {
+	    $output_type = "html";
+	}
+	
+	# Attempt coversion to Image
+	#if ($output_type =~ m/jp?g|gif|png/i) {
+	#    $success = &pdfps_to_img($dirname, $input_filename, $output_filestem, $output_type);
+	#    if ($success){
+	#	return "item";
+	#    }
+	#}
+	
+	# Attempt conversion to (paged) HTML using the newer pdftohtml of Xpdftools.
+	if ($output_type =~ m/^(paged_html|html)$/i) {
+	    $success = &xpdf_to_html($dirname, $input_filename, $output_filestem);
+	    if ($success) {
+		return $output_type;
+	    }
+	}
+	
+	# Attempt conversion to TEXT
+	if (!$output_type || ($output_type =~ m/text/i)) {	    
+	    $success = &xpdf_to_text($dirname, $input_filename, $output_filestem);
+	    
+	    if ($success) {
+		return "text";
+	    }
+	}
+  }
+	
     return "fail";
 
