I'm using iText pdf library to process PDF files using C# in asp.net core application.I'm getting following errors while using GetNumberOfPages and GetPage methods.
Error CS1061 'PdfReader' does not contain a definition for 'GetNumberOfPages' and no accessible extension method 'GetNumberOfPages' accepting a first argument of type 'PdfReader' could be found (are you missing a using directive or an assembly reference?)
Severity Code Description Project File Line Suppression StateError CS1061 'PdfReader' does not contain a definition for 'GetPage' and no accessible extension method 'GetPage' accepting a first argument of type 'PdfReader' could be found (are you missing a using directive or an assembly reference?)
I have used both iText and iText7 nugget libraries
List<byte[]> chunks = new List<byte[]>();using (MemoryStream pdfStream = new MemoryStream(pdfBytes)){ using (PdfReader pdfReader = new PdfReader(pdfStream)) { int pageCount = pdfReader.GetNumberOfPages(); for (int i = 1; i <= pageCount; i++) { using (MemoryStream chunkStream = new MemoryStream()) { using (PdfWriter pdfWriter = new PdfWriter(chunkStream)) { using (PdfDocument pdfDocument = new PdfDocument(pdfWriter)) { pdfDocument.AddPage(pdfReader.GetPage(i).CopyTo(pdfDocument)); } } chunks.Add(chunkStream.ToArray()); } } }}
I have tried both iText and iText7 but issue isn't resolved