码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 使用apose.pdf批量导出图片


    今天遇到了,需要将pdf文件插到word里,好像word不支持直接插入pdf文件,所以现在通过将pdf转为图片的方式,逐个将图片插入到word。这里使用apose.pdf第三方库,将多个pdf文件读取,然后转为pdf。具体的实现代码如下所示。

    1. private void BTN_PDF_TO_IMAGES_Click(object sender, EventArgs e)
    2. {
    3. List<string> files = GetFiles(@"C:\Users\qrb\Desktop\测绘资质\三、专业技术人员\part7", new string[] { "*.pdf"});
    4. int indexxx = 0;
    5. foreach (var item in files)
    6. {
    7. indexxx = indexxx + 1;
    8. Console.WriteLine(item);
    9. try
    10. {
    11. Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(item);
    12. int pageCount = pdfDocument.Pages.Count;
    13. Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(130);
    14. Aspose.Pdf.Devices.JpegDevice jpegDevice = new Aspose.Pdf.Devices.JpegDevice(resolution);
    15. string parentPath=Path.GetDirectoryName(item);
    16. string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item);
    17. for (int pageIndex = 1; pageIndex <= pageCount; pageIndex++) {
    18. string fileName = parentPath + "\\"+ fileNameWithoutExtension + "_" + Convert.ToString(pageIndex)+".jpeg";
    19. MemoryStream stream = new MemoryStream();
    20. jpegDevice.Process(pdfDocument.Pages[pageIndex], stream);
    21. using (var fs = new FileStream(fileName, FileMode.OpenOrCreate))
    22. {
    23. jpegDevice.Process(pdfDocument.Pages[pageIndex], fs);
    24. fs.Close();
    25. }
    26. }
    27. }
    28. catch (Exception ex) {
    29. System.Windows.Forms.MessageBox.Show("异常错误:" + ex.ToString());
    30. }
    31. }

  • 相关阅读:
    ATF问题二则:EL3可能没有实现吗?&& aarch32中的S-EL1是什么?
    系列二、Shiro的核心组件
    【历史上的今天】6 月 28 日:马斯克诞生;微软推出 Office 365;蔡氏电路的发明者出生
    GMAN: A Graph Multi-Attention Network for Traffic Prediction(2020AAAI)
    为什么许多shopify独立站卖家都在用聊天机器人?一分钟读懂行业秘密!
    search_engine:搜索引擎实现
    基于gunicorn+flask+docker模型高并发部署
    蓝桥等考Python组别十级007
    springboot+vue云 农产品中心门户系统
    公共政策学考试题库
  • 原文地址:https://blog.csdn.net/u010608964/article/details/133875594
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号