Get document information

Overview

GroupDocs.Signature allows you to retrieve document information, which includes the following:

  • FileType: The type of the document.
  • Size: The size of the document.
  • PageCount: The total number of pages in the document.
  • Page dimensions for each page in a document:

These properties are available through the Pages collection for each page in the document.

Get document information from a file

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

  // The path to the documents directory.
  const filePath = Constants.SAMPLE_PDF;

  const signature = new signatureLib.Signature(filePath);

  const documentInfo = await signature.getDocumentInfo();

  console.log(`Document properties ${path.basename(filePath)}`);
  console.log(` - format : ${documentInfo.getFileType().getFileFormat()}`);
  console.log(` - extension : ${documentInfo.getFileType().getExtension()}`);
  console.log(` - size : ${documentInfo.getSize()}`);
  console.log(` - page count : ${documentInfo.getPageCount()}`);
  console.log(` - Form Fields count : ${documentInfo.getFormFields().size()}`);
  console.log(` - Text signatures count : ${documentInfo.getTextSignatures().size()}`);
  console.log(` - Image signatures count : ${documentInfo.getImageSignatures().size()}`);
  console.log(` - Digital signatures count : ${documentInfo.getDigitalSignatures().size()}`);
  console.log(` - Barcode signatures count : ${documentInfo.getBarcodeSignatures().size()}`);
  console.log(` - QrCode signatures count : ${documentInfo.getQrCodeSignatures().size()}`);
  console.log(` - FormField signatures count : ${documentInfo.getFormFieldSignatures().size()}`);

  for (const pageInfo of documentInfo.getPages().toArray()) {
    console.log(` - page-${pageInfo.getPageNumber()} Width ${pageInfo.getWidth()}, Height ${pageInfo.getHeight()}`);
  }

More resources

GitHub Examples

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

Free Online Apps

Along with the full-featured .NET library, we provide simple but powerful free online apps.

To sign PDF, Word, Excel, PowerPoint, and other documents you can use the online apps from the GroupDocs.Signature App Product Family.