1. How would i know if the type of file is a PDF file?
2. To determine the number of pages of a PDF File.
* please use c#
Thanks in advance ...
Printable View
1. How would i know if the type of file is a PDF file?
2. To determine the number of pages of a PDF File.
* please use c#
Thanks in advance ...
Welcome to the forum.
Can't we use FileStream method for that. I said that based on Java, not at best in C#. Hope it will work.
There is a PDFParser class as well. May be it will help you. I found it on MSDN.
Thanks
The first four charaters of a valid pdf file will should be:
Code:%PDF-
This code is used to get the pdf page number.Code:using Acrobat;
using AFORMAUTLib;
private void DisplayPDFPageNumber(string FilePath)
{
AcroPDDocClass objPages = new AcroPDDocClass();
objPages.Open(FilePath);
long TotalPDFPages = objPages.GetNumPages();
objPages.Close();
AcroAVDocClass avDoc = new AcroAVDocClass();
avDoc.Open(FilePath, "Title");
IAFormApp formApp = new AFormAppClass();
IFields myFields = (IFields)formApp.Fields;
firstPageNumber = myFields.ExecuteThisJavascript("event.value=this.getPageLabel(0);");
long lst = TotalPDFPages - 1;
lastPageNumber = myFields.ExecuteThisJavascript("event.value=this.getPageLabel('" + lst + "');");
avDoc.Close(0);
}
You can get the first page number and the last page number.