在C#中,PDFsharp库使用(三):PDF提取

PDF提取

一、PDF提取功能,看图

d68fad88efc059aeaa351187eb0a44b7.png

二、PDF提取界面

ff90001cd028c85a559d042d25926226.png

三、PDF提取代码

//pdf提取---选择文件Button

private void button9_Click(object sender, EventArgs e)

{
     string oneFilePath = GetOneFilepath();
     if (!string.IsNullOrEmpty(oneFilePath))
       {
          textBox3.Text = oneFilePath;
       }
 }

//pdf提取---输出目录Button

private void button10_Click(object sender, EventArgs e)
  {
      string FileFolder = SelectFolder();
      if (!string.IsNullOrEmpty(FileFolder))
      {
         textBox4.Text = FileFolder;
      }
 }

//pdf提取---执行提取Button

private void button11_Click(object sender, EventArgs e)
  {
       int x = (int)numericUpDown2.Value;
       int y= (int)numericUpDown3.Value;
       string inputFilePath = textBox3.Text;
       string outputDirectory = textBox4.Text;
        // 确保输出目录存在
        if (!Directory.Exists(outputDirectory))
            {
                Directory.CreateDirectory(outputDirectory);
            }
       string outputFilePath1 = Path.Combine(outputDirectory, $"{Path.GetFileNameWithoutExtension(inputFilePath)}_{x}-{y}.pdf");
       string outputFilePath2 = Path.Combine(outputDirectory, $"{Path.GetFileNameWithoutExtension(inputFilePath)}_other.pdf");
       ExtractPages(inputFilePath, x, y, outputFilePath1);
       SaveRemainingPages(inputFilePath, x, y, outputFilePath2);
       MessageBox.Show("完成", "提示");
}

//ExtractPages函数,作用是提取指定PDF部分页面

6084d73b602ec547df240782ffb46d3b.png

//SaveRemainingPages函数,作用是上面提取完成后留下的部分,保存为另一个文件

71b9c538dc4f254910c9f71b9a607c68.png

发信息“PDF”,获取“PDF工具”

关注,阅读更多文章

ab31925ba936e1fad47f30aa73f9d61d.jpeg

相关推荐

  1. 使用 Python 从 PDF 文件提取、转换图像

    2024-04-22 11:50:05       41 阅读
  2. 使用Python提取PDF的文本和表格数据

    2024-04-22 11:50:05       44 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-22 11:50:05       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-22 11:50:05       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-22 11:50:05       87 阅读
  4. Python语言-面向对象

    2024-04-22 11:50:05       96 阅读

热门阅读

  1. 教授 Avi Wigderson荣获2023年图灵奖

    2024-04-22 11:50:05       39 阅读
  2. Go 之获取变量类型

    2024-04-22 11:50:05       38 阅读
  3. 【QT教程】QT6图形渲染与OpenGL编程

    2024-04-22 11:50:05       31 阅读
  4. 探索 Git:开源项目管理的利器

    2024-04-22 11:50:05       42 阅读
  5. Go读取文件n行的思路之旅

    2024-04-22 11:50:05       39 阅读
  6. 聚合支付的代付业务详解

    2024-04-22 11:50:05       41 阅读
  7. 大模型prompt engineering api开发

    2024-04-22 11:50:05       130 阅读
  8. torch.where()中并行方式的实现

    2024-04-22 11:50:05       82 阅读
  9. http和https区别与上网过程

    2024-04-22 11:50:05       35 阅读
  10. SQLite去除.db-shm和.db-wal文件【已解决】

    2024-04-22 11:50:05       34 阅读
  11. Spring Boot 中整合 Redisson 实现分布式锁

    2024-04-22 11:50:05       38 阅读
  12. 三年经验!你还不知道KVM虚拟化技术???

    2024-04-22 11:50:05       42 阅读