remove islenientparsing from contentstreamprocessor

This commit is contained in:
Eliot Jones
2020-02-28 11:44:13 +00:00
parent 6fdaf054cb
commit 48d166276d
2 changed files with 10 additions and 22 deletions

View File

@@ -43,7 +43,6 @@
private readonly IResourceStore resourceStore;
private readonly UserSpaceUnit userSpaceUnit;
private readonly PageRotationDegrees rotation;
private readonly bool isLenientParsing;
private readonly IPdfTokenScanner pdfScanner;
private readonly IPageContentParser pageContentParser;
private readonly IFilterProvider filterProvider;
@@ -82,7 +81,6 @@
};
public ContentStreamProcessor(PdfRectangle cropBox, IResourceStore resourceStore, UserSpaceUnit userSpaceUnit, PageRotationDegrees rotation,
bool isLenientParsing,
IPdfTokenScanner pdfScanner,
IPageContentParser pageContentParser,
IFilterProvider filterProvider,
@@ -91,7 +89,6 @@
this.resourceStore = resourceStore;
this.userSpaceUnit = userSpaceUnit;
this.rotation = rotation;
this.isLenientParsing = isLenientParsing;
this.pdfScanner = pdfScanner ?? throw new ArgumentNullException(nameof(pdfScanner));
this.pageContentParser = pageContentParser ?? throw new ArgumentNullException(nameof(pageContentParser));
this.filterProvider = filterProvider ?? throw new ArgumentNullException(nameof(filterProvider));
@@ -490,9 +487,9 @@
public void BeginInlineImage()
{
if (inlineImageBuilder != null && !isLenientParsing)
if (inlineImageBuilder != null)
{
throw new PdfDocumentFormatException("Begin inline image (BI) command encountered while another inline image was active.");
log?.Error("Begin inline image (BI) command encountered while another inline image was active.");
}
inlineImageBuilder = new InlineImageBuilder();
@@ -502,14 +499,10 @@
{
if (inlineImageBuilder == null)
{
if (isLenientParsing)
{
log?.Error("Begin inline image data (ID) command encountered without a corresponding begin inline image (BI) command.");
return;
}
throw new PdfDocumentFormatException("Begin inline image data (ID) command encountered without a corresponding begin inline image (BI) command.");
}
inlineImageBuilder.Properties = properties;
}
@@ -517,14 +510,10 @@
{
if (inlineImageBuilder == null)
{
if (isLenientParsing)
{
log?.Error("End inline image (EI) command encountered without a corresponding begin inline image (BI) command.");
return;
}
throw new PdfDocumentFormatException("End inline image (EI) command encountered without a corresponding begin inline image (BI) command.");
}
inlineImageBuilder.Bytes = bytes;
var image = inlineImageBuilder.CreateInlineImage(CurrentTransformationMatrix, filterProvider, pdfScanner, GetCurrentState().RenderingIntent, resourceStore);

View File

@@ -109,7 +109,7 @@
}
}
content = GetContent(number, bytes, cropBox, userSpaceUnit, rotation, isLenientParsing);
content = GetContent(number, bytes, cropBox, userSpaceUnit, rotation);
}
else
{
@@ -122,7 +122,7 @@
var bytes = contentStream.Decode(filterProvider);
content = GetContent(number, bytes, cropBox, userSpaceUnit, rotation, isLenientParsing);
content = GetContent(number, bytes, cropBox, userSpaceUnit, rotation);
}
var page = new Page(number, dictionary, mediaBox, cropBox, rotation, content,
@@ -138,13 +138,12 @@
}
private PageContent GetContent(int pageNumber, IReadOnlyList<byte> contentBytes, CropBox cropBox, UserSpaceUnit userSpaceUnit,
PageRotationDegrees rotation,
bool isLenientParsing)
PageRotationDegrees rotation)
{
var operations = pageContentParser.Parse(pageNumber, new ByteArrayInputBytes(contentBytes),
log);
var context = new ContentStreamProcessor(cropBox.Bounds, resourceStore, userSpaceUnit, rotation, isLenientParsing, pdfScanner,
var context = new ContentStreamProcessor(cropBox.Bounds, resourceStore, userSpaceUnit, rotation, pdfScanner,
pageContentParser,
filterProvider,
log);