Get document information
GroupDocs.Signature allows to get document information which includes:
- FileType
- Size
- PageCount
- Pages dimensions - Height and Width for each page in a document Pages collection.
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);
}
}
}
GroupDocs.Signature also provides an abilityto obtain extended information of document form fields and existing signatures.
To learn more about please refer to the following guides: Obtain document form fields and signatures information
To learn more about please refer to the following guides: Obtain document form fields and signatures information
Advanced Usage Topics
To learn more about document eSign features, please refer to the advanced usage section.
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
- GroupDocs.Signature for .NET examples, plugins, and showcase
- GroupDocs.Signature for Java examples, plugins, and showcase
- Document Signature for .NET MVC UI Example
- Document Signature for .NET App WebForms UI Example
- Document Signature for Java App Dropwizard UI Example
- Document Signature for Java Spring UI Example
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.