Embedded Files

We have historically used Aspose PDF with .NET to embed attachments into an existing PDF in certain circumstances which all works fine. The basic structure is below:

var MainPDF = new Aspose.Pdf.Document(“pdfdoc.pdf”);
var EmbeddedFile = new Aspose.Pdf.FileSpecification(“EmbeddedFile”, “Title”);
MainPDF.EmbeddedFiles.Add(EmbeddedFile);
MainPDF.Save();

We are now attempting to integrate with SharePoint. As far as we know, Aspose won’t source file content directly from SharePoint, so we generate MemoryStreams containing the MainFile and the EmbeddedFile, create the document and FileSpecification from the streams and then persist the stream back to SharePoint.

Problems seem to manifest in that the attachments to the PDF are there but are zero bytes in size, and we seem to be unable to set the MIMEType on the Aspose.Pdf.FileSpecification object.

Can you please let me know if this type of use-case is supported?

Correction: The files appear as zero bytes in the hint text of the attachment in Acrobat Reader, but are in fact fully embedded. If the FileSpecification.Name is suffixed with the mime type (in this case .PDF) then all seems to work.

Apologies we got this sorted. The constructor for a FileSpecification with a file system based source file that we use takes the file name and a name. The constructor for a FileSpecification with a stream has the second parameter as the description, not the name. There is an overload that allows for the stream, name and description to be passed that we’re now using successfully.

@miteleda2

It is good to know that you sorted out the issue. Please keep using our API and in case you face any issue, please feel free to let us know.