Issues embeding PDF using InsertOleObject

Hi,

I’m trying to attach a PDF to a word document but getting issues opening the file from within Word. If I embed from within word it works fine.

I’ve tried the following code:

builder.InsertOleObjectAsIcon(filePath, false, null, filename);
Stream memStream = File.OpenRead(filePath);
builder.InsertOleObject(memStream, "AcroExch.Document.DC", true, null);
builder.InsertOleObject(memStream, "Package", true, null);
builder.InsertOleObject(memStream, "Acrobat.Document.DC", true, null);

Any help would be greatly appreciated.

Thanks,

Dan

@daniel.miller Please use the following code to insert PDF OLE object into the document:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
string filePath = @"C:\Temp\test.pdf";
// Insert from the file
builder.InsertOleObject(filePath, false, true, null);
// Insert from the stream
using (Stream fileStream = File.OpenRead(filePath))
{
    builder.InsertOleObject(fileStream, "AcroExch.Document.7", true, null);
}
doc.Save(@"C:\Temp\out.docx");