I have a problem, when I try to attach a file to a pdf document
When I create a new pdf document the attachment works just fine
- Code: Select all
var doc = new PdfDocument();
var attachment = new PdfAttachment(attachmentFilename);
attachment.Data = File.ReadAllBytes(attachmentFilename);
attachment.Description = "Some PDF File.";
attachment.MimeType = "application/pdf";
doc.Attachments.Add(attachment);
doc.SaveToFile(outputFilename);
doc.Close();
but in the other case when I want to add an attachment to an existing pdf document
doc.Attachments is not initialized at all!
- Code: Select all
var doc = new PdfDocument();
doc.LoadFromFile(pdfFilename, FileFormat.PDF);
What am I doing wrong?