We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PDF file embedded inside excel are not coming after converting to PDF

Hi Aspose,



We
are trying to convert some of our Excel to PDF. One of our excel have
pdf embedded inside the excel. Is it possible to embed the pdfs(or
any others like .doc,.zip) in converted PDF.

For example if I have a sample1.xls and its having some pdfs in it.

After converting the Excel to PDF the pdfs inside the excel are not coming. The PDF just has the name of the embedded pdfs.

Thanks and Regards,
Prabu K

Hi Prabu,


Thank you for contacting Aspose support.

First of all, please note that Aspose.Cells APIs follow Excel’s guidelines & specifications for its processes. If you use Excel application to convert a spreadsheet (containing an embedded PDF) to PDF format then you will notice that the result is same as of Aspose.Cells APIs, that is; only the file name of the OleObject/embedded object will be rendered to the resultant PDF. However, if you wish to extract the embedded file from the spreadsheet and save it separately then you can use the following snippet to achieve this.

Let us know if the following solution fulfills your requirement.

C#

var book = new Workbook(dir + “embedded-pdf.xlsx”);
var sheet = book.Worksheets[0];
foreach(Aspose.Cells.Drawing.OleObject emdeddedObject in sheet.OleObjects)
{
string fileName = emdeddedObject.ObjectSourceFullName;
byte[] oleBytes = emdeddedObject.ObjectData;
File.WriteAllBytes(dir + Path.GetFileName(emdeddedObject.ObjectSourceFullName), oleBytes);
}
book.Save(dir + “output.pdf”, new PdfSaveOptions());

Note: As you have not mentioned the platform of interest therefore I have provided the solution as per .NET API of Aspose.Cells product.