'PdfTextExtractor' does not contain definition for 'GetTextFromPage', it throws Compiler Error CS0117
This is my code, which I have coppied just to check how does iText7 work:
using System;
using iText.Kernel.Pdf;
using iText.Kernel.Pdf.Canvas.Parser.Listener;
namespace PdfParser
{
public static class PdfTextExtractor
{
public static void ExtractTextFromPDF(string filePath)
{
PdfReader pdfReader = new PdfReader(filePath);
PdfDocument pdfDoc = new PdfDocument(pdfReader);
for (int page = 1; page <= pdfDoc.GetNumberOfPages(); page )
{
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
// the line below throws the exception
string pageContent = PdfTextExtractor.GetTextFromPage(pdfDoc.GetPage(page), strategy);
}
pdfDoc.Close();
pdfReader.Close();
}
}
}
I tried using iTextCsharp, but there was writen that iText7 is a new version.
I am working on "Console Application", maybe this is the problem? Should I use another framework?
CodePudding user response:
The problem is that your class is also called PdfTextExtractor
. Please rename your static class and the issue will be solved.
For future issues, you can jump to the reference (via F12 or similar, depending on your IDE/Shorctus) and check where it directs you.