Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我如何在c中解析pdf#_C#_Parsing_Pdf - Fatal编程技术网

C# 我如何在c中解析pdf#

C# 我如何在c中解析pdf#,c#,parsing,pdf,C#,Parsing,Pdf,我想解析一个pdf文件,并在该pdf文件中添加一些标签,这样我就可以将其上传到几个论坛。我在考虑可能使用c#(或者可能是python),让它阅读pdf并在需要时插入标记。从哪里开始呢?到目前为止,我可以将pdf转换成文本文件。但从那以后我就被难住了。以下是我目前掌握的情况: /* * Convert PDF To Text * *******************/ using System; using System.Co

我想解析一个pdf文件,并在该pdf文件中添加一些标签,这样我就可以将其上传到几个论坛。我在考虑可能使用c#(或者可能是python),让它阅读pdf并在需要时插入标记。从哪里开始呢?到目前为止,我可以将pdf转换成文本文件。但从那以后我就被难住了。以下是我目前掌握的情况:

        /*
         * Convert PDF To Text
         * *******************/

    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Drawing.Printing;
    using System.IO;
    using System.Text;
    using System.ComponentModel.Design;
    using System.ComponentModel;
    using org.pdfbox.pdmodel;
    using org.pdfbox.util;

    namespace Test.iPdfToText
    {
        public partial class MainForm : Form
        {
            public MainForm()
            {
                InitializeComponent(); 
            }

            void Button1Click(object sender, EventArgs e)    
            {    
                PDDocument doc = PDDocument.load("C:\\pdftoText\\myPdfTest.pdf");
                PDFTextStripper stripper = new PDFTextStripper();
                richTextBox1.Text=(stripper.getText(doc));
            }

         }
    }

你可能想看看这个我已经看过了。似乎大多数人都希望更改pdf并保留pdf作为最终结果。我想以一个文本文件结束。因此,基本上,我可以将我的pdf转换为纯文本,然后进行更改。我困惑的部分是如何插入文本文件(我代码中的richTextBox),您试图解决什么问题?您提供的代码是否将文本放入文本框?是的,它将文本放入文本框。但是,我想搜索这个文本框,然后找到一段粗体文本。一旦我找到这个,我就需要在文本周围添加标签。我该一个字一个字地看一遍吗?谢谢您在文本框中搜索粗体文本吗?或者您想知道PDF中提取文本的哪些部分是粗体的吗?或者更一般地说,您试图从PDF中提取什么样的信息?