2015-02-24 35 views

回答

1

您可以使用iTextSharp .NET庫將PDF文件轉換爲文本。

的簡短的文章關於PDF至txt文件在以下鏈接解釋:

C-sharp pdf to txt

+0

提到「已掃描」 ,我認爲這隻適用於PDF實際包含文本而非掃描圖像的情況。 – 2015-02-24 06:25:29

+0

轉換爲txt文件時,它無法像解析文檔文件一樣解析圖像。 @SamiKuhmonen – Karthikeyan 2015-02-24 07:12:13

0

您可以參考此示例代碼。

using iTextSharp.text.pdf; 
using iTextSharp.text.pdf.parser; 

// ... 

public static string ExtractTextFromPdf(string path) 
{ 
using (PdfReader reader = new PdfReader(path)) 
{ 
StringBuilder text = new StringBuilder(); 

for (int i = 1; i <= reader.NumberOfPages; i++) 
{ 
    text.Append(PdfTextExtractor.GetTextFromPage(reader, i)); 
} 

return text.ToString(); 
} 
} 
+0

嗨可汗,我需要從PDF圖像文本,但你張貼從普通PDF格式的閱讀文本。 – 2015-02-24 06:30:08

0

我在一年前試過這個,寫了我自己的解析器,但沒有運氣。但我認爲你應該找到一種方法將圖像格式的pdf粘貼到文檔中。

我知道這不是答案,但它有助於改變你對如何達到你的要求的想法。