MIMEtype is not set when adding an XML attachment to PDF when creating a ZUGFeRD PDF

Hi,
I tried to create a ZUGFeRD PDF and attach the corresponding XML.
I used your code template from docs here: Attach ZUGFeRD

What didn’t work for me was setting the correct MIMEType. Like in the template, I set the MIMEType to text/xml but when I checked the embedded files in the saved pdf, the Xml was added with the MIMEType application/pdf.

After a quick search I found this old post: MIMEtype is not set when adding an XML attachment to PDF
It is declared as a bug there but no solution was provided.

Since there was no solution I tried some things and noticed that when you convert the pdf to the PDF A3U format first and then add the embedded files, the correct MIMEType will be set.

I don’t know if this is still a bug or if the docs are outdated.

@BAV_Institut

You should use the following code.

var doc = new Document(inputFileName);
doc.Pages.Add();
string fileName = GetInputPath("fileName.xml");
var fs = new FileSpecification(fileName)
{
    Description = "ZUGFeRD invoice in XML format",
    Name = "factur-x.xml"
};
doc.EmbeddedFiles.Add(fs);
doc.Convert(new MemoryStream(), PdfFormat.ZUGFeRD, ConvertErrorAction.Delete);

I will wait for your feedback.