VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.Pdf Namespace / PdfDocument Class
Members Example



In This Topic
    PdfDocument Class
    In This Topic
    Represents a PDF document.
    Object Model
    PdfDocument ClassPdfDocumentAdditionalActions ClassPdfAttachmentCollection ClassPdfBookmarkCollection ClassPdfBookmark ClassPdfDocumentCatalog ClassDecodingSettings ClassPdfDocumentInformation ClassPdfEmbeddedFileSpecificationDictionary ClassPdfEmbeddedFileSpecification ClassEncryptionSystem ClassPdfDeveloperExtensionDictionary ClassPdfDeveloperExtension ClassPdfFontManager ClassFontProgramsControllerBase ClassPdfFormat ClassPdfDocumentInteractiveForm ClassPdfJavaScriptActionDictionary ClassPdfJavaScriptAction ClassPdfMarkInformation ClassPdfAction ClassPdfDestinationBase ClassPdfOptionalContentConfiguration ClassPdfOptionalContentProperties ClassPdfPageCollection ClassPdfPage ClassPdfRenderingSettings ClassPdfStructureTreeRoot ClassPdfDocumentViewerPreferences Class
    Syntax
    'Declaration
     
    Public NotInheritable Class PdfDocument 
    public sealed class PdfDocument 
    public __gc __sealed class PdfDocument 
    public ref class PdfDocument sealed 
    Remarks
    This class adds the following string resources in Vintasoft.Imaging.ImagingEnvironment.ResourceManager
    • "PDFDOCUMENT_GET_FONTS" = "Get document fonts"
    Example
    This example shows how to get information about PDF document.
    Public Shared Sub GetInfoAboutPDF(filename As String)
    	' open PDF document
    	Using document As New Vintasoft.Imaging.Pdf.PdfDocument(filename)
    		' show information about PDF document
    		If document.IsEncrypted Then
    			System.Console.WriteLine(String.Format("Encryption  : {0}", document.EncryptionSystem))
    		End If
    		System.Console.WriteLine(String.Format("Pages count : {0}", document.Pages.Count))
    		System.Console.WriteLine(String.Format("Title       : {0}", document.DocumentInformation.Title))
    		System.Console.WriteLine(String.Format("Author      : {0}", document.DocumentInformation.Author))
    		System.Console.WriteLine(String.Format("Creator     : {0}", document.DocumentInformation.Creator))
    		System.Console.WriteLine(String.Format("Producer    : {0}", document.DocumentInformation.Producer))
    		System.Console.WriteLine(String.Format("Subject     : {0}", document.DocumentInformation.Subject))
    		If document.DocumentInformation.CreationDate <> System.DateTime.MinValue Then
    			System.Console.WriteLine(String.Format("CreationDate: {0}", document.DocumentInformation.CreationDate))
    		End If
    		If document.DocumentInformation.ModifyDate <> System.DateTime.MinValue Then
    			System.Console.WriteLine(String.Format("ModifyDate  : {0}", document.DocumentInformation.ModifyDate))
    		End If
                
    		' for each page of PDF document
    		Dim page As Vintasoft.Imaging.Pdf.Tree.PdfPage
    		For i As Integer = 0 To document.Pages.Count - 1
    			' show information about PDF page
    			System.Console.WriteLine()
    			page = document.Pages(i)
    			System.Console.WriteLine(String.Format("Page {0}:", i))
    			System.Console.WriteLine(String.Format(" - Size (in units)    = {0}", page.Size))
    			System.Console.WriteLine(String.Format(" - Default Resolution = {0}", page.DefaultResolution))
    			Dim images As Vintasoft.Imaging.Pdf.Tree.PdfImageResource() = page.GetImages()
    			If images.Length > 0 Then
    				System.Console.WriteLine(String.Format(" - Contains {0} images.", images.Length))
    			End If
    			If page.Thumbnail IsNot Nothing Then
    				System.Console.WriteLine(" - Contains thumbnail.")
    			End If
    			If page.IsImageOnly Then
    				System.Console.WriteLine(" - Is image only page.")
    			End If
    		Next
    	End Using
    End Sub
    public static void GetInfoAboutPDF(string filename)
    {
        // open PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document = 
            new Vintasoft.Imaging.Pdf.PdfDocument(filename))
        {
            // show information about PDF document
            if (document.IsEncrypted)
                System.Console.WriteLine(string.Format("Encryption  : {0}", document.EncryptionSystem));
            System.Console.WriteLine(string.Format("Pages count : {0}", document.Pages.Count));
            System.Console.WriteLine(string.Format("Title       : {0}", document.DocumentInformation.Title));
            System.Console.WriteLine(string.Format("Author      : {0}", document.DocumentInformation.Author));
            System.Console.WriteLine(string.Format("Creator     : {0}", document.DocumentInformation.Creator));
            System.Console.WriteLine(string.Format("Producer    : {0}", document.DocumentInformation.Producer));
            System.Console.WriteLine(string.Format("Subject     : {0}", document.DocumentInformation.Subject));
            if (document.DocumentInformation.CreationDate != System.DateTime.MinValue)
                System.Console.WriteLine(string.Format("CreationDate: {0}", document.DocumentInformation.CreationDate));
            if (document.DocumentInformation.ModifyDate != System.DateTime.MinValue)
                System.Console.WriteLine(string.Format("ModifyDate  : {0}", document.DocumentInformation.ModifyDate));
                
            // for each page of PDF document
            Vintasoft.Imaging.Pdf.Tree.PdfPage page;
            for (int i = 0; i < document.Pages.Count; i++)
            {
                // show information about PDF page
                System.Console.WriteLine();
                page = document.Pages[i];
                System.Console.WriteLine(string.Format("Page {0}:", i));
                System.Console.WriteLine(string.Format(" - Size (in units)    = {0}", page.Size));
                System.Console.WriteLine(string.Format(" - Default Resolution = {0}", page.DefaultResolution));
                Vintasoft.Imaging.Pdf.Tree.PdfImageResource[] images = page.GetImages();
                if (images.Length > 0)
                    System.Console.WriteLine(string.Format(" - Contains {0} images.", images.Length));
                if (page.Thumbnail != null)
                    System.Console.WriteLine(" - Contains thumbnail.");
                if (page.IsImageOnly)
                    System.Console.WriteLine(" - Is image only page.");
            }
        }
    }
    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.Pdf.PdfDocument

    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also