Skip to content

System.IndexOutOfRangeException : Index was outside the bounds of the array in Glyph.MergeContourEndPoints #954

@GrabzIt

Description

@GrabzIt

This error is happening quite often happening for various PDF documents. Here is an example:
broken_colour.pdf

Glyph.MergeContourEndPoints(IGlyphDescription glyph)
Glyph.Merge(IGlyphDescription glyph)
GlyphDataTable.ReadCompositeGlyph(TrueTypeDataBytes data, TemporaryCompositeLocation compositeLocation, Dictionary`2 compositeLocations, IGlyphDescription[] glyphs, IGlyphDescription emptyGlyph)
GlyphDataTable.ReadGlyphs()
Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
Lazy`1.CreateValue()
GlyphDataTable.get_Glyphs()
GlyphDataTable.TryGetGlyphBounds(Int32 glyphIndex, PdfRectangle& bounds)
TrueTypeFont.TryGetBoundingBox(Int32 characterCode, Func`2 characterCodeToGlyphId, PdfRectangle& boundingBox)
<4 more frames...>
ShowText.Run(IOperationContext operationContext)
BaseStreamProcessor`1.ProcessOperations(IReadOnlyList`1 operations)
ContentStreamProcessor.Process(Int32 pageNumberCurrent, IReadOnlyList`1 operations)
PageFactory.ProcessPage(Int32 pageNumber, DictionaryToken dictionary, NamedDestinations namedDestinations, MediaBox mediaBox, CropBox cropBox, UserSpaceUnit userSpaceUnit, PageRotationDegrees rotation, TransformationMatrix initialMatrix, IReadOnlyList`1 operations)
BasePageFactory`1.Create(Int32 number, DictionaryToken dictionary, PageTreeMembers pageTreeMembers, NamedDestinations namedDestinations)
Pages.GetPage[TPage](IPageFactory`1 pageFactory, Int32 pageNumber, NamedDestinations namedDestinations, ParsingOptions parsingOptions)
Pages.GetPage(Int32 pageNumber, NamedDestinations namedDestinations, ParsingOptions parsingOptions)
PdfDocument.GetPage(Int32 pageNumber)

To recreate it run the following code:

UglyToad.PdfPig.PdfDocument document = UglyToad.PdfPig.PdfDocument.Open("broken_colour.pdf");
Page page = document.GetPage(0);       

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions