Aspose::Words::Saving::HtmlSaveOptions class

HtmlSaveOptions class

Can be used to specify additional options when saving a document into the Html, Mhtml, Epub, Azw3 or Mobi format. To learn more, visit the Specify Save Options documentation article.

class HtmlSaveOptions : public Aspose::Words::Saving::SaveOptions

Methods

MethodDescription
static CreateSaveOptions(Aspose::Words::SaveFormat)Creates a save options object of a class suitable for the specified save format.
static CreateSaveOptions(const System::String&)Creates a save options object of a class suitable for the file extension specified in the given file name.
get_AllowEmbeddingPostScriptFonts() constGets or sets a boolean value indicating whether to allow embedding fonts with PostScript outlines when embedding TrueType fonts in a document upon it is saved. The default value is false.
get_AllowNegativeIndent() constSpecifies whether negative left and right indents of paragraphs are normalized when saving to HTML, MHTML or EPUB. Default value is false.
get_CssClassNamePrefix() constSpecifies a prefix which is added to all CSS class names. Default value is an empty string and generated CSS class names have no common prefix.
get_CssSavingCallback() constAllows to control how CSS styles are saved when a document is saved to HTML, MHTML or EPUB.
get_CssStyleSheetFileName() constSpecifies the path and the name of the Cascading Style Sheet (CSS) file written when a document is exported to HTML. Default is an empty string.
get_CssStyleSheetType() constSpecifies how CSS (Cascading Style Sheet) styles are exported to HTML, MHTML or EPUB. Default value is Inline for HTML/MHTML and External for EPUB.
get_CustomTimeZoneInfo() constGets or sets custom local time zone used for date/time fields.
get_DefaultTemplate() constGets or sets path to default template (including filename). Default value for this property is empty string.
get_Dml3DEffectsRenderingMode() constGets a value determining how 3D effects are rendered.
virtual get_DmlEffectsRenderingMode()Gets or sets a value determining how DrawingML effects are rendered.
get_DmlRenderingMode() constGets or sets a value determining how DrawingML shapes are rendered.
get_DocumentPartSavingCallback() constAllows to control how document parts are saved when a document is saved to HTML or EPUB.
get_DocumentSplitCriteria() constSpecifies how the document should be split when saving to Html, Epub or Azw3 format. Default is None for HTML and HeadingParagraph for EPUB and AZW3.
get_DocumentSplitHeadingLevel() constSpecifies the maximum level of headings at which to split the document. Default value is %2.
get_Encoding() constSpecifies the encoding to use when exporting to HTML, MHTML or EPUB. Default value is new UTF8Encoding(false) (UTF-8 without BOM).
get_ExportCidUrlsForMhtmlResources() constSpecifies whether to use CID (Content-ID) URLs to reference resources (images, fonts, CSS) included in MHTML documents. Default value is false.
get_ExportDocumentProperties() constSpecifies whether to export built-in and custom document properties to HTML, MHTML or EPUB. Default value is false.
get_ExportDropDownFormFieldAsText() constControls how drop-down form fields are saved to HTML or MHTML. Default value is false.
get_ExportFontResources() constSpecifies whether font resources should be exported to HTML, MHTML or EPUB. Default is false.
get_ExportFontsAsBase64() constSpecifies whether fonts resources should be embedded to HTML in Base64 encoding. Default is false.
get_ExportGeneratorName() constWhen true, causes the name and version of Aspose.Words to be embedded into produced files. Default value is true.
get_ExportHeadersFootersMode() constSpecifies how headers and footers are output to HTML, MHTML or EPUB. Default value is PerSection for HTML/MHTML and None for EPUB.
get_ExportImagesAsBase64() constSpecifies whether images are saved in Base64 format to the output HTML, MHTML or EPUB. Default is false.
get_ExportLanguageInformation() constSpecifies whether language information is exported to HTML, MHTML or EPUB. Default is false.
get_ExportListLabels() constControls how list labels are output to HTML, MHTML or EPUB. Default value is Auto.
get_ExportOriginalUrlForLinkedImages() constSpecifies whether original URL should be used as the URL of the linked images. Default value is false.
get_ExportPageMargins() constSpecifies whether page margins is exported to HTML, MHTML or EPUB. Default is false.
get_ExportPageSetup() constSpecifies whether page setup is exported to HTML, MHTML or EPUB. Default is false.
get_ExportRelativeFontSize() constSpecifies whether font sizes should be output in relative units when saving to HTML, MHTML or EPUB. Default is false.
get_ExportRoundtripInformation() constSpecifies whether to write the roundtrip information when saving to HTML, MHTML or EPUB. Default value is true for HTML and false for MHTML and EPUB.
get_ExportShapesAsSvg() constControls whether Shape nodes are converted to SVG images when saving to HTML, MHTML, EPUB or AZW3. Default value is false.
get_ExportTextInputFormFieldAsText() constControls how text input form fields are saved to HTML or MHTML. Default value is false.
get_ExportTocPageNumbers() constSpecifies whether to write page numbers to table of contents when saving HTML, MHTML and EPUB. Default value is false.
get_ExportXhtmlTransitional() constSpecifies whether to write the DOCTYPE declaration when saving to HTML or MHTML. When true, writes a DOCTYPE declaration in the document prior to the root element. Default value is false. When saving to EPUB or HTML5 (Html5) the DOCTYPE declaration is always written.
get_FontResourcesSubsettingSizeThreshold() constControls which font resources need subsetting when saving to HTML, MHTML or EPUB. Default is %0.
get_FontSavingCallback() constAllows to control how fonts are saved when a document is saved to HTML, MHTML or EPUB.
get_FontsFolder() constSpecifies the physical folder where fonts are saved when exporting a document to HTML. Default is an empty string.
get_FontsFolderAlias() constSpecifies the name of the folder used to construct font URIs written into an HTML document. Default is an empty string.
get_HtmlVersion() constSpecifies version of HTML standard that should be used when saving the document to HTML or MHTML. Default value is Xhtml.
get_ImageResolution() constSpecifies the output resolution for images when exporting to HTML, MHTML or EPUB. Default is %96 dpi.
get_ImageSavingCallback() constAllows to control how images are saved when a document is saved to HTML, MHTML or EPUB.
get_ImagesFolder() constSpecifies the physical folder where images are saved when exporting a document to HTML format. Default is an empty string.
get_ImagesFolderAlias() constSpecifies the name of the folder used to construct image URIs written into an HTML document. Default is an empty string.
get_ImlRenderingMode() constGets or sets a value determining how ink (InkML) objects are rendered.
get_MemoryOptimization() constGets or sets value determining if memory optimization should be performed before saving the document. Default value for this property is false.
get_MetafileFormat() constSpecifies in what format metafiles are saved when exporting to HTML, MHTML, or EPUB. Default value is Png, meaning that metafiles are rendered to raster PNG images.
get_NavigationMapLevel() constSpecifies the maximum level of headings populated to the navigation map when exporting to EPUB, MOBI, or AZW3 formats. Default value is %3.
get_OfficeMathOutputMode() constControls how OfficeMath objects are exported to HTML, MHTML or EPUB. Default value is Image.
get_PrettyFormat() constWhen true, pretty formats output where applicable. Default value is false.
get_ProgressCallback() constCalled during saving a document and accepts data about saving progress.
get_ReplaceBackslashWithYenSign() constSpecifies whether backslash characters should be replaced with yen signs. Default value is false.
get_ResolveFontNames() constSpecifies whether font family names used in the document are resolved and substituted according to FontSettings when being written into HTML-based formats.
get_ResourceFolder() constSpecifies a physical folder where all resources like images, fonts, and external CSS are saved when a document is exported to HTML. Default is an empty string.
get_ResourceFolderAlias() constSpecifies the name of the folder used to construct URIs of all resources written into an HTML document. Default is an empty string.
get_SaveFormat() overrideSpecifies the format in which the document will be saved if this save options object is used. Can be Html, Mhtml, Epub, Azw3 or Mobi.
get_ScaleImageToShapeSize() constSpecifies whether images are scaled by Aspose.Words to the bounding shape size when exporting to HTML, MHTML or EPUB. Default value is true.
get_TableWidthOutputMode() constControls how table, row and cell widths are exported to HTML, MHTML or EPUB. Default value is All.
get_TempFolder() constSpecifies the folder for temporary files used when saving to a DOC or DOCX file. By default this property is null and no temporary files are used.
get_UpdateCreatedTimeProperty() constGets a value determining whether the CreatedTime property is updated before saving. Default value is false;.
get_UpdateFields() constGets or sets a value determining if fields of certain types should be updated before saving the document to a fixed page format. Default value for this property is true.
get_UpdateLastPrintedProperty() constGets or sets a value determining whether the LastPrinted property is updated before saving.
get_UpdateLastSavedTimeProperty() constGets or sets a value determining whether the LastSavedTime property is updated before saving.
get_UseAntiAliasing() constGets or sets a value determining whether or not to use anti-aliasing for rendering.
get_UseHighQualityRendering() constGets or sets a value determining whether or not to use high quality (i.e. slow) rendering algorithms.
GetType() const override
HtmlSaveOptions()Initializes a new instance of this class that can be used to save a document in the Html format.
HtmlSaveOptions(Aspose::Words::SaveFormat)Initializes a new instance of this class that can be used to save a document in the Html, Mhtml, Epub, Azw3 or Mobi format.
Is(const System::TypeInfo&) const override
set_AllowEmbeddingPostScriptFonts(bool)Setter for Aspose::Words::Saving::SaveOptions::get_AllowEmbeddingPostScriptFonts.
set_AllowNegativeIndent(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_AllowNegativeIndent.
set_CssClassNamePrefix(const System::String&)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_CssClassNamePrefix.
set_CssSavingCallback(const System::SharedPtr<Aspose::Words::Saving::ICssSavingCallback>&)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_CssSavingCallback.
set_CssStyleSheetFileName(const System::String&)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_CssStyleSheetFileName.
set_CssStyleSheetType(Aspose::Words::Saving::CssStyleSheetType)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_CssStyleSheetType.
set_CustomTimeZoneInfo(const System::SharedPtr<System::TimeZoneInfo>&)Setter for Aspose::Words::Saving::SaveOptions::get_CustomTimeZoneInfo.
set_DefaultTemplate(const System::String&)Setter for Aspose::Words::Saving::SaveOptions::get_DefaultTemplate.
set_Dml3DEffectsRenderingMode(Aspose::Words::Saving::Dml3DEffectsRenderingMode)Sets a value determining how 3D effects are rendered.
virtual set_DmlEffectsRenderingMode(Aspose::Words::Saving::DmlEffectsRenderingMode)Setter for Aspose::Words::Saving::SaveOptions::get_DmlEffectsRenderingMode.
set_DmlRenderingMode(Aspose::Words::Saving::DmlRenderingMode)Setter for Aspose::Words::Saving::SaveOptions::get_DmlRenderingMode.
set_DocumentPartSavingCallback(const System::SharedPtr<Aspose::Words::Saving::IDocumentPartSavingCallback>&)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_DocumentPartSavingCallback.
set_DocumentSplitCriteria(Aspose::Words::Saving::DocumentSplitCriteria)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_DocumentSplitCriteria.
set_DocumentSplitHeadingLevel(int32_t)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_DocumentSplitHeadingLevel.
set_Encoding(const System::SharedPtr<System::Text::Encoding>&)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_Encoding.
set_ExportCidUrlsForMhtmlResources(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportCidUrlsForMhtmlResources.
set_ExportDocumentProperties(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportDocumentProperties.
set_ExportDropDownFormFieldAsText(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportDropDownFormFieldAsText.
set_ExportFontResources(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportFontResources.
set_ExportFontsAsBase64(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportFontsAsBase64.
set_ExportGeneratorName(bool)Setter for Aspose::Words::Saving::SaveOptions::get_ExportGeneratorName.
set_ExportHeadersFootersMode(Aspose::Words::Saving::ExportHeadersFootersMode)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportHeadersFootersMode.
set_ExportImagesAsBase64(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportImagesAsBase64.
set_ExportLanguageInformation(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportLanguageInformation.
set_ExportListLabels(Aspose::Words::Saving::ExportListLabels)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportListLabels.
set_ExportOriginalUrlForLinkedImages(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportOriginalUrlForLinkedImages.
set_ExportPageMargins(bool)Specifies whether page margins is exported to HTML, MHTML or EPUB. Default is false.
set_ExportPageSetup(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportPageSetup.
set_ExportRelativeFontSize(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportRelativeFontSize.
set_ExportRoundtripInformation(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportRoundtripInformation.
set_ExportShapesAsSvg(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportShapesAsSvg.
set_ExportTextInputFormFieldAsText(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportTextInputFormFieldAsText.
set_ExportTocPageNumbers(bool)Specifies whether to write page numbers to table of contents when saving HTML, MHTML and EPUB. Default value is false.
set_ExportXhtmlTransitional(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ExportXhtmlTransitional.
set_FontResourcesSubsettingSizeThreshold(int32_t)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_FontResourcesSubsettingSizeThreshold.
set_FontSavingCallback(const System::SharedPtr<Aspose::Words::Saving::IFontSavingCallback>&)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_FontSavingCallback.
set_FontsFolder(const System::String&)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_FontsFolder.
set_FontsFolderAlias(const System::String&)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_FontsFolderAlias.
set_HtmlVersion(Aspose::Words::Saving::HtmlVersion)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_HtmlVersion.
set_ImageResolution(int32_t)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ImageResolution.
set_ImageSavingCallback(const System::SharedPtr<Aspose::Words::Saving::IImageSavingCallback>&)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ImageSavingCallback.
set_ImagesFolder(const System::String&)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ImagesFolder.
set_ImagesFolderAlias(const System::String&)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ImagesFolderAlias.
set_ImlRenderingMode(Aspose::Words::Saving::ImlRenderingMode)Setter for Aspose::Words::Saving::SaveOptions::get_ImlRenderingMode.
set_MemoryOptimization(bool)Setter for Aspose::Words::Saving::SaveOptions::get_MemoryOptimization.
set_MetafileFormat(Aspose::Words::Saving::HtmlMetafileFormat)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_MetafileFormat.
set_NavigationMapLevel(int32_t)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_NavigationMapLevel.
set_OfficeMathOutputMode(Aspose::Words::Saving::HtmlOfficeMathOutputMode)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_OfficeMathOutputMode.
set_PrettyFormat(bool)Setter for Aspose::Words::Saving::SaveOptions::get_PrettyFormat.
set_ProgressCallback(const System::SharedPtr<Aspose::Words::Saving::IDocumentSavingCallback>&)Setter for Aspose::Words::Saving::SaveOptions::get_ProgressCallback.
set_ReplaceBackslashWithYenSign(bool)Specifies whether backslash characters should be replaced with yen signs. Default value is false.
set_ResolveFontNames(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ResolveFontNames.
set_ResourceFolder(const System::String&)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ResourceFolder.
set_ResourceFolderAlias(const System::String&)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ResourceFolderAlias.
set_SaveFormat(Aspose::Words::SaveFormat) overrideSetter for Aspose::Words::Saving::HtmlSaveOptions::get_SaveFormat.
set_ScaleImageToShapeSize(bool)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_ScaleImageToShapeSize.
set_TableWidthOutputMode(Aspose::Words::Saving::HtmlElementSizeOutputMode)Setter for Aspose::Words::Saving::HtmlSaveOptions::get_TableWidthOutputMode.
set_TempFolder(const System::String&)Setter for Aspose::Words::Saving::SaveOptions::get_TempFolder.
set_UpdateCreatedTimeProperty(bool)Sets a value determining whether the CreatedTime property is updated before saving. Default value is false;.
set_UpdateFields(bool)Setter for Aspose::Words::Saving::SaveOptions::get_UpdateFields.
set_UpdateLastPrintedProperty(bool)Setter for Aspose::Words::Saving::SaveOptions::get_UpdateLastPrintedProperty.
set_UpdateLastSavedTimeProperty(bool)Setter for Aspose::Words::Saving::SaveOptions::get_UpdateLastSavedTimeProperty.
set_UseAntiAliasing(bool)Setter for Aspose::Words::Saving::SaveOptions::get_UseAntiAliasing.
set_UseHighQualityRendering(bool)Setter for Aspose::Words::Saving::SaveOptions::get_UseHighQualityRendering.
static Type()

Examples

Shows how to use a specific encoding when saving a document to .epub.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");

// Use a SaveOptions object to specify the encoding for a document that we will save.
auto saveOptions = MakeObject<HtmlSaveOptions>();
saveOptions->set_SaveFormat(SaveFormat::Epub);
saveOptions->set_Encoding(System::Text::Encoding::get_UTF8());

// By default, an output .epub document will have all its contents in one HTML part.
// A split criterion allows us to segment the document into several HTML parts.
// We will set the criteria to split the document into heading paragraphs.
// This is useful for readers who cannot read HTML files more significant than a specific size.
saveOptions->set_DocumentSplitCriteria(DocumentSplitCriteria::HeadingParagraph);

// Specify that we want to export document properties.
saveOptions->set_ExportDocumentProperties(true);

doc->Save(ArtifactsDir + u"HtmlSaveOptions.Doc2EpubSaveOptions.epub", saveOptions);

Shows how to specify the folder for storing linked images after saving to .html.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");

String imagesDir = System::IO::Path::Combine(ArtifactsDir, u"SaveHtmlWithOptions");

if (System::IO::Directory::Exists(imagesDir))
{
    System::IO::Directory::Delete(imagesDir, true);
}

System::IO::Directory::CreateDirectory_(imagesDir);

// Set an option to export form fields as plain text instead of HTML input elements.
auto options = MakeObject<HtmlSaveOptions>(SaveFormat::Html);
options->set_ExportTextInputFormFieldAsText(true);
options->set_ImagesFolder(imagesDir);

doc->Save(ArtifactsDir + u"HtmlSaveOptions.SaveHtmlWithOptions.html", options);

Shows how to split a document into parts and save them.

void DocumentPartsFileNames()
{
    auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
    String outFileName = u"SavingCallback.DocumentPartsFileNames.html";

    // Create an "HtmlFixedSaveOptions" object, which we can pass to the document's "Save" method
    // to modify how we convert the document to HTML.
    auto options = MakeObject<HtmlSaveOptions>();

    // If we save the document normally, there will be one output HTML
    // document with all the source document's contents.
    // Set the "DocumentSplitCriteria" property to "DocumentSplitCriteria.SectionBreak" to
    // save our document to multiple HTML files: one for each section.
    options->set_DocumentSplitCriteria(DocumentSplitCriteria::SectionBreak);

    // Assign a custom callback to the "DocumentPartSavingCallback" property to alter the document part saving logic.
    options->set_DocumentPartSavingCallback(MakeObject<ExSavingCallback::SavedDocumentPartRename>(outFileName, options->get_DocumentSplitCriteria()));

    // If we convert a document that contains images into html, we will end up with one html file which links to several images.
    // Each image will be in the form of a file in the local file system.
    // There is also a callback that can customize the name and file system location of each image.
    options->set_ImageSavingCallback(MakeObject<ExSavingCallback::SavedImageRename>(outFileName));

    doc->Save(ArtifactsDir + outFileName, options);
}

class SavedDocumentPartRename : public IDocumentPartSavingCallback
{
public:
    SavedDocumentPartRename(String outFileName, DocumentSplitCriteria documentSplitCriteria)
        : mCount(0), mDocumentSplitCriteria(((Aspose::Words::Saving::DocumentSplitCriteria)0))
    {
        mOutFileName = outFileName;
        mDocumentSplitCriteria = documentSplitCriteria;
    }

private:
    int mCount;
    String mOutFileName;
    DocumentSplitCriteria mDocumentSplitCriteria;

    void DocumentPartSaving(SharedPtr<DocumentPartSavingArgs> args) override
    {
        // We can access the entire source document via the "Document" property.
        ASSERT_TRUE(args->get_Document()->get_OriginalFileName().EndsWith(u"Rendering.docx"));

        String partType = String::Empty;

        switch (mDocumentSplitCriteria)
        {
        case DocumentSplitCriteria::PageBreak:
            partType = u"Page";
            break;

        case DocumentSplitCriteria::ColumnBreak:
            partType = u"Column";
            break;

        case DocumentSplitCriteria::SectionBreak:
            partType = u"Section";
            break;

        case DocumentSplitCriteria::HeadingParagraph:
            partType = u"Paragraph from heading";
            break;

        default:
            break;
        }

        String partFileName = String::Format(u"{0} part {1}, of type {2}{3}", mOutFileName, ++mCount, partType,
                                             System::IO::Path::GetExtension(args->get_DocumentPartFileName()));

        // Below are two ways of specifying where Aspose.Words will save each part of the document.
        // 1 -  Set a filename for the output part file:
        args->set_DocumentPartFileName(partFileName);

        // 2 -  Create a custom stream for the output part file:
        args->set_DocumentPartStream(MakeObject<System::IO::FileStream>(ArtifactsDir + partFileName, System::IO::FileMode::Create));

        ASSERT_TRUE(args->get_DocumentPartStream()->get_CanWrite());
        ASSERT_FALSE(args->get_KeepDocumentPartStreamOpen());
    }
};

class SavedImageRename : public IImageSavingCallback
{
public:
    SavedImageRename(String outFileName) : mCount(0)
    {
        mOutFileName = outFileName;
    }

private:
    int mCount;
    String mOutFileName;

    void ImageSaving(SharedPtr<ImageSavingArgs> args) override
    {
        String imageFileName = String::Format(u"{0} shape {1}, of type {2}{3}", mOutFileName, ++mCount, args->get_CurrentShape()->get_ShapeType(),
                                              System::IO::Path::GetExtension(args->get_ImageFileName()));

        // Below are two ways of specifying where Aspose.Words will save each part of the document.
        // 1 -  Set a filename for the output image file:
        args->set_ImageFileName(imageFileName);

        // 2 -  Create a custom stream for the output image file:
        args->set_ImageStream(MakeObject<System::IO::FileStream>(ArtifactsDir + imageFileName, System::IO::FileMode::Create));

        ASSERT_TRUE(args->get_ImageStream()->get_CanWrite());
        ASSERT_TRUE(args->get_IsImageAvailable());
        ASSERT_FALSE(args->get_KeepImageStreamOpen());
    }
};

See Also