比如pdf文档在大图标显示下会显示出第一页的内容,
这个第一页的内容是怎么得到的?

解决方案 »

  1.   

    PDF->Generate Thumbnail Images from PDF Documents
    http://www.codeproject.com/KB/GDI-plus/pdfthumbnail.aspx
      

  2.   

    Doc file ->找到一个代码,不知道是否可用using System.IO;
    using System.Drawing.Imaging;private const int THUMBNAIL_DATA = 0x501B;
    /// <summary>
    /// Gets the thumbnail from the image metadata. Returns null of no
    thumbnail
    /// is stored in the image metadata
    /// </summary>
    /// <param name="path"></param>
    /// <returns></returns>
    Image GetThumbnail (string path)
    {
    FileStream fs = File.OpenRead (path);
    // Last parameter tells GDI+ not the load the actual image data
    Image img = Image.FromStream (fs, false, false);
    // GDI+ throws an error if we try to read a property when the image
    // doesn't have that property. Check to make sure the thumbnail
    property
    // item exists.
    bool propertyFound = false;
    for (int i=0; i<img.PropertyIdList.Length; i++)
    if (img.PropertyIdList[i] == THUMBNAIL_DATA)
    {
    propertyFound = true;
    break;
    }if (!propertyFound)
    return null;PropertyItem p = img.GetPropertyItem (THUMBNAIL_DATA);
    fs.Close();
    img.Dispose();
    // The image data is in the form of a byte array. Write all
    // the bytes to a stream and create a new image from that stream
    byte[] imageBytes = p.Value;
    MemoryStream stream = new MemoryStream (imageBytes.Length);
    stream.Write (imageBytes, 0, imageBytes.Length);return Image.FromStream(stream);
    }