Changeset 24476

Show
Ignore:
Timestamp:
25.08.2011 19:33:02 (8 years ago)
Author:
ak19
Message:

Number of pages calculated for PDFs when using PDFBox is now no longer twice the number it's supposed to be.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/PDFPlugin.pm

    r24431 r24476  
    285285    # embeds each page in an extra div. The div opener is:  
    286286    # <div style=\"page-break-before:always; page-break-after:always\"> 
    287     # The PDFPlugin now looks for this and prefix <a name=0></a> to each such div. (The  
     287    # The PDFPlugin now looks for this and prefixes <a name=0></a> to each such div. (The  
    288288    # pagenumber is fixed at 0 since I'm unable to work out how to increment the pagenum during  
    289289    # a regex substitution even with regex extensions on.) Later, when we process each section  
     
    299299    # for each page).  Metadata based on this calculation not set until process() 
    300300    #  
    301     # Note: this is done even if we are not breaking to document into pages as it might 
     301    # Note: this is done even if we are not breaking the document into pages as it might 
    302302    # be useful to give an indication of document length in browser through setting 
    303303    # num_pages as metadata. 
    304     my @pages = ($text =~ m/(\<[Aa] name=\"?\w+\"?>|\<div style=\"page-break-before:always; page-break-after:always\">)/ig); #<div style=\"?page-break-before:always; page-break-after:always\"?> 
     304    my @pages = ($text =~ m/\<[Aa] name=\"?\w+\"?>/ig); #<div style=\"?page-break-before:always; page-break-after:always\"?> 
    305305    my $num_pages = scalar(@pages); 
    306306    $self->{'num_pages'} = $num_pages; 
     
    422422    } 
    423423 
    424     $doc_obj->add_utf8_metadata($cursection, "NumPages", $self->{'num_pages'}); 
     424    $doc_obj->add_utf8_metadata($cursection, "NumPages", $self->{'num_pages'}) if defined $self->{'num_pages'}; 
    425425     
    426426    if ($self->{'use_sections'} && $self->{'converted_to'} eq "HTML") {