Index: main/trunk/greenstone2/bin/script/gsConvert.pl
===================================================================
--- main/trunk/greenstone2/bin/script/gsConvert.pl	(revision 32268)
+++ 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";
 
Index: main/trunk/greenstone2/perllib/plugins/PDFPlugin.pm
===================================================================
--- main/trunk/greenstone2/perllib/plugins/PDFPlugin.pm	(revision 32268)
+++ main/trunk/greenstone2/perllib/plugins/PDFPlugin.pm	(revision 32273)
@@ -140,7 +140,16 @@
     $self->{'file_type'} = "PDF";
 
+    # PDFPlugin is deprecated and migrating users should hereafter choose between
+    # PDFv1Plugin, if they want to use the old pdftohtml tool's capabilities,
+    # and PDFv2Plugin, if they want to use pdfbox or the new xpdftools capabilities.
+    &gsprintf::gsprintf(STDERR, "{PDFPlugin.deprecated_plugin}");
+    
     # these are passed through to gsConvert.pl by ConvertBinaryFile.pm
     my $zoom = $self->{"zoom"};
-    $self->{'convert_options'} = "-pdf_zoom $zoom";
+    # By default, PDFPlugin assumes gsConvert.pl will run the old pdftohtml conversion tool,
+    # But if pdfbox conversion is turned on, the tool used is pdfbox (which is presently an
+    # AutoLoadConverter and therefore bypasses gsConvert.pl)
+    $self->{'convert_options'} = "-pdf_tool pdftohtml"; 
+    $self->{'convert_options'} .= " -pdf_zoom $zoom";
     $self->{'convert_options'} .= " -pdf_complex" if $self->{"complex"};
     $self->{'convert_options'} .= " -pdf_nohidden" if $self->{"nohidden"};
@@ -151,7 +160,7 @@
     # TODO: Start supporting PDF to txt on Windows if we're going to be using XPDF Tools (incl pdftotext) on Windows/Linux/Mac
     if ($self->{'convert_to'} eq "text" && $ENV{'GSDLOS'} =~ /^windows$/i) {
-		print STDERR "On Windows, Greenstone now uses Xpdf tools to support pdf to text conversion.\n";
-	#print STDERR "Windows does not support pdf to text. PDFs will be converted to HTML instead\n";
-	#$self->{'convert_to'} = "html";
+	#print STDERR "On Windows, Greenstone now uses Xpdf tools to support pdf to text conversion.\n";
+	print STDERR "Windows does not support pdf to text. PDFs will be converted to HTML instead\n";
+	$self->{'convert_to'} = "html";
     }
     elsif ($self->{'convert_to'} eq "auto") {
@@ -407,5 +416,5 @@
     # Copying file open/close code from CommonUtil::utf8_write_file()
     if (!open (OUTFILE, ">:utf8", $output_filename)) {
-	gsprintf(STDERR, "PDFPlugin::xpdftohtml_convert_post_process {ConvertToPlug.could_not_open_for_writing} ($!)\n", $output_filename);
+	gsprintf(STDERR, "PDFPlugin::xpdftohtml_convert_post_process {CommonUtil.could_not_open_for_writing} ($!)\n", $output_filename);
 	die "\n";
     }
Index: main/trunk/greenstone2/perllib/plugins/PDFv1Plugin.pm
===================================================================
--- main/trunk/greenstone2/perllib/plugins/PDFv1Plugin.pm	(revision 32273)
+++ main/trunk/greenstone2/perllib/plugins/PDFv1Plugin.pm	(revision 32273)
@@ -0,0 +1,409 @@
+###########################################################################
+#
+# PDFv1Plugin.pm -- The older pdf plugin, which uses the older pdftohtml
+# tool that can't handle newer versions of PDFs.
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 1999-2018 New Zealand Digital Library Project
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###########################################################################
+package PDFv1Plugin;
+
+use strict;
+no strict 'refs'; # so we can use a var for filehandles (e.g. STDERR)
+no strict 'subs'; # allow filehandles to be variables and viceversa
+
+use ConvertBinaryFile;
+use ReadTextFile;
+use unicode;
+
+
+@PDFv1Plugin::ISA = ('ConvertBinaryFile', 'ReadTextFile');
+
+# PDFv1 plugin should be returned to being more like it was before AutoLoadConverters/PDFBox extension's inclusion
+# like the PDFPlugin was at http://trac.greenstone.org/browser/main/trunk/greenstone2/perllib/plugins/PDFPlugin.pm?rev=22597
+my $convert_to_list =
+    [ {	'name' => "auto",
+	'desc' => "{ConvertBinaryFile.convert_to.auto}" },
+      {	'name' => "html",
+	'desc' => "{ConvertBinaryFile.convert_to.html}" },
+      {	'name' => "text",
+	'desc' => "{ConvertBinaryFile.convert_to.text}" },      
+      { 'name' => "pagedimg_jpg",
+	'desc' => "{ConvertBinaryFile.convert_to.pagedimg_jpg}"},
+      { 'name' => "pagedimg_gif",
+	'desc' => "{ConvertBinaryFile.convert_to.pagedimg_gif}"},
+      { 'name' => "pagedimg_png",
+	'desc' => "{ConvertBinaryFile.convert_to.pagedimg_png}"}, 
+      ];
+
+
+my $arguments = 
+    [
+     { 'name' => "convert_to",
+       'desc' => "{ConvertBinaryFile.convert_to}",
+       'type' => "enum",
+       'reqd' => "yes",
+       'list' => $convert_to_list, 
+       'deft' => "html" },	 
+     { 'name' => "process_exp",
+       'desc' => "{BaseImporter.process_exp}",
+       'type' => "regexp",
+       'deft' => &get_default_process_exp(),
+       'reqd' => "no" },
+     { 'name' => "block_exp",
+       'desc' => "{CommonUtil.block_exp}",
+       'type' => "regexp",
+       'deft' => &get_default_block_exp() },
+     { 'name' => "metadata_fields",
+       'desc' => "{HTMLPlugin.metadata_fields}",
+       'type' => "string",
+       'deft' => "Title,Author,Subject,Keywords" },
+      { 'name' => "metadata_field_separator",
+	'desc' => "{HTMLPlugin.metadata_field_separator}",
+	'type' => "string",
+	'deft' => "" },
+     { 'name' => "noimages",
+       'desc' => "{PDFPlugin.noimages}",
+       'type' => "flag" },
+     { 'name' => "allowimagesonly",
+       'desc' => "{PDFPlugin.allowimagesonly}",
+       'type' => "flag" },
+     { 'name' => "complex",
+       'desc' => "{PDFPlugin.complex}",
+       'type' => "flag" },
+     { 'name' => "nohidden",
+       'desc' => "{PDFPlugin.nohidden}",
+       'type' => "flag" },
+     { 'name' => "zoom",
+       'desc' => "{PDFPlugin.zoom}",
+       'deft' => "2",
+       'range' => "1,3", # actually the range is 0.5-3 
+       'type' => "int" },
+     { 'name' => "use_sections",
+       'desc' => "{PDFPlugin.use_sections}",
+       'type' => "flag" },
+     { 'name' => "description_tags",
+       'desc' => "{HTMLPlugin.description_tags}",
+       'type' => "flag" },
+      { 'name' => "use_realistic_book",
+        'desc' => "{PDFPlugin.use_realistic_book}",
+	'type' => "flag"}
+     ];
+
+my $options = { 'name'     => "PDFv1Plugin",
+		'desc'     => "{PDFPlugin.desc}",
+		'abstract' => "no",
+		'inherits' => "yes",
+		'srcreplaceable' => "yes", # Source docs in PDF can be replaced with GS-generated html		
+		'args'     => $arguments };
+
+sub new {
+    my ($class) = shift (@_);
+    my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
+    push(@$pluginlist, $class);
+
+    push(@$inputargs,"-title_sub");
+    push(@$inputargs,'^(Page\s+\d+)?(\s*1\s+)?');
+
+    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
+    push(@{$hashArgOptLists->{"OptList"}},$options);
+
+    my $self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists);
+    
+    if ($self->{'info_only'}) {
+	# don't worry about any options etc
+	return bless $self, $class;
+    }
+    
+    $self = bless $self, $class;
+    $self->{'file_type'} = "PDF";
+
+    # these are passed through to gsConvert.pl by ConvertBinaryFile.pm
+    my $zoom = $self->{"zoom"};
+    $self->{'convert_options'} = "-pdf_tool pdftohtml"; # PDFPluginv1 only ever uses the old pdftohtml conversion tool
+    $self->{'convert_options'} .= " -pdf_zoom $zoom";
+    $self->{'convert_options'} .= " -pdf_complex" if $self->{"complex"};
+    $self->{'convert_options'} .= " -pdf_nohidden" if $self->{"nohidden"};
+    $self->{'convert_options'} .= " -pdf_ignore_images" if $self->{"noimages"};
+    $self->{'convert_options'} .= " -pdf_allow_images_only" if $self->{"allowimagesonly"};
+
+    # check convert_to
+    # TODO: Start supporting PDF to txt on Windows if we're going to be using XPDF Tools (incl pdftotext) on Windows/Linux/Mac
+    if ($self->{'convert_to'} eq "text" && $ENV{'GSDLOS'} =~ /^windows$/i) {
+	print STDERR "*** On Windows, PDFv1Plugin does not support pdf to text. PDFs will be converted to HTML instead.\n";
+	print STDERR "*** Use PDFv2Plugin if you really want pdf to text conversion.\n";
+	$self->{'convert_to'} = "html";
+    }
+    elsif ($self->{'convert_to'} eq "auto") {
+	# choose html ?? is this the best option
+	$self->{'convert_to'} = "html";
+    }
+    if ($self->{'use_realistic_book'}) {
+	if ($self->{'convert_to'} ne "html") {
+	    print STDERR "PDFs will be converted to HTML for realistic book functionality\n";
+	    $self->{'convert_to'} = "html";
+	}
+    }
+    # set convert_to_plugin and convert_to_ext
+    $self->set_standard_convert_settings();
+
+    my $secondary_plugin_name = $self->{'convert_to_plugin'};
+    my $secondary_plugin_options = $self->{'secondary_plugin_options'};
+
+    if (!defined $secondary_plugin_options->{$secondary_plugin_name}) {
+	$secondary_plugin_options->{$secondary_plugin_name} = [];
+    }
+    my $specific_options = $secondary_plugin_options->{$secondary_plugin_name};
+
+    # following title_sub removes "Page 1" added by pdftohtml, and a leading
+    # "1", which is often the page number at the top of the page. Bad Luck
+    # if your document title actually starts with "1 " - is there a better way?
+    push(@$specific_options , "-title_sub", '^(Page\s+\d+)?(\s*1\s+)?');
+    my $associate_tail_re = $self->{'associate_tail_re'};
+    if ((defined $associate_tail_re) && ($associate_tail_re ne "")) {
+	push(@$specific_options, "-associate_tail_re", $associate_tail_re);
+    }
+    push(@$specific_options, "-file_rename_method", "none");
+    
+    if ($secondary_plugin_name eq "HTMLPlugin") {
+	# pdftohtml always produces utf8
+	push(@$specific_options, "-input_encoding", "utf8");
+	push(@$specific_options, "-extract_language") if $self->{'extract_language'};
+	push(@$specific_options, "-processing_tmp_files");
+	# Instruct HTMLPlug (when eventually accessed through read_into_doc_obj) 
+	# to extract these metadata fields from the HEAD META fields
+	if (defined $self->{'metadata_fields'} && $self->{'metadata_fields'} =~ /\S/) {
+	    push(@$specific_options,"-metadata_fields",$self->{'metadata_fields'});
+	} else {
+	    push(@$specific_options,"-metadata_fields","Title,GENERATOR,date,author<Creator>");
+	}
+	if (defined $self->{'metadata_field_separator'} && $self->{'metadata_field_separator'} =~ /\S/) {
+	    push(@$specific_options,"-metadata_field_separator",$self->{'metadata_field_separator'});
+	}
+	if ($self->{'use_sections'} || $self->{'description_tags'}) {
+	    $self->{'description_tags'} = 1;
+	    push(@$specific_options, "-description_tags");
+	}
+	if ($self->{'use_realistic_book'}) {
+	    push(@$specific_options, "-use_realistic_book");
+	}
+    }
+    elsif ($secondary_plugin_name eq "PagedImagePlugin") {
+	push(@$specific_options, "-screenviewsize", "1000");
+	push(@$specific_options, "-enable_cache");
+	push(@$specific_options, "-processing_tmp_files");
+    }
+
+    $self = bless $self, $class; # Q TODO: why does it do this a 2nd time in this function?
+    $self->load_secondary_plugins($class,$secondary_plugin_options,$hashArgOptLists);
+    return $self;
+}
+
+sub get_default_process_exp {
+    my $self = shift (@_);
+
+    return q^(?i)\.pdf$^;
+}
+
+# so we don't inherit HTMLPlug's block exp...
+sub get_default_block_exp {
+    return "";
+}
+
+  
+# By setting hashing to be on ga xml this ensures that two 
+# PDF files that are identical except for the metadata
+# to hash to different values. Without this, when each PDF
+# file is converted to HTML there is a chance that they 
+# will both be *identical* if the conversion utility does
+# not embed the metadata in the generated HTML. This is
+# certainly the case when PDFBOX is being used. 
+
+# This change makes this convert to based plugin more 
+# consistent with the original vision that the same document 
+# with different metadata should
+# be seen as different.
+
+sub get_oid_hash_type {
+    my $self = shift (@_);
+    return "hash_on_ga_xml";
+}
+  
+  
+#sub tmp_area_convert_file {
+#
+#    my $self = shift (@_);
+#    return $self->AutoLoadConverters::tmp_area_convert_file(@_);
+#
+#}
+
+sub convert_post_process
+{
+    my $self = shift (@_);
+    my ($conv_filename) = @_;
+
+    my $outhandle=$self->{'outhandle'};
+
+    #$self->{'input_encoding'} = "utf8"; # The output is always in utf8 (is it?? it is for html, but what about other types?)
+    #my ($language, $encoding) = $self->textcat_get_language_encoding ($conv_filename);
+
+    # read in file ($text will be in utf8)
+    my $text = "";
+    # encoding will be utf8 for html files - what about other types? will we do this step for them anyway?
+    $self->read_file ($conv_filename, "utf8", "", \$text);
+
+    # Clean html from low and high surrogates D800âDFFF
+    $text =~ s@[\N{U+D800}-\N{U+DFFF}]@\ @g;
+    
+    # Calculate number of pages based on <a ...> tags (we have a <a name=1> etc
+    # for each page).  Metadata based on this calculation not set until process()
+    # 
+    # Note: this is done even if we are not breaking the document into pages as it might
+    # be useful to give an indication of document length in browser through setting
+    # num_pages as metadata.
+    my @pages = ($text =~ m/\<[Aa] name=\"?\w+\"?>/ig); #<div style=\"?page-break-before:always; page-break-after:always\"?>
+    my $num_pages = scalar(@pages);
+    $self->{'num_pages'} = $num_pages;
+
+    if ($self->{'use_sections'}
+	&& $self->{'converted_to'} eq "HTML") {
+
+	print $outhandle "PDFPlugin: Calculating sections...\n";
+
+	# we have "<a name=1></a>" etc for each page
+	# it may be <A name=
+	my @sections = split('<[Aa] name=', $text);
+
+	my $top_section = "";
+
+	if (scalar (@sections) == 1) { #only one section - no split!
+	    print $outhandle "PDFPlugin: warning - no sections found\n";
+	} else {
+	    $top_section .= shift @sections; # keep HTML header etc as top_section
+	}
+
+	# handle first section specially for title? Or all use first 100...
+	
+	my $title = $sections[0];
+	$title =~ s/^\"?\w+\"?>//; # specific for pdftohtml...
+	$title =~ s/<\/([^>]+)><\1>//g; # (eg) </b><b> - no space
+	$title =~ s/<[^>]*>/ /g;
+	$title =~ s/(?:&nbsp;|\xc2\xa0)/ /g; # utf-8 for nbsp...
+	$title =~ s/^\s+//s;
+	$title =~ s/\s+$//;
+	$title =~ s/\s+/ /gs;
+	$title =~ s/^$self->{'title_sub'}// if ($self->{'title_sub'});
+	$title =~ s/^\s+//s; # in case title_sub introduced any...
+	$title = substr ($title, 0, 100);
+	$title =~ s/\s\S*$/.../;
+
+
+	if (scalar (@sections) == 1) { # no sections found
+	    $top_section .= $sections[0];
+	    @sections=();
+	} else {
+	    $top_section .= "<!--<Section>\n<Metadata name=\"Title\">$title</Metadata>\n-->\n <!--</Section>-->\n";
+	}
+
+	# add metadata per section...
+	foreach my $section (@sections) {
+	    # section names are not always just digits, may be like "outline"
+	    $section =~ s@^\"?(\w+)\"?></a>@@; # leftover from split expression...
+
+	    $title = $1; # Greenstone does magic if sections are titled digits
+	    if (! defined($title) ) {
+		print STDERR "no title: $section\n";
+		$title = " "; # get rid of the undefined warning in next line
+	    }
+	    my $newsection = "<!-- from PDFPlugin -->\n<!-- <Section>\n";
+	    $newsection .= "<Metadata name=\"Title\">" . $title
+		. "</Metadata>\n--><br />\n"; #TODO: . "</Metadata>\n--><p>\n";
+	    $newsection .= $section;
+	    $newsection .= "<!--</Section>-->\n";
+	    $section = $newsection;
+	}
+
+	$text=join('', ($top_section, @sections));
+    }
+
+    if ($self->{'use_sections'}
+	&& $self->{'converted_to'} eq "text") {
+	print STDERR "**** When converting PDF to text, cannot apply use_sections\n";
+    }
+
+
+    # The following should no longer be needed, now that strings
+    # read in are Unicode aware (in the Perl sense) rather than
+    # raw binary strings that just happen to be UTF-8 compliant
+
+    # turn any high bytes that aren't valid utf-8 into utf-8.
+##    unicode::ensure_utf8(\$text);
+
+    # Write it out again!
+    $self->utf8_write_file (\$text, $conv_filename);
+}
+
+
+# do plugin specific processing of doc_obj for HTML type
+sub process {
+    my $self = shift (@_);
+    my ($pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
+
+    my $result = $self->process_type($base_dir,$file,$doc_obj);
+
+    # fix up the extracted date metadata to be in Greenstone date format,
+    # and fix the capitalisation of 'date'
+    my $cursection = $doc_obj->get_top_section();
+    foreach my $datemeta (@{$doc_obj->get_metadata($cursection, "date")}) {
+	$doc_obj->delete_metadata($cursection, "date", $datemeta);
+
+	# We're just interested in the date bit, not the time
+	# some pdf creators (eg "Acrobat 5.0 Scan Plug-in for Windows")
+	# set a /CreationDate, and set /ModDate to 000000000. pdftohtml
+	# extracts the ModDate, so it is 0...
+	$datemeta =~ /(\d+)-(\d+)-(\d+)/;
+	my ($year, $month, $day) = ($1,$2,$3);
+	if (defined($year) && defined($month) && defined($day)) {
+	    if ($year == 0) {next}
+	    if ($year < 100) {$year += 1900} # just to be safe
+	    if ($month =~ /^\d$/) {$month="0$month"} # single digit
+	    if ($day =~ /^\d$/) {$day="0$day"} # single digit
+	    my $date="$year$month$day";
+	    $doc_obj->add_utf8_metadata($cursection, "Date", $date);
+	}
+    }
+
+    $doc_obj->add_utf8_metadata($cursection, "NumPages", $self->{'num_pages'}) if defined $self->{'num_pages'};
+    
+    if ($self->{'use_sections'} && $self->{'converted_to'} eq "HTML") {
+	# For gs2 we explicitly make it a paged document, cos greenstone won't get it
+	# right if any section has an empty title, or one with letters in it
+	if (&util::is_gs3()) {
+	    # but for gs3, paged docs currently use image slider which is ugly if there are no images
+	    $doc_obj->set_utf8_metadata_element ($cursection, "gsdlthistype", "Hierarchy");
+	} else {
+	    $doc_obj->set_utf8_metadata_element ($cursection, "gsdlthistype", "Paged");
+	}
+    }
+
+    return $result;
+}
+
+1;
Index: main/trunk/greenstone2/perllib/strings.properties
===================================================================
--- main/trunk/greenstone2/perllib/strings.properties	(revision 32268)
+++ main/trunk/greenstone2/perllib/strings.properties	(revision 32273)
@@ -809,4 +809,6 @@
 CommonUtil.block_exp:Files matching this regular expression will be blocked from being passed to any later plugins in the list.
 
+CommonUtil.could_not_open_for_writing:could not open %s for writing
+
 CommonUtil.desc:Base Utility plugin class that handles filename encoding and file blocking.
 
@@ -1165,5 +1167,7 @@
 PDFPlugin.convert_to.paged_html:A series of HTML pages, one for each page. Each HTML page contains selectable text positionally overlaid on top of a screenshot of the PDF page background comprising any images, tables and drawings.
 
-PDFPlugin.desc:Plugin that processes PDF documents.
+PDFPlugin.deprecated_plugin:*************IMPORTANT******************\nPDFPlugin is being deprecated.\nConsider upgrading to the recommended PDFv2Plugin, which supports newer versions of PDFs.\nAlternatively, if you wish to retain the old style of conversion and are NOT relying on PDFBox,\nchange to PDFv1Plugin.\nIf you are using PDFBox then upgrade to PDFv2Plugin.\n*****************************************\n
+
+PDFPlugin.desc:Plugin that processes PDF documents using the older pdftohtml tool. Does not support newer PDF versions.
 
 PDFPlugin.nohidden:Prevent pdftohtml from attempting to extract hidden text. This is only useful if the -complex option is also set.
