Fix Issue 516. Page Dictionary Count field has incorrect page count. Compare with PageTree children count.

This commit is contained in:
Fred Natzke 2022-11-30 09:25:23 +10:00
parent afe473e10e
commit a7f64ec64b
2 changed files with 7 additions and 1 deletions

View File

@ -51,7 +51,7 @@
8,
("Extract Words with newline detection (example with algorithm). Issue 512",
() => OpenDocumentAndExtractWords.Run(Path.Combine(filesDirectory, "OPEN.RABBIT.ENGLISH.LOP.pdf")))
}
}
};
var choices = string.Join(Environment.NewLine, examples.Select(x => $"{x.Key}: {x.Value.name}"));

View File

@ -21,6 +21,12 @@
this.pdfScanner = pdfScanner ?? throw new ArgumentNullException(nameof(pdfScanner));
Count = catalog.PagesDictionary.GetIntOrDefault(NameToken.Count);
var CountOfPagesByPagesTree = catalog.PageTree.Children.Count;
if (Count != CountOfPagesByPagesTree)
{
//log.Warning($"Dicrionary Page Count {Count} different to discovered pages {CountOfPagesByPagesTree}. Using {CountOfPagesByPagesTree}.");
Count = CountOfPagesByPagesTree;
}
}
public Page GetPage(int pageNumber, InternalParsingOptions parsingOptions)