Windows API Code Pack - ShellFile not generating PDF bitmap(Windows API代码包-外壳文件不生成PDF位图)
本文介绍了Windows API代码包-外壳文件不生成PDF位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用前面堆栈溢出问题中的代码:
System.Drawing.Bitmap image;
ShellFile f = ShellFile.FromFilePath(fileLocation);
image = f.Thumbnail.ExtraLargeBitmap;
image.Save(tempfile, ImageFormat.Png);
我正在尝试使用Windows API获取PDF的缩略图
我被误认为这会生成一个类似于PDF文档第一页的图像文件。
但实际情况是,它看起来并不像那样,只是看起来像PDF图标。
在实际按预期工作之前,我是否遗漏了什么内容?
PDF文件已与Adobe Reader正确关联。
在Windows资源管理器中浏览目录时,我是否查看与文档关联的缩略图。
我应该指出的是,在处理Excel和Word文档时,代码实际上确实正确地提取了缩略图。
编辑(参考):
- C# get thumbnail from file via windows api
- Get thumbnail of any file, not only image files on Windows XP/Vista
- Windows API Code Pack Thumbnail gives preview thumb of pdf but not Word or Excel
推荐答案
您需要指定需要的是缩略图,而不是图标(默认设置)。 将您的代码更改为:
System.Drawing.Bitmap image;
ShellFile f = ShellFile.FromFilePath(fileLocation);
//force the actual thumbnail, not the icon
f.Thumbnail.FormatOption = ShellThumbnailFormatOption.ThumbnailOnly;
image = f.Thumbnail.ExtraLargeBitmap;
image.Save(tempfile, ImageFormat.Png);
这篇关于Windows API代码包-外壳文件不生成PDF位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:Windows API代码包-外壳文件不生成PDF位图


基础教程推荐
猜你喜欢
- MS Visual Studio .NET 的替代品 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 如何激活MC67中的红灯 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01