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.
Stream that were created by CreatePageStream delegate will be disposed automatically once after generation of preview image. If you need to implement custom image preview stream disposing you have to pass additional argument ReleasePageStream to clean up resources.
Generate document preview without signatures on it
publicstaticvoidGetPreview(){// The path to the documents directory.stringfilePath=Constants.SAMPLE_WORD_SIGNED;using(Signaturesignature=newSignature(filePath)){// create preview options objectPreviewOptionspreviewOption=newPreviewOptions(CreatePageStream,ReleasePageStream){PreviewFormat=PreviewOptions.PreviewFormats.JPEG,// set property to hide all known signaturesHideSignatures=true};// generate previewsignature.GeneratePreview(previewOption);}}privatestaticStreamCreatePageStream(PreviewPageDatapageData){stringimageFilePath=Path.Combine("GeneratePreviewFolder","image-"+pageData.PageNumber.ToString()+".jpg");varfolder=Path.GetDirectoryName(imageFilePath);if(!Directory.Exists(folder)){Directory.CreateDirectory(folder);}returnnewSystem.IO.FileStream(imageFilePath,FileMode.Create);}privatestaticvoidReleasePageStream(PreviewPageDatapageData,StreampageStream){pageStream.Dispose();stringimageFilePath=Path.Combine("GeneratePreviewFolder","image-"+pageData.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: