Generating document preview - advanced

GroupDocs.Signature provides PreviewOptions class to specify different options to manage document pages preview generation process. Since 19.12 version there’s ability to hide signatures from documents. Using property HideSignature of PreviewOptions will allow to hide signatures from document preview.

Here are the steps to generate document preview with GroupDocs.Signature with hidden signatures:

  • Create new instance of Signature class and pass source document path as a constructor parameter.
  • Instantiate the PreviewOptions object with:
  • delegate for each page stream creation (see event handler CreatePageStream); 
  • property HideSignature set to true;
  • image preview format - PNG / JPG / BMP;
  • page numbers to process;
  • custom size of preview images (if needed). 
  • Call GeneratePreview method of Signature class instance and pass PreviewOptions to it.

Generate document preview without signatures on it

public static void GetPreview()
    // The path to the documents directory.
    string filePath = Constants.SAMPLE_WORD_SIGNED;
    using (Signature signature = new Signature(filePath))
        // create preview options object
        PreviewOptions previewOption = new PreviewOptions(CreatePageStream, ReleasePageStream)
            PreviewFormat = PreviewOptions.PreviewFormats.JPEG,
            // set property to hide all known signatures
            HideSignatures = true
        // generate preview

private static Stream CreatePageStream(int pageNumber)
    string imageFilePath = Path.Combine("GeneratePreviewFolder", "image-" + pageNumber.ToString() + ".jpg");
    var folder = Path.GetDirectoryName(imageFilePath);
    return new System.IO.FileStream(imageFilePath, FileMode.Create);

private static void ReleasePageStream(int pageNumber, Stream pageStream)
     string imageFilePath = Path.Combine("GeneratePreviewFolder", "image-" + pageNumber.ToString() + ".jpg");
     Console.WriteLine("Image file {0} is ready for preview", imageFilePath);

More resources

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.