remove islenientparsing from annotation provider

This commit is contained in:
Eliot Jones
2020-02-28 11:39:56 +00:00
parent 7b09999a3f
commit 6fdaf054cb
2 changed files with 3 additions and 19 deletions

View File

@@ -13,19 +13,16 @@
{
private readonly IPdfTokenScanner tokenScanner;
private readonly DictionaryToken pageDictionary;
private readonly bool isLenientParsing;
public AnnotationProvider(IPdfTokenScanner tokenScanner, DictionaryToken pageDictionary, bool isLenientParsing)
public AnnotationProvider(IPdfTokenScanner tokenScanner, DictionaryToken pageDictionary)
{
this.tokenScanner = tokenScanner ?? throw new ArgumentNullException(nameof(tokenScanner));
this.pageDictionary = pageDictionary ?? throw new ArgumentNullException(nameof(pageDictionary));
this.isLenientParsing = isLenientParsing;
}
public IEnumerable<Annotation> GetAnnotations()
{
if (!pageDictionary.TryGet(NameToken.Annots, out IToken annotationsToken)
|| !DirectObjectFinder.TryGet(annotationsToken, tokenScanner, out ArrayToken annotationsArray))
if (!pageDictionary.TryGet(NameToken.Annots, tokenScanner, out ArrayToken annotationsArray))
{
yield break;
}
@@ -34,20 +31,7 @@
{
if (!DirectObjectFinder.TryGet(token, tokenScanner, out DictionaryToken annotationDictionary))
{
if (isLenientParsing)
{
continue;
}
throw new PdfDocumentFormatException($"The annotations dictionary contained an annotation which wasn't a dictionary: {token}.");
}
if (!isLenientParsing && annotationDictionary.TryGet(NameToken.Type, out NameToken dictionaryType))
{
if (dictionaryType != NameToken.Annot)
{
throw new PdfDocumentFormatException($"The annotations dictionary contained a non-annotation type dictionary: {annotationDictionary}.");
}
}
var type = annotationDictionary.Get<NameToken>(NameToken.Subtype, tokenScanner);

View File

@@ -126,7 +126,7 @@
}
var page = new Page(number, dictionary, mediaBox, cropBox, rotation, content,
new AnnotationProvider(pdfScanner, dictionary, isLenientParsing),
new AnnotationProvider(pdfScanner, dictionary),
pdfScanner);
for (var i = 0; i < stackDepth; i++)