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

Pages Property (PDFFile)

Example 





Gets the collection of pages in this PDF file.
Syntax
public IList<PDFFilePage> Pages {get;}
'Declaration
 
Public ReadOnly Property Pages As IList(Of PDFFilePage)
'Usage
 
Dim instance As PDFFile
Dim value As IList(Of PDFFilePage)
 
value = instance.Pages
 get_Pages(); 
public:
property IList<PDFFilePage>^ Pages {
   IList<PDFFilePage>^ get();
}

Property Value

A collection of PDFFilePage objects that contain an item for each page in the PDF file associated with this PDFFile object. Default value is null (Nothing in Visual Basic).
Remarks

The value of Pages will be populated with the pages collection after you set a valid PDF file name (and optional password) in this PDFFile object and call the Load method.

Each item in the collection corresponds to a page in the PDF file. So item at index 0 is the properties of page 1, item at index 1 is the properties of page 2 and so on.

The PDFFilePage structure contains the width and height of the page in PDF units which is read from the PDF file directly. PDF units are in 1/72 of an inch units, so a page size of 612 by 792 corresponds to 8.5 by 11 inches (612/72 by 792/72). For more information, refer to PDF Coordinate System.

You can get the the total number of pages in a PDF file with two ways:

The values of the PDFFilePage structure are used as read only by the PDFFile object. The toolkit will only return objects of type PDFFilePage from the PDF document and does not use them anymore.

The PDFFilePage does not contain any information about a PDF page other than its size. To get the objects, bookmarks, images, links of a page, use the PDFDocument class and its collection of PDFDocumentPage items.

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

      ' Load the file
      Dim pdfFileObj As New PDFFile(pdfFileName)
      pdfFileObj.Load()

      ' Show the pages
      Console.WriteLine("File has {0} pages", pdfFileObj.Pages.Count)
      For Each page As PDFFilePage In pdfFileObj.Pages
         Console.WriteLine("Page {0} size is {1} by {2} units", page.PageNumber, page.Width, page.Height)
      Next
   End Sub

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

      // Load the file
      PDFFile file = new PDFFile(pdfFileName);
      file.Load();

      // Show the pages
      Console.WriteLine("File has {0} pages", file.Pages.Count);
      foreach(PDFFilePage page in file.Pages)
      {
         Console.WriteLine("Page {0} size is {1} by {2} units", page.PageNumber, page.Width, page.Height);
      }
   }

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
PDF Coordinate System

 

 


Products | Support | Contact Us | Copyright Notices

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