Ale*_*x C 5 c# pdf thumbnails windows-api-code-pack
使用先前堆栈溢出问题中的代码:
System.Drawing.Bitmap image;
ShellFile f = ShellFile.FromFilePath(fileLocation);
image = f.Thumbnail.ExtraLargeBitmap;
image.Save(tempfile, ImageFormat.Png);
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用Window API来获取PDF的缩略图
我被认为可以生成类似于PDF文档第一页的图像文件。
但是实际情况是,它看起来并不像PDF图标。
在实际按预期工作之前,我是否需要缺少任何内容?
PDF文件已与Adobe Reader正确关联。
在Windows资源管理器中浏览目录时,我确实会看到与文档关联的缩略图。
我应该注意,在处理Excel和Word文档时,该代码实际上确实可以正确提取缩略图。
编辑(参考):
小智 1
问题是因为您尚未选择要从中创建缩略图的活动帧。
我无法在我当前的计算机上验证它,因为我没有 Windows API,但它为您提供了标准 PDF 缩略图,因为在您的代码中您没有指定用于缩略图的页面。
尝试做这样的事情:
Image image = new Image();
//Load image here
int frameindex = 1; // Page number you want to use for thumbnail
Guid guide = image.FrameDimensionsList[0];
FrameDimension fDimension = new FrameDimension(guide);
image.SelectActiveFrame(fDimension, frameindex);
//Then go on to extract your thumbnail
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3826 次 |
| 最近记录: |