empira / PDFsharp-1.5

A .NET library for processing PDF
MIT License
1.28k stars 589 forks source link

Invalid entry in XRef table #154

Closed bagsergen closed 2 years ago

bagsergen commented 2 years ago

Resources

sample-pdf-with-images.pdf

Issue

Hi, I'm trying to add info element. Error as below has occured when I tried this case. Sample file is downloaded from internet.

Environtment: .Net 4.8 Framework

Expected Behavior

The key-value should be added correctly.

Actual Behavior

Invalid entry

Steps to Reproduce the Behavior

        PdfDocument document;
        try
        {
            document = PdfReader.Open(filePath);
            var properties = document.Info.Elements;                
            properties.SetString("/" + key, value);
            document.Save(filePath);
            document = null;                
            return true;
        }
        catch (Exception e)
        {
            if (document != null)
                document = null;
            throw;
        }
TH-Soft commented 2 years ago

At first glance, this is a corrupt PDF file and not a bug in PDFsharp.

bagsergen commented 2 years ago

I understood, thank you.