private PageContent GetContent(IReadOnlyList <byte> contentBytes, CropBox cropBox, UserSpaceUnit userSpaceUnit, bool isLenientParsing) { var operations = pageContentParser.Parse(new ByteArrayInputBytes(contentBytes)); var context = new ContentStreamProcessor(cropBox.Bounds, resourceStore, userSpaceUnit, isLenientParsing, pdfScanner, xObjectFactory); return(context.Process(operations)); }
private PageContent GetContent(IReadOnlyList <byte> contentBytes, CropBox cropBox, UserSpaceUnit userSpaceUnit, PageRotationDegrees rotation, bool isLenientParsing) { var operations = pageContentParser.Parse(new ByteArrayInputBytes(contentBytes)); var context = new ContentStreamProcessor(cropBox.Bounds, resourceStore, userSpaceUnit, rotation, isLenientParsing, pdfScanner, pageContentParser, filterProvider, log); return(context.Process(operations)); }
private PageContent GetContent(IReadOnlyList <byte> contentBytes, CropBox cropBox, UserSpaceUnit userSpaceUnit, bool isLenientParsing) { if (Debugger.IsAttached) { var txt = OtherEncodings.BytesAsLatin1String(contentBytes.ToArray()); } var operations = pageContentParser.Parse(new ByteArrayInputBytes(contentBytes)); var context = new ContentStreamProcessor(cropBox.Bounds, resourceStore, userSpaceUnit, isLenientParsing); return(context.Process(operations)); }
private PageContent GetContent(int pageNumber, IReadOnlyList <byte> contentBytes, CropBox cropBox, UserSpaceUnit userSpaceUnit, PageRotationDegrees rotation, bool clipPaths) { var operations = pageContentParser.Parse(pageNumber, new ByteArrayInputBytes(contentBytes), log); var context = new ContentStreamProcessor(cropBox.Bounds, resourceStore, userSpaceUnit, rotation, pdfScanner, pageContentParser, filterProvider, log, clipPaths); return(context.Process(pageNumber, operations)); }
public Page Create(int number, PdfDictionary dictionary, PageTreeMembers pageTreeMembers, IRandomAccessRead reader, bool isLenientParsing) { if (dictionary == null) { throw new ArgumentNullException(nameof(dictionary)); } var type = dictionary.GetName(CosName.TYPE); if (type != null && !type.Equals(CosName.PAGE) && !isLenientParsing) { throw new InvalidOperationException($"Page {number} had its type was specified as {type} rather than 'Page'."); } MediaBox mediaBox = GetMediaBox(number, dictionary, pageTreeMembers, isLenientParsing); CropBox cropBox = GetCropBox(dictionary, pageTreeMembers, mediaBox); UserSpaceUnit userSpaceUnit = GetUserSpaceUnits(dictionary); LoadResources(dictionary, reader, isLenientParsing); PageContent content = default(PageContent); var contentObject = dictionary.GetItemOrDefault(CosName.CONTENTS) as CosObject; if (contentObject != null) { var contentStream = pdfObjectParser.Parse(contentObject.ToIndirectReference(), reader, false) as PdfRawStream; if (contentStream == null) { throw new InvalidOperationException("Failed to parse the content for the page: " + number); } var contents = contentStream.Decode(filterProvider); var txt = OtherEncodings.BytesAsLatin1String(contents); var operations = pageContentParser.Parse(new ByteArrayInputBytes(contents)); var context = new ContentStreamProcessor(cropBox.Bounds, resourceStore, userSpaceUnit); content = context.Process(operations); } var page = new Page(number, mediaBox, cropBox, content); return(page); }