empira / PDFsharp-1.5

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

Make it possible to provide custom XMP metadata #80

Open wiz78 opened 5 years ago

wiz78 commented 5 years ago

The PdfMetadata class is now inheritable. PdfDocument has a new delegate that can be used to provide a different implementation of that class that creates custom metadata.

e.g.:

class MyXMPMetadata : PdfMetadata
{
    private readonly XmpCore    xmp;

    public MyXMPMetadata( PdfDocument document, XmpCore xmpCore ) : base( document )
    {
        xmp = xmpCore;

        SetupStream();
    }

    protected override byte[] GenerateXmp()
    {
        return xmp?.SerializeToRDF();
    }
}