PreviewOptions class

PreviewOptions class

Provides options to set requirements and stream delegates for preview generation.

Use this class with Redactor.generate_preview to render document pages to image streams.

The PreviewOptions type exposes the following members:

Constructors

Constructor Description
init Initializes a new PreviewOptions instance, causing the output stream to be closed.
init Initializes a new PreviewOptions instance, causing the output stream to be returned to the client for further use.

Properties

Property Description
create_page_stream The page stream creation delegate used to obtain a writable io.RawIOBase stream for each rendered page.
height The page preview height.
page_numbers The page numbers to generate preview.
preview_format The preview image format.
release_page_stream The page preview completion delegate.
width The page preview width.

Example

from groupdocs.redaction import Redactor
from groupdocs.redaction.options import PreviewOptions

def get_document_page_preview():
    def create_page_stream(page_number):
        return open(f"preview_page_{page_number}.png", "wb")

    with Redactor("./multipage_sample.docx") as redactor:
        options = PreviewOptions(create_page_stream)
        options.width = 480
        options.height = 640
        options.page_numbers = [1]
        options.preview_format = PreviewOptions.PreviewFormats.PNG
        redactor.generate_preview(options)
        print("The preview of page 1 is saved to preview_page_1.png")

Guides

Task guides that use PreviewOptions:

See Also