开发者

Windows API Code Pack Thumbnail gives preview thumb of pdf but not Word or Excel

开发者 https://www.devze.com 2023-03-25 22:12 出处:网络
I am using the Microsoft API Code Pack and have a handler using the following code string filename = \"C:\\\\Hello.pdf\";

I am using the Microsoft API Code Pack and have a handler using the following code

    string filename = "C:\\Hello.pdf";

    ShellFile shellFile = ShellFile.FromFilePath(filename);
    Bitmap bitmap = shellFile.Thumbnail.ExtraLargeBitmap;

    context.Response.ContentType = "image/jpeg";
    bitmap.Save(context.Response.OutputStream, ImageFormat.Jpeg);

T开发者_JAVA技巧his works fine to produce a "preview" style thumbnail for pdf documents, but when I try it with Word or Excel I get the generic thumbnail for the filetype instead of a mini image of the document (which is what I'm looking for).

Anyone have ideas on this? Can it be done using this API?


As David said, not all Office documents are saved with a thumbnail. It's a property on the document itself. In Office 2010 you can see the checkbox on the Save As dialog box. In older versions of Office you can find it in the document properties.

Once the Office document is saved with a thumbnail, the code you have will work.

0

精彩评论

暂无评论...
验证码 换一张
取 消