[RESOLVED] To find the starting page number and end page number of a pdf file
Dear all,
Can anyone help me to find the starting page number and the end page number of a pdf file. The pdf file may start with any number (for example the pdf file can start with the page number 10 and end with 20) the code should find out the start pare number 10 and the end page number 20.
Thanks in advance.
Re: To find the starting page number and end page number of a pdf file
PDF files can start with roman numerals or any made up characters as well.
Howevre, all PDF pages have an internal pageIndex, which is the actual index of the page within the document.
So even if the first four pages of a 10 page PDF were labeled with roman numerals, the fifth page could be labeled 'Page 1', but it internally has a pageIndex equal to 5.
So the question to you is, do you want the internal page index? If you do, that is easy to obtain. If not, it gets severely more complicated.
1 Attachment(s)
Re: To find the starting page number and end page number of a pdf file
Yes Nemaroller I want to know the internal page index. Can you help me to find out this. I have attached the bmp file with this please check it.
Re: To find the starting page number and end page number of a pdf file
Re: To find the starting page number and end page number of a pdf file
This is not working Nemaroller.
Re: To find the starting page number and end page number of a pdf file
If you just want it done fast, reference an open-source C# PDF library - use it to load the document and give you a page count.
Try PDFSharp:
http://sourceforge.net/projects/pdfsharp
(beta 4)
I was able to get the page count by using two lines of code:
Code:
PdfDocument theDoc = PdfReader.Open(@"C:\test2.pdf");
Console.WriteLine(theDoc.PageCount);
theDoc.Close();
Re: To find the starting page number and end page number of a pdf file
My friend I don't want to get the page count, I can able to get the page count. I want to get the page number of a pdf file. The page number is displayed at the bottom of the pdf file(not inside the page). I want to get that number.
Re: To find the starting page number and end page number of a pdf file
I dont know if this will help, but I had something to do like this before where I wanted to count the number of pages in a pdf file.
http://www.codeproject.com/useritems...select=1778090
You could check the page with the code, what it does is check through a pdf files using a regular pattern to search for a string at the end of every page.
I dont know if you could use this to help,
Jennifer
Re: To find the starting page number and end page number of a pdf file
vb Code:
using Acrobat;
using AFORMAUTLib;
public static DisplayPDFPageNumber(string FilePath)
{
AcroPDDocClass objPages = new AcroPDDocClass();
objPages.Open(FilePath);
int TotalPDFPages = objPages.GetNumPages();
objPages.Close();
AcroAVDocClass avDoc = new AcroAVDocClass();
avDoc.Open(FilePath, "Title");
IAFormApp formApp = new AFormAppClass();
IFields myFields = (IFields)formApp.Fields;
for (int i = 0; i < TotalPDFPages; i++)
{
string PageNumber = myFields.ExecuteThisJavascript("event.value=this.getPageLabel(" + i + ");");
MessageBox.Show("Page " + i + " : " + PageNumber + "");
}
}
I have found the page number of a pdf file by using this code. This code is working fine.
Re: To find the starting page number and end page number of a pdf file
using Acrobat;
using AFORMAUTLib;
public static DisplayPDFPageNumber(string FilePath)
{
AcroPDDocClass objPages = new AcroPDDocClass();
objPages.Open(FilePath);
int TotalPDFPages = objPages.GetNumPages();
objPages.Close();
AcroAVDocClass avDoc = new AcroAVDocClass();
avDoc.Open(FilePath, "Title");
IAFormApp formApp = new AFormAppClass();
IFields myFields = (IFields)formApp.Fields;
for (int i = 0; i < TotalPDFPages; i++)
{
string PageNumber = myFields.ExecuteThisJavascript("event.value=this.getPageLabel(" + i + ");");
MessageBox.Show("Page " + i + " : " + PageNumber + "");
}
}
This code is working fine.