PreviewOptions Class
Provides options to sets requirements and stream delegates for preview generation.
Inheritance Hierarchy
SystemObject
  GroupDocs.Redaction.OptionsPreviewOptions

Namespace: GroupDocs.Redaction.Options
Assembly: GroupDocs.Redaction (in GroupDocs.Redaction.dll) Version: 20.9
Syntax
public class PreviewOptions

The PreviewOptions type exposes the following members.

Constructors
  NameDescription
Public methodPreviewOptions(CreatePageStream)
Initializes a new instance of PreviewOptions class, causing the output stream to be closed.
Public methodPreviewOptions(CreatePageStream, ReleasePageStream)
Initializes a new instance of PreviewOptions class, causing the output stream to be returned to the client for further use.
Properties
  NameDescription
Public propertyCreatePageStream
Gets or sets an instance of page stream creation delegate.
Public propertyHeight
Gets or sets page preview height.
Public propertyPageNumbers
Gets or sets an array of page numbers to generate preview.
Public propertyPreviewFormat
Gets or sets preview image format.
Public propertyReleasePageStream
Gets or sets an instance of page preview completion delegate.
Public propertyWidth
Gets or sets page preview width.
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Examples

The following example demonstrates how get a document preview using PreviewOptions and CreatePageStream delegate.

C#
CreatePageStream createDelegate = delegate (int pageNumber)
{
    var pagePath = System.IO.Path.Combine(@"C:\Temp", string.Format("page_{0}.png", pageNumber));
    return System.IO.File.Create(pagePath);
};
var previewOptions = new PreviewOptions(createDelegate);
previewOptions.PreviewFormat = PreviewOptions.PreviewFormats.PNG;
previewOptions.Height = 640;
previewOptions.Width = 480;
previewOptions.PageNumbers = new int[] { 1 };
using (var redactor = new Redactor("C:\Temp\SourceFile.pdf"))
{
    redactor.GeneratePreview(previewOptions);
}

The following example demonstrates how get a document preview using PreviewOptions and both delegates.

C#
CreatePageStream createDelegate = delegate (int pageNumber)
{
    var pagePath = System.IO.Path.Combine(@"C:\Temp", string.Format("page_{0}.png", pageNumber));
    return System.IO.File.Create(pagePath);
};
ReleasePageStream releaseDelegate = delegate (int pageNumber, System.IO.Stream pageStream)
{
    // do anything with Stream, containing page preview
    pageStream.Close();
};
var previewOptions = new PreviewOptions(createDelegate, releaseDelegate);
previewOptions.PreviewFormat = PreviewOptions.PreviewFormats.PNG;
previewOptions.Height = 640;
previewOptions.Width = 480;
previewOptions.PageNumbers = new int[] { 1 };
using (var redactor = new Redactor("C:\Temp\SourceFile.pdf"))
{
    redactor.GeneratePreview(previewOptions);
}
See Also