I have a website where users upload Word documents and I want to display thumbnails of these word documents. If anyone of you knows how to display the first page of a Word file as an image using C# please tell me.
Also if you know a trusted .NET library to convert word files to images that requires no office interop that would be great.
A thumbnail is a miniature representation of a page or image that is used to identify a file by its contents. Clicking the thumbnail opens the file.
Click on the Picture Position tab. Under both the Horizontal and Vertical selections, select Absolute Position, and pick "Page" from the drop-down menu at the right. Also, click on the checkbox that says "Lock anchor." Now, your pictures won't move around the page.
Take a look at this article. It's in VB, but it lets you extract the thumbnail image that Windows Explorer uses for Office documents and regular images.
http://blogs.msdn.com/windowssdk/archive/2009/06/12/windows-api-code-pack-for-microsoft-net-framework.aspx
ShellFile shellFile = ShellFile.FromFilePath(pathToYourFile);
Bitmap shellThumb = shellFile.Thumbnail.ExtraLargeBitmap;
It's Microsoft's API Code Pack
I found this question (7 yrs later) while searching for a similar solution. I'm evaluating 2JPEG and it appears to support 275 formats including Word, Excel, Publisher & Powerpoint files. fCoder recommends running 2JPEG as a scheduled background task. The command line syntax is pretty comprehensive.
Here's a sample snippet to generate a thumbnail for a specific file:
2jpeg.exe -src "c:\files\myfile.docx" -dst "c:\files" -oper Resize size:"100 200" fmode:fit_width -options pages:"1" scansf:no overwrite:yes template:"{Title}_thumb.jpg" silent:yes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With