Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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);

This 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...