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

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

asp.net - Windows API Code Pack Thumbnail gives preview thumb of pdf but not Word or Excel

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...