LEADTOOLS PDF (Leadtools.Pdf assembly)

PDFFile Class

Show in webframe
Example 





Members 
PDF file features class. * PDF Capability Required.
Object Model
Syntax
[SerializableAttribute()]
public class PDFFile 
'Declaration
 
<SerializableAttribute()>
Public Class PDFFile 
'Usage
 
Dim instance As PDFFile

            

            
[SerializableAttribute()]
public ref class PDFFile 
Remarks

The PDFFile class allows you to perform the following actions on Adobe Document Format (PDF) and Postscript (PS) files:

All the methods described above can set the compatibility level (version) of the created or updated PDF using the CompatibilityLevel property, update its properties using the the DocumentProperties property or set the security and encryption mode using the SecurityOptions property.

To use most of these properties methods, you must construct a PDFFile object with the PDF file and optional password before performing the action.

The C# and VB PDF File Demo shipped with LEADTOOLS contains a wizard style user interface to perform all the action above on existing PDF and PS files.

You can also use the PDFDocument class to parse a PDF file and extract its objects such as text (without invoking OCR), images, hyperlinks, internal links and bookmarks.

*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
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Pdf
Imports Leadtools.WinForms

Public Sub PDFFileExample()
   Dim sourceFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "LEAD.pdf")
   Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "LEAD_14.pdf")

   ' Load the properties of the file
   ShowProperties("Source file", sourceFileName)

   ' Update the properties of the file
   Dim pdfFileObj As New PDFFile(sourceFileName)
   pdfFileObj.DocumentProperties = New PDFDocumentProperties()
   pdfFileObj.DocumentProperties.Author = "Me"
   pdfFileObj.DocumentProperties.Title = "My title"
   pdfFileObj.DocumentProperties.Subject = "My subject"
   pdfFileObj.DocumentProperties.Creator = "My application"
   pdfFileObj.DocumentProperties.Modified = DateTime.Now
   pdfFileObj.SetDocumentProperties(destFileName)

   ' Show the properties of the new file
   ShowProperties("Destination file", destFileName)
End Sub

Private Shared Sub ShowProperties(ByVal message As String, ByVal fileName As String)
   Console.WriteLine(message)

   ' Get the properties of the file
   Dim pdfFileObj As New PDFFile(fileName)
   pdfFileObj.Load()

   Dim props As PDFDocumentProperties = pdfFileObj.DocumentProperties

   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)
   Console.WriteLine("----------:")
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Pdf;
using Leadtools.WinForms;

public void PDFFileExample()
{
   string sourceFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD.pdf");
   string destFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD_14.pdf");

   // Load the properties of the file
   ShowProperties("Source file", sourceFileName);

   // Update the properties of the file
   PDFFile file = new PDFFile(sourceFileName);
   file.DocumentProperties = new PDFDocumentProperties();
   file.DocumentProperties.Author = "Me";
   file.DocumentProperties.Title = "My title";
   file.DocumentProperties.Subject = "My subject";
   file.DocumentProperties.Creator = "My application";
   file.DocumentProperties.Modified = DateTime.Now;
   file.SetDocumentProperties(destFileName);

   // Show the properties of the new file
   ShowProperties("Destination file", destFileName);
}

private static void ShowProperties(string message, string fileName)
{
   Console.WriteLine(message);

   // Get the properties of the file
   PDFFile file = new PDFFile(fileName);
   file.Load();

   PDFDocumentProperties props = file.DocumentProperties;

   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);
   Console.WriteLine("----------:");
}

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

Target Platforms

See Also

Reference

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

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.