hi all,
i am using
PdfReader pdfr = new PdfReader(strFilePath);
TextBox1.Text = pdfr.NumberOfPages.ToString();
but my problem is that , it capture page number of some pdf file and some time it does not capture the page number. I am using itextsharp.dll
plese give some solutation. its urgent
Thanks in Advance.
i am using
PdfReader pdfr = new PdfReader(strFilePath);
TextBox1.Text = pdfr.NumberOfPages.ToString();
but my problem is that , it capture page number of some pdf file and some time it does not capture the page number. I am using itextsharp.dll
plese give some solutation. its urgent
Thanks in Advance.

Vignesh KumarPosted Jan 3, 2014, 2:57 AM
Try this,
This is for console app
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using iTextSharp.text.pdf;
using iTextSharp.text.xml;
namespace GetPages_PDF
{
class Program
{
static void Main(string[] args)
{
// Right side of equation is location of YOUR pdf file
string ppath = "C:\\working\\Object.pdf";
PdfReader pdfReader = new PdfReader(ppath);
int numberOfPages = pdfReader.NumberOfPages;
Console.WriteLine(numberOfPages);
Console.ReadLine();
}
}
}
or
public int getNumberOfPdfPages(string fileName)
{
using (StreamReader sr = new StreamReader(File.OpenRead(fileName)))
{
Regex regex = new Regex(@"/Type\s*/Page[^s]");
MatchCollection matches = regex.Matches(sr.ReadToEnd());
return matches.Count;
}
}