Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

iText pdf methods not getting exposed in asp.net core C# application - GetNumberOfPages, GetPage

$
0
0

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

Please check screenshot

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


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>