public PDFDocument(
string fileName
)
public PDFDocument(
java.lang.String fileName
);
public:
PDFDocument(
String^ fileName
)
__init__(self,fileName) # Overloaded constructor
fileName
The name of an existing PDF file.
The PDFDocument class encapsulates a PDF document on disk and allows you to read the pages, objects and images from the document.
fileName must contain the name of an existing and valid PDF file on disk. If the PDF file is encrypted, then use the PDFDocument(string fileName, string password) constructor. You can check whether a PDF is encrypted using the PDFFile.IsEncrypted method.
This method will initialize the members of PDFDocument as follows:
FileName: will be set to fileName.
Password: will be set to null.
IsEncrypted: will be set false since this method cannot open an encrypted PDF file.
Resolution: will be set to the default value used to load PDF files set in the static DefaultResolution property.
Pages: will be initialized to list of PDFDocumentPage objects, one item for each page found in the PDF document. Not all the PDFDocumentPage members will be initialized since the PDFDocument constructor does not read any PDF objects by default. Refer to PDFDocumentPage for more information.
DocumentProperties: will be initialized with PDF document properties or metadata read from the file.
SecurityOptions: will be initialized with PDF document security and encryption options read from the file.
FileType: will be initialized with PDF document file type or version read from the file.
InternalLinks: will be initialized to null. The PDFDocument constructor will not read the PDF document structure by default. Instead, use the ParseDocumentStructure method to read the structure and populate InternalLinks.
Bookmarks: will be initialized to null. The PDFDocument constructor will not read the PDF document structure by default. Instead, use the ParseDocumentStructure method to read the structure and populate Bookmarks.
Use PDFDocument Constructor(Stream) to create a PDF document from a .NET stream.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Controls;
using Leadtools.Pdf;
using Leadtools.Svg;
using Leadtools.WinForms;
public void PDFDocumentExample()
{
string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Leadtools.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:\LEADTOOLS22\Resources\Images";
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document