How to find text from pdf image?

后端 未结 2 744
误落风尘
误落风尘 2021-02-11 01:27

I am developing a C# application in which I am converting a PDF document to an image and then rendering that image in a custom viewer.

I\'ve come across a bit of a bric

2条回答
  •  旧巷少年郎
    2021-02-11 01:56

    Use ITextSharp download it here. Make sure the PDF is searchable.

    and use this code:

    public static string GetTextFromAllPages(String pdfPath)
    {
        PdfReader reader = new PdfReader(pdfPath); 
    
        StringWriter output = new StringWriter();  
    
        for (int i = 1; i <= reader.NumberOfPages; i++) 
            output.WriteLine(PdfTextExtractor.GetTextFromPage(reader, i, new SimpleTextExtractionStrategy()));
    
        return output.ToString();
    }
    

提交回复
热议问题