C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » General »

To get PDF pagecount


Posted Date: 29 Oct 2008      Posted By: Dharmaraj      Member Level: Diamond     Points: 1   Responses: 1



Hi,
I am having a task for counting the number of pages in a PDF file, here is my code.

FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
StreamReader r = new StreamReader(fs);
string pdfText = r.ReadToEnd();
Regex rxl = new Regex(@"/Type\s/Page[^s]");
MatchCollection match = rxl.Matches(pdfText);
return match.Count.ToString();

But its not returning the page count for all the pdf files. Can anyone share me a code which will count all the pages for a PDF file.
Regards,
Dharma

Regards,
Dharma
Editor,Mentor,MVM
Try and fail but don't fail and try
Me and DNS





Responses

Author: Ankush    29 Oct 2008Member Level: SilverRating: 1 out of 5     Points: 1

I think we can use Regex as "/Type\s*/Page[^s]".This can help you.


Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : sp1.msb not found -why
Previous : ToolTip Adding to Report (SQL Server 2005 Reporting Services)
Return to Discussion Forum
Post New Message
Category: General

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use