Hi All,
- In Open XML, there are basically 2 different classes provided to embed any file or object in Open XML Document.
- EmbeddedPackagePart
- EmbeddedObjectPart
- EmbeddedPackagePart is used to embed Open XML Packages inside document, for e.g. docx, xlsx files.
- Using EmbeddedObjectPart, we can add any file as an Object inside document.
Scenarios:
Embed Open XML package inside document
In this case, we can use EmbeddedPackagePart class and use feeddata method of same class, which will create a package file (extension: .package). And store it into embeddings folder under document folder of Open XML package.
As package is an Open XML package, OpenXML SDK easily can cache it and store it inside document package.
MSDN Code Ref. https://msdn.microsoft.com/en-us/library/ee355229(v=office.12).aspx
Embed Object inside document
In this case, we use EmbeddedObjectPart with application/vnd.openxmlformats-officedocument.oleObject content type. When we use feeddata method of this class, it will create a Bin file (extension: .bin) and store it in embeddings folder.
Now issue is Open XML itself not able to create bin cache file. It’s not get linked with Object tag in document, as Microsoft Office does not recognized bin file created by Open XML SDK.
So we use Open XML Productivity Tool shipped with Open XML SDK from MSDN ( https://www.microsoft.com/en-us/download/details.aspx?id=30425 ). And use that tool to regenerate code of Docx file, which have an embedded Object using Microsoft word.
In code we have found, a Base 64 String, which is used to generate object. When we convert that Base 64 String to check file type, we have found that file signature (Magic Number: https://en.wikipedia.org/wiki/Magic_number_(programming) ) of Base 64 was related to Old file extensions e.g. Doc, xls.
List of file signatures : https://en.wikipedia.org/wiki/List_of_file_signatures
Magic Number of File Extensions : http://asecuritysite.com/forensics/magic
Can someone help me on this?
Regards,
Manish
manish