PdfPig icon indicating copy to clipboard operation
PdfPig copied to clipboard

ArgumentOutOfRangeException in CharacterCodeToGlyphIndex on Format4CMapTable

Open dyster opened this issue 3 years ago • 3 comments

The parameter "characterCode" passed to the function has a value of 1 There are two segments, 0 to 65535m delta 0, offset 4 and 65535 to 65535, delta 1, offset 0 On the first segment it iterates through it passes the if checks and arrives at an offset of 3. so adding together the offset of 3, the segment.count of 2 and the iterator of 0 the return line is looking inside the GlyphIds at position 1, but this array is empty thus getting the argument out of range.

In the constructor for Format4CMapTable the glyphids are checked for null, but not checked for being empty. I don't know if it should be checked for emptiness or if it is not meant to be empty.

The pdf that triggered this problem is proprietary so I cannot share it on github or somewhere public, but I could potentially share it with a developer privately.

dyster avatar Jan 06 '22 11:01 dyster

Hi @dyster can you try the following package locally and see if it works or is just broken in a different way please? PdfPig.0.1.6-alpha001.zip

https://stackoverflow.com/questions/10240029/how-do-i-install-a-nuget-package-nupkg-file-locally

EliotJones avatar Jan 10 '22 12:01 EliotJones

Sorry @EliotJones I should have mentioned that I've tried this with the currently available nuget, as well as the current master branch on github and they both break in the same way. Is this alpha001 nuget the same as the current source?

dyster avatar Jan 10 '22 13:01 dyster

@dyster this NuGet is a custom build with the CMap construction skipped if the array is empty, just want to see if that's a viable strategy or the real problem is calculation of the available glyph ids array length.

EliotJones avatar Jan 10 '22 13:01 EliotJones