mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-19 02:37:56 +08:00
remove islenientparsing from annotation provider
This commit is contained in:
@@ -13,19 +13,16 @@
|
|||||||
{
|
{
|
||||||
private readonly IPdfTokenScanner tokenScanner;
|
private readonly IPdfTokenScanner tokenScanner;
|
||||||
private readonly DictionaryToken pageDictionary;
|
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.tokenScanner = tokenScanner ?? throw new ArgumentNullException(nameof(tokenScanner));
|
||||||
this.pageDictionary = pageDictionary ?? throw new ArgumentNullException(nameof(pageDictionary));
|
this.pageDictionary = pageDictionary ?? throw new ArgumentNullException(nameof(pageDictionary));
|
||||||
this.isLenientParsing = isLenientParsing;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Annotation> GetAnnotations()
|
public IEnumerable<Annotation> GetAnnotations()
|
||||||
{
|
{
|
||||||
if (!pageDictionary.TryGet(NameToken.Annots, out IToken annotationsToken)
|
if (!pageDictionary.TryGet(NameToken.Annots, tokenScanner, out ArrayToken annotationsArray))
|
||||||
|| !DirectObjectFinder.TryGet(annotationsToken, tokenScanner, out ArrayToken annotationsArray))
|
|
||||||
{
|
{
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
@@ -34,20 +31,7 @@
|
|||||||
{
|
{
|
||||||
if (!DirectObjectFinder.TryGet(token, tokenScanner, out DictionaryToken annotationDictionary))
|
if (!DirectObjectFinder.TryGet(token, tokenScanner, out DictionaryToken annotationDictionary))
|
||||||
{
|
{
|
||||||
if (isLenientParsing)
|
|
||||||
{
|
|
||||||
continue;
|
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);
|
var type = annotationDictionary.Get<NameToken>(NameToken.Subtype, tokenScanner);
|
||||||
|
@@ -126,7 +126,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var page = new Page(number, dictionary, mediaBox, cropBox, rotation, content,
|
var page = new Page(number, dictionary, mediaBox, cropBox, rotation, content,
|
||||||
new AnnotationProvider(pdfScanner, dictionary, isLenientParsing),
|
new AnnotationProvider(pdfScanner, dictionary),
|
||||||
pdfScanner);
|
pdfScanner);
|
||||||
|
|
||||||
for (var i = 0; i < stackDepth; i++)
|
for (var i = 0; i < stackDepth; i++)
|
||||||
|
Reference in New Issue
Block a user