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

PDFDocument Class

Example 





Members 
Encapsulates a PDF document and allows reading the PDF pages, objects and images. * PDF Capability Required.
Object Model
PDFDocument ClassPDFDocumentProperties ClassPDFDocumentPageCollection ClassPDFDocumentPage Class
Syntax
public class PDFDocument 
'Declaration
 
Public Class PDFDocument 
'Usage
 
Dim instance As PDFDocument
public sealed class PDFDocument 
function Leadtools.Pdf.PDFDocument()
public ref class PDFDocument 
Remarks

The PDFDocument class encapsulates a PDF document on disk and allows you to read the pages, objects and images from the document. The PDFDocument contains the following functionality:

To create a PDFDocument from a PDF file on disk, use the PDFDocument(string fileName) constructor passing the file name. If the document is encrypted with a password, then use the the PDFDocument(string fileName, string password) constructor which will automatically decrypt the document and read it. To find out if a document is encrypted and requires a password, use the static (Shared in Visual Basic) PDFFile.IsEncrypted method.

The PDFDocument class implements the System.IDisposable interface, it is recommended that you follow the standard .NET dispose pattern when using the PDFDocument class. For more information, refer to the System.IDisposable interface documentation in MSDN.

* NOTE: This class is only included as part of our Advanced PDF Plugin. If you receive a PDF Capability Required error, please check that your license supports this plugin before using these classes in an unlocked application.

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

      ' Create a PDF document for file
      Using document As New PDFDocument(pdfFileName)

         ' Show the file type and properties
         Console.WriteLine("File type is : {0}", document.FileType)
         Console.WriteLine("Contains : {0} pages", document.Pages.Count)
         Console.WriteLine("----------:")
         For Each page As PDFDocumentPage In document.Pages
            Console.WriteLine("Page: {0}, size: {1} by {2} ({3} by {4} inches)", page.PageNumber, page.Width, page.Height, page.WidthInches, page.HeightInches)
         Next

         Dim props As PDFDocumentProperties = document.DocumentProperties
         Console.WriteLine("Properties:")
         Console.WriteLine("----------:")
         Console.WriteLine("Title: {0}", props.Title)
         Console.WriteLine("Author: {0}", props.Author)
         Console.WriteLine("Subject: {0}", props.Subject)
         Console.WriteLine("Keywords: {0}", props.Keywords)
         Console.WriteLine("Creator: {0}", props.Creator)
         Console.WriteLine("Producer: {0}", props.Producer)
         Console.WriteLine("Created: {0}", props.Created)
         Console.WriteLine("Modified: {0}", props.Modified)
      End Using
   End Sub

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

      // Create a PDF document for file
      using(PDFDocument document = new PDFDocument(pdfFileName))
      {

         // Show the file type and properties
         Console.WriteLine("File type is : {0}", document.FileType);
         Console.WriteLine("Contains : {0} pages", document.Pages.Count);
         Console.WriteLine("----------:");
         foreach(PDFDocumentPage page in document.Pages)
         {
            Console.WriteLine("Page: {0}, size: {1} by {2} ({3} by {4} inches)", page.PageNumber, page.Width, page.Height, page.WidthInches, page.HeightInches);
         }

         PDFDocumentProperties props = document.DocumentProperties;
         Console.WriteLine("Properties:");
         Console.WriteLine("----------:");
         Console.WriteLine("Title: {0}", props.Title);
         Console.WriteLine("Author: {0}", props.Author);
         Console.WriteLine("Subject: {0}", props.Subject);
         Console.WriteLine("Keywords: {0}", props.Keywords);
         Console.WriteLine("Creator: {0}", props.Creator);
         Console.WriteLine("Producer: {0}", props.Producer);
         Console.WriteLine("Created: {0}", props.Created);
         Console.WriteLine("Modified: {0}", props.Modified);
      }
   }

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

PDFDocument Members
Leadtools.Pdf Namespace
PDFFile Class
PDFDocumentPage Class
PDFObject Structure
Programming with LEADTOOLS PDF

 

 


Products | Support | Contact Us | Copyright Notices

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