Reputation: 4202
so I learned about the System.IO.Packaging.ZipPackage
in .NET. I am trying to use it to extract a thumbnail that is located in word documents if you 'Save as Thumbnail', the general advice seems to be to use a third-part library instead, but does anyone perhaps know how to do this?
Upvotes: 1
Views: 1168
Reputation: 38077
If you know you are only working with .docx files, you can read the thumbnail, if the document has one, using this code:
ZipPackage zip = ZipPackage.Open(@"C:\Test Documents\thumbnail.docx") as ZipPackage;
var part = zip.GetPart(new Uri("/docProps/thumbnail.emf", UriKind.Relative));
if (part != null)
{
Image i = Image.FromStream(part.GetStream());
pictureBox1.Image = i;
}
Upvotes: 2