empira / PDFsharp-1.5

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

The file is not a valid PDF Document (PDF 2.0) #155

Closed bagsergen closed 1 year ago

bagsergen commented 2 years ago

Resources

Simple_pdf_2.0_file.pdf

Issue

Hi, I'm getting this error when I try to add info element on PDF 2.0. My purpose is custom metadata editing on pdf. Is PDFSharp supporting PDF 2.0 ? If not, can you suggest another package ?

Environtment: .Net 4.8 Framework

Expected Behavior

PdfSharp should open the file and add info element succesfully.

Actual Behavior

pdf_v2-0_not_opened

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;
    }
ThomasHoevel commented 2 years ago

PDFsharp does not yet support PDF 2.0.

ThomasHoevel commented 1 year ago

PDFsharp 6.0.0 should now support PDF 2.0.