Free Support Forum -

Extract pdf file embedded in excel worksheet


I am working with 2.0 , office 2010, vs2005 , Abobe reader 7

I have an excel file with embed ‘pdf’ and ‘doc’ files.

I am able to read and save the ‘doc’ file.

if (inlineShape.OLEFormat.progID.StartsWith("word.document."))



Word.Document document = inlineShape.OLEFormat.Object as Word.Document;

FileInfo wfi = new FileInfo(fileName);

object wfileName = (object)(explodedDirectory + wfi.Name + "." + docCount.ToString() + ".doc");

object fileFormat = Word.WdSaveFormat.wdFormatDocument;

document.SaveAs(ref wfileName, ref fileFormat, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing);

document.Close(ref saveChanges, ref originalFormat, ref routeChanges);

document = null;


But can’t do anything with pdf.

I need to extract the ‘pdf’ file and save it in to a folder.

Thanks in Advance



Please check the topic on how to Extract Ole Objects in the Excel Workbook using Aspose.Cells for .NET API (See the sub-topic “Extracting OLE Objects in the Workbook”).

If you still find any issue, kindly give us your template Excel file containing an embedded PDF in it. We will check your issue soon.

Thank you.


Thanks for your help. it’s working. How can i embed pdf files to a Excel worksheet.



Could you try the sample code:
Workbook workbook = new Workbook();
//Get the first worksheet.
Worksheet sheet = workbook.Worksheets[0];
//Define a string variable to store the image path.
string ImageUrl = @“e:\test\pdf.jpg”;
//Get the picture into the streams.
FileStream fs = File.OpenRead(ImageUrl);
//Define a byte array.
byte[] imageData = new Byte[fs.Length];
//Obtain the picture into the array of bytes from streams.
fs.Read(imageData, 0, imageData.Length);
//Close the stream.
//Get an pdf file path in a variable.
string path = @“e:\test2\abc.pdf”;
//Get the file into the streams.
fs = File.OpenRead(path);
//Define an array of bytes.
byte[] objectData = new Byte[fs.Length];
//Store the file from streams.
fs.Read(objectData, 0, objectData.Length);
//Close the stream.
sheet.OleObjects.Add(14, 3, 200, 220, imageData);
//Set embedded ole object data.
sheet.OleObjects[0].ObjectData = objectData;
sheet.OleObjects[0].FileType = OleFileType.Pdf;
//Save the excel file

Thanks …It’s working