没有demo,如果不会实现,建议你用截屏来实现试试
[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); }
参考这个 基于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
社区成员
12,293
社区内容
加载中
试试用AI创作助手写篇文章吧