PDF文件转成图片

kiss3389 2016-04-04 10:42:22
请教下,如何将PDF文件(一页)转成图片(jpg,bmp等)。有什么控件可以直接使用不?
...全文
596 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
T被打的小猪M 2016-04-22
  • 打赏
  • 举报
回复
有这一类的转换网站,像http://app.xunjiepdf.com/pdf2img,可以将pdf的一页转换成图片的。
kiss3389 2016-04-13
  • 打赏
  • 举报
回复
引用 5 楼 lzp_lrp 的回复:
没有demo,如果不会实现,建议你用截屏来实现试试
好的,谢谢。结贴吧。。。
kiss3389 2016-04-12
  • 打赏
  • 举报
回复
引用 3 楼 kiss3389 的回复:
[quote=引用 1 楼 lzp_lrp 的回复:] 参考这个 基于Aspose.Pdf把pdf文件每一页转换为图片 //1.选择pdf文件 var dialog = new OpenFileDialog(); dialog.Filter = "pdf文件|*.pdf"; var dialogResult = dialog.ShowDialog(); if (dialogResult != System.Windows.Forms.DialogResult.OK) { return; } //和选择的文件并列创建一个目录 string filePath = dialog.FileName; string directoryPath = filePath + "目录"; //aspose许可证 Aspose.Pdf.License l = new Aspose.Pdf.License(); string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic"); l.SetLicense(licenseName); //定义Jpeg转换设备 Aspose.Pdf.Document document = new Aspose.Pdf.Document(filePath); var device = new Aspose.Pdf.Devices.JpegDevice(); int quality = int.Parse(this.comboBox1.SelectedItem.ToString()); directoryPath += quality; Directory.CreateDirectory(directoryPath); //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩 device = new Aspose.Pdf.Devices.JpegDevice(quality); //遍历每一页转为jpg for (var i = 1; i <= document.Pages.Count; i++) { string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}.jpg", i)); FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate); try { device.Process(document.Pages[i], fs); fs.Close(); } catch (Exception ex) { fs.Close(); File.Delete(filePathOutPut); }
能给个demo吗?[/quote] 补充下,要PB的demo
kiss3389 2016-04-12
  • 打赏
  • 举报
回复
引用 1 楼 lzp_lrp 的回复:
参考这个 基于Aspose.Pdf把pdf文件每一页转换为图片 //1.选择pdf文件 var dialog = new OpenFileDialog(); dialog.Filter = "pdf文件|*.pdf"; var dialogResult = dialog.ShowDialog(); if (dialogResult != System.Windows.Forms.DialogResult.OK) { return; } //和选择的文件并列创建一个目录 string filePath = dialog.FileName; string directoryPath = filePath + "目录"; //aspose许可证 Aspose.Pdf.License l = new Aspose.Pdf.License(); string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic"); l.SetLicense(licenseName); //定义Jpeg转换设备 Aspose.Pdf.Document document = new Aspose.Pdf.Document(filePath); var device = new Aspose.Pdf.Devices.JpegDevice(); int quality = int.Parse(this.comboBox1.SelectedItem.ToString()); directoryPath += quality; Directory.CreateDirectory(directoryPath); //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩 device = new Aspose.Pdf.Devices.JpegDevice(quality); //遍历每一页转为jpg for (var i = 1; i <= document.Pages.Count; i++) { string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}.jpg", i)); FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate); try { device.Process(document.Pages[i], fs); fs.Close(); } catch (Exception ex) { fs.Close(); File.Delete(filePathOutPut); }
能给个demo吗?
WorldMobile 2016-04-12
  • 打赏
  • 举报
回复
没有demo,如果不会实现,建议你用截屏来实现试试
WorldMobile 2016-04-05
  • 打赏
  • 举报
回复
参考这个 基于Aspose.Pdf把pdf文件每一页转换为图片
//1.选择pdf文件
var dialog = new OpenFileDialog();
dialog.Filter = "pdf文件|*.pdf";
var dialogResult = dialog.ShowDialog();
if (dialogResult != System.Windows.Forms.DialogResult.OK) {
return;
}

//和选择的文件并列创建一个目录
string filePath = dialog.FileName;
string directoryPath = filePath + "目录";
//aspose许可证
Aspose.Pdf.License l = new Aspose.Pdf.License();
string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
l.SetLicense(licenseName);
//定义Jpeg转换设备
Aspose.Pdf.Document document = new Aspose.Pdf.Document(filePath);
var device = new Aspose.Pdf.Devices.JpegDevice();
int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
directoryPath += quality;
Directory.CreateDirectory(directoryPath);
//默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
device = new Aspose.Pdf.Devices.JpegDevice(quality);
//遍历每一页转为jpg
for (var i = 1; i <= document.Pages.Count; i++) {
string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}.jpg", i));
FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
try {
device.Process(document.Pages[i], fs);
fs.Close();
} catch (Exception ex) {
fs.Close();
File.Delete(filePathOutPut);
}

604

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 控件与界面
社区管理员
  • 控件与界面社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧