Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate a thumbnail of a Word document

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.

like image 576
mona Avatar asked Jun 17 '09 21:06

mona


People also ask

What is a thumbnail in Word?

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.

How do I permanently make an image in Word?

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.


3 Answers

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.

like image 79
David Avatar answered Oct 02 '22 20:10

David


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

like image 27
Kamil Budziewski Avatar answered Oct 02 '22 20:10

Kamil Budziewski


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
like image 38
James Moberg Avatar answered Oct 02 '22 20:10

James Moberg