Generate a thumbnail of a Word document

可紊 提交于 2019-12-18 13:25:08

问题


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.


回答1:


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.




回答2:


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




回答3:


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


来源:https://stackoverflow.com/questions/1009693/generate-a-thumbnail-of-a-word-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!