Get document information

GroupDocs.Signature allows to get document information which includes:

Get document information from file on local disk

The following code snippet demonstrates how to obtain information about document stored on local disk.

using (Signature signature = new Signature("sample.pdf"))
{
    IDocumentInfo documentInfo = signature.GetDocumentInfo();
    Console.WriteLine("Document properties {0}:", Path.GetFileName("sample.pdf"));
    Console.WriteLine(" - format : {0}", documentInfo.FileType.FileFormat);
    Console.WriteLine(" - extension : {0}", documentInfo.FileType.Extension);
    Console.WriteLine(" - size : {0}", documentInfo.Size);
    Console.WriteLine(" - page count : {0}", documentInfo.PageCount);
    foreach(PageInfo pageInfo in documentInfo.Pages)
    {
        Console.WriteLine(" - page-{0} Width {1}, Height {2}", pageInfo.PageNumber, pageInfo.Width, pageInfo.Height);
    }
}

Get document information from a stream

The following code snippet demonstrates how to obtain information about document provided as a stream. 

using (var stream = File.OpenRead("sample.pdf"))
{
    using (Signature signature = new Signature(stream))
    {
        IDocumentInfo documentInfo = signature.GetDocumentInfo();
        Console.WriteLine("Document properties {0}:", Path.GetFileName(filePath));
        Console.WriteLine(" - format : {0}", documentInfo.FileType.FileFormat);
        Console.WriteLine(" - extension : {0}", documentInfo.FileType.Extension);
        Console.WriteLine(" - size : {0}", documentInfo.Size);
        Console.WriteLine(" - page count : {0}", documentInfo.PageCount);
        foreach (PageInfo pageInfo in documentInfo.Pages)
        {
            Console.WriteLine(" - page-{0} Width {1}, Height {2}", pageInfo.PageNumber, pageInfo.Width, pageInfo.Height);
        }
    }
}

More resources

Advanced Usage Topics

To learn more about document eSign features, please refer to the advanced usage section.

GitHub Examples 

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App 

Along with full-featured .NET library we provide simple, but powerful free Apps.
You are welcome to eSign PDF, Word, Excel, PowerPoint documents with free to use online GroupDocs Signature App.