比如pdf文档在大图标显示下会显示出第一页的内容,
这个第一页的内容是怎么得到的?
解决方案 »
- VS2008 如何实现通过针式打印机打印单据 急!!!
- c#动态创建属性
- C#一些基础常识问题?大侠们帮帮忙,俺想学习。
- 请问怎么捕捉dataGridView中单元格的写入事件啊,就是单元格一录数据就改变另一个单元格,来点提示也好啊。
- 程序打包问题
- C# 电子书
- Directx9.0中的NetworkPacket如果像客户端传一个对象?
- 删除了 dataset 中的表,再次连接时,dataGrid 不显示数据了,郁闷呀。。。
- 在类的构造函数里初始化的变量,怎样才能让类中的方法调用啊?
- Remoting超时?
- 用C#写个操作命令行窗口的代码,help
- Convert.ToInt16 与 Convert.ToInt32 究竟区别在哪里?
http://www.codeproject.com/KB/GDI-plus/pdfthumbnail.aspx
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);
}