Hi Michael,
Thank you for considering Aspose.Pdf.
I think you can use Attachment.AttachedStream API and see if it fits your requirement. You can create your ByteArray to a MemoryStream and attach it to the pdf file. Please see the following sample code in this regard:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
//Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
//Add a section into the pdf document
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
//Instantiate attachment instance by calling its empty constructor
Aspose.Pdf.Generator.Attachment fileAttachment = new Aspose.Pdf.Generator.Attachment();
//Add attachment in the paragraphs collection of the section
sec1.Paragraphs.Add(fileAttachment);
//Set attachment type to File using AttachmentType enumeration
fileAttachment.AttachmentType = Aspose.Pdf.Generator.AttachmentType.File;
//Set the path of the attachment file
fileAttachment.AttachedFileName = "Result.png";
// Create a FileStream object to read the imag file
FileStream fs = File.OpenRead(@"E:\AP DATA\Source_Files\Result.png");
// Read the image into Byte array (You can use the code here onwards)
byte[] data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
// Create a MemoryStream object from image Byte array
MemoryStream ms = new MemoryStream(data);
fileAttachment.AttachedStream = ms;
//Set the type of the file to be attached
fileAttachment.AttachedFileType = "png";
pdf1.Save(@"E:\AP DATA\Source_Files\Attachment_Test.pdf");
Please do let us know if this fits your requirement or not.
Thank You & Best Regards,