Hi Lisa,
Thanks for your inquiry. First of all, please see the attached document. There are three embedded objects inside the attached document. Simple embedded document, embedded as link and embedded as icon (show icon). You can try using the following code to extract each of these embedded objects and convert them to PDF as well:
Document doc = new Document(@“c:\temp\test.docx”);
// Get collection of shapes
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
int i = 0;
//Loop through all shapes
foreach (Shape shape in shapes)
{
if (shape.OleFormat != null)
{
if (!shape.OleFormat.IsLink)
{
//Extract OLE Word object
if (shape.OleFormat.ProgId == “Word.Document.12”)
{
MemoryStream stream = new
MemoryStream();
shape.OleFormat.Save(stream);
Document newDoc = new
Document(stream);
newDoc.Save(string.Format(@“C:\temp\outEmbeded_{0}.pdf”, i));
i++;
}
//Extract OLE Excel object
if (shape.OleFormat.ProgId == “Excel.Sheet.12”)
{
// Here you can use Aspose.Cells component
// to be able to convert MS Excel files to PDF
}
}
else
{
string filePath = shape.OleFormat.SourceFullName;
Document newDoc = new
Document(filePath);
newDoc.Save(string.Format(@“C:\temp\outLinkedEmbeded_{0}.pdf”,
i));
i++;
}
}
}
Secondly, when you convert the main document, in this case ‘test.docx’, directly to PDF format, the content of embedded objects inside will be rendered in PDF. There will be no attachments or links in the final PDF.
Please let me know if I can be of any further assistance.
Best Regards,