LEADTOOLS PDF (Leadtools.Pdf assembly)
LEAD Technologies, Inc

GetPageCount Method

Example 





Gets the number of pages in this PDFFile object.
Syntax
public int GetPageCount()
'Declaration
 
Public Function GetPageCount() As Integer
'Usage
 
Dim instance As PDFFile
Dim value As Integer
 
value = instance.GetPageCount()
public int GetPageCount()
 function Leadtools.Pdf.PDFFile.GetPageCount()
public:
int GetPageCount(); 

Return Value

A System.Int32 that represents the number of pages in this PDFFile object.
Remarks

This method will obtain the number of pages in the PDF file set in FileName. Since obtaining the number of pages might require decrypting a secured file, the value of the password set in Password will be used if the file is encrypted.

To get the size of each page in a PDF file, use the Load method which populates the Pages collection with an PDFFilePage for each page.

This method is faster than calling Load and using Pages.Count since it does not parse the page sizes not load the document properties.

Example
 
Public Sub PDFFilePageCountExample()
      Dim pdfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "LEAD.pdf")

      ' Show the number of pages
      Dim pdfFileObj As New PDFFile(pdfFileName)
      Dim pageCount As Integer = pdfFileObj.GetPageCount()
      Console.WriteLine("File has {0} pages", pageCount)
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void PDFFilePageCountExample()
   {
      string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD.pdf");

      // Show the number of pages
      PDFFile file = new PDFFile(pdfFileName);
      int pageCount = file.GetPageCount();
      Console.WriteLine("File has {0} pages", pageCount);
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

PDFFile Class
PDFFile Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.