Skip to content

FormatException thrown when attempting to open a file #216

@franklbt

Description

@franklbt

I have a PDF that cannot be opened via your librairy (attached to this issue).
This PDF throw a FormatException on the following call:

PdfReader.Open(stream, PdfDocumentOpenMode.Import, PdfReadAccuracy.Moderate)

The stacktrace related to this:

FormatException
   at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
   at System.Number.ParseInt32(ReadOnlySpan`1 value, NumberStyles styles, NumberFormatInfo info)
   at System.Int32.Parse(String s, NumberStyles style)
   at PdfSharpCore.Pdf.IO.Lexer.ScanHexadecimalString()
   at PdfSharpCore.Pdf.IO.Lexer.ScanNextToken()
   at PdfSharpCore.Pdf.IO.Parser.ScanNextToken()
   at PdfSharpCore.Pdf.IO.Parser.ParseObject(Symbol stop)
   at PdfSharpCore.Pdf.IO.Parser.ReadDictionary(PdfDictionary dict, Boolean includeReferences)
   at PdfSharpCore.Pdf.IO.Parser.ParseObject(Symbol stop)
   at PdfSharpCore.Pdf.IO.Parser.ReadDictionary(PdfDictionary dict, Boolean includeReferences)
   at PdfSharpCore.Pdf.IO.Parser.ReadObject(PdfObject pdfObject, PdfObjectID objectID, Boolean includeReferences, Boolean fromObjecStream)
   at PdfSharpCore.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider passwordProvider, PdfReadAccuracy accuracy)
   at PdfSharpCore.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openmode, PdfReadAccuracy accuracy)
   at PdfSharpCore.Pdf.IO.PdfReader.Open(Stream stream, PdfDocumentOpenMode openmode, PdfReadAccuracy accuracy)

I think this issue is related to the encoding of the file.
FYI the file can be opened on Chrome and the PDF.JS lib, but not on slack for example, where it was detected as a binary file.

23e9c85a-71d9-4030-a84c-556f31eca207.pdf

PS: The file was generated automatically via this site: https://www.cvgenerator.co.uk/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions