Aspose::Words::Saving::HtmlFixedSaveOptions class

HtmlFixedSaveOptions class

Can be used to specify additional options when saving a document into the HtmlFixed format. To learn more, visit the Specify Save Options documentation article.

class HtmlFixedSaveOptions : public Aspose::Words::Saving::FixedPageSaveOptions

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.
Equals(System::SharedPtr<System::Object>) overrideDetermines whether the specified object is equal in value to the current object.
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_ColorMode() constGets or sets a value determining how colors are rendered.
get_CssClassNamesPrefix() constSpecifies prefix which is added to all class names in style.css file. Default value is %“aw”.
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_Encoding() constSpecifies the encoding to use when exporting to HTML. Default value is new UTF8Encoding(true) (UTF-8 with BOM).
get_ExportEmbeddedCss() constSpecifies whether the CSS (Cascading Style Sheet) should be embedded into Html document.
get_ExportEmbeddedFonts() constSpecifies whether fonts should be embedded into Html document in Base64 format. Note setting this flag can significantly increase size of output Html file.
get_ExportEmbeddedImages() constSpecifies whether images should be embedded into Html document in Base64 format. Note setting this flag can significantly increase size of output Html file.
get_ExportEmbeddedSvg() constSpecifies whether SVG resources should be embedded into Html document. Default value is true.
get_ExportFormFields() constGets or sets indication of whether form fields are exported as interactive items (as ‘input’ tag) rather than converted to text or graphics.
get_ExportGeneratorName() constWhen true, causes the name and version of Aspose.Words to be embedded into produced files. Default value is true.
get_FontFormat() constGets or sets ExportFontFormat used for font exporting. Default value is Woff.
get_ImlRenderingMode() constGets or sets a value determining how ink (InkML) objects are rendered.
get_JpegQuality() constGets or sets a value determining the quality of the JPEG images inside Html document.
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_MetafileRenderingOptions() constAllows to specify metafile rendering options.
get_NumeralFormat() constGets or sets NumeralFormat used for rendering of numerals. European numerals are used by default.
get_OptimizeOutput() overrideFlag indicates whether it is required to optimize output. If this flag is set redundant nested canvases and empty canvases are removed, also neighbor glyphs with the same formating are concatenated. Note: The accuracy of the content display may be affected if this property is set to true. Default is true.
get_PageHorizontalAlignment() constSpecifies the horizontal alignment of pages in an HTML document. Default value is Center.
get_PageMargins() constSpecifies the margins around pages in an HTML document. The margins value is measured in points and should be equal to or greater than 0. Default value is 10 points.
get_PageSavingCallback() constAllows to control how separate pages are saved when a document is exported to fixed page format.
get_PageSet() constGets or sets the pages to render. Default is all the pages in the document.
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_ResourceSavingCallback() constAllows to control how resources (images, fonts and css) are saved when a document is exported to fixed page Html format.
get_ResourcesFolder() constSpecifies the physical folder where resources (images, fonts, css) are saved when exporting a document to Html format. Default is null.
get_ResourcesFolderAlias() constSpecifies the name of the folder used to construct image URIs written into an Html document. Default is null.
get_SaveFontFaceCssSeparately() constFlag indicates whether “@font-face” CSS rules should be placed into a separate file “fontFaces.css” when a document is being saved with external stylesheet (that is, when ExportEmbeddedCss is false). Default value is false, all CSS rules are written into single file “styles.css”.
get_SaveFormat() overrideSpecifies the format in which the document will be saved if this save options object is used. Can only be HtmlFixed.
get_ShowPageBorder() constSpecifies whether border around pages should be shown. Default is true.
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.
get_UseTargetMachineFonts() constFlag indicates whether fonts from target machine must be used to display the document. If this flag is set to true, FontFormat and ExportEmbeddedFonts properties do not have effect, also ResourceSavingCallback is not fired for fonts. Default is false.
GetType() const override
HtmlFixedSaveOptions()
Is(const System::TypeInfo&) const override
set_AllowEmbeddingPostScriptFonts(bool)Setter for Aspose::Words::Saving::SaveOptions::get_AllowEmbeddingPostScriptFonts.
set_ColorMode(Aspose::Words::Saving::ColorMode)Setter for Aspose::Words::Saving::FixedPageSaveOptions::get_ColorMode.
set_CssClassNamesPrefix(const System::String&)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_CssClassNamesPrefix.
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_Encoding(const System::SharedPtr<System::Text::Encoding>&)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_Encoding.
set_ExportEmbeddedCss(bool)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_ExportEmbeddedCss.
set_ExportEmbeddedFonts(bool)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_ExportEmbeddedFonts.
set_ExportEmbeddedImages(bool)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_ExportEmbeddedImages.
set_ExportEmbeddedSvg(bool)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_ExportEmbeddedSvg.
set_ExportFormFields(bool)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_ExportFormFields.
set_ExportGeneratorName(bool)Setter for Aspose::Words::Saving::SaveOptions::get_ExportGeneratorName.
set_FontFormat(Aspose::Words::Saving::ExportFontFormat)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_FontFormat.
set_ImlRenderingMode(Aspose::Words::Saving::ImlRenderingMode)Setter for Aspose::Words::Saving::SaveOptions::get_ImlRenderingMode.
set_JpegQuality(int32_t)Setter for Aspose::Words::Saving::FixedPageSaveOptions::get_JpegQuality.
set_MemoryOptimization(bool)Setter for Aspose::Words::Saving::SaveOptions::get_MemoryOptimization.
set_MetafileRenderingOptions(const System::SharedPtr<Aspose::Words::Saving::MetafileRenderingOptions>&)Setter for Aspose::Words::Saving::FixedPageSaveOptions::get_MetafileRenderingOptions.
set_NumeralFormat(Aspose::Words::Saving::NumeralFormat)Setter for Aspose::Words::Saving::FixedPageSaveOptions::get_NumeralFormat.
set_OptimizeOutput(bool) overrideSetter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_OptimizeOutput.
set_PageHorizontalAlignment(Aspose::Words::Saving::HtmlFixedPageHorizontalAlignment)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_PageHorizontalAlignment.
set_PageMargins(double)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_PageMargins.
set_PageSavingCallback(const System::SharedPtr<Aspose::Words::Saving::IPageSavingCallback>&)Setter for Aspose::Words::Saving::FixedPageSaveOptions::get_PageSavingCallback.
set_PageSet(const System::SharedPtr<Aspose::Words::Saving::PageSet>&)Setter for Aspose::Words::Saving::FixedPageSaveOptions::get_PageSet.
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_ResourceSavingCallback(const System::SharedPtr<Aspose::Words::Saving::IResourceSavingCallback>&)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_ResourceSavingCallback.
set_ResourcesFolder(const System::String&)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_ResourcesFolder.
set_ResourcesFolderAlias(const System::String&)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_ResourcesFolderAlias.
set_SaveFontFaceCssSeparately(bool)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_SaveFontFaceCssSeparately.
set_SaveFormat(Aspose::Words::SaveFormat) overrideSetter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_SaveFormat.
set_ShowPageBorder(bool)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_ShowPageBorder.
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.
set_UseTargetMachineFonts(bool)Setter for Aspose::Words::Saving::HtmlFixedSaveOptions::get_UseTargetMachineFonts.
static Type()

Examples

Shows how to use a callback to print the URIs of external resources created while converting a document to HTML.

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

    auto callback = MakeObject<ExHtmlFixedSaveOptions::ResourceUriPrinter>();

    auto options = MakeObject<HtmlFixedSaveOptions>();
    options->set_SaveFormat(SaveFormat::HtmlFixed);
    options->set_ExportEmbeddedImages(false);
    options->set_ResourcesFolder(ArtifactsDir + u"HtmlFixedResourceFolder");
    options->set_ResourcesFolderAlias(ArtifactsDir + u"HtmlFixedResourceFolderAlias");
    options->set_ShowPageBorder(false);
    options->set_ResourceSavingCallback(callback);

    // A folder specified by ResourcesFolderAlias will contain the resources instead of ResourcesFolder.
    // We must ensure the folder exists before the streams can put their resources into it.
    System::IO::Directory::CreateDirectory_(options->get_ResourcesFolderAlias());

    doc->Save(ArtifactsDir + u"HtmlFixedSaveOptions.HtmlFixedResourceFolder.html", options);

    std::cout << callback->GetText() << std::endl;

    ArrayPtr<String> resourceFiles = System::IO::Directory::GetFiles(ArtifactsDir + u"HtmlFixedResourceFolderAlias");

    ASSERT_FALSE(System::IO::Directory::Exists(ArtifactsDir + u"HtmlFixedResourceFolder"));
    std::function<bool(String f)> isImageOrCss = [](String f)
    {
        return f.EndsWith(u".jpeg") || f.EndsWith(u".png") || f.EndsWith(u".css");
    };

    ASSERT_EQ(6, resourceFiles->LINQ_Count(isImageOrCss));
}

class ResourceUriPrinter : public IResourceSavingCallback
{
public:
    String GetText()
    {
        return mText->ToString();
    }

    ResourceUriPrinter() : mSavedResourceCount(0), mText(MakeObject<System::Text::StringBuilder>())
    {
    }

private:
    int mSavedResourceCount;
    SharedPtr<System::Text::StringBuilder> mText;

    void ResourceSaving(SharedPtr<ResourceSavingArgs> args) override
    {
        // If we set a folder alias in the SaveOptions object, we will be able to print it from here.
        mText->AppendLine(String::Format(u"Resource #{0} \"{1}\"", ++mSavedResourceCount, args->get_ResourceFileName()));

        String extension = System::IO::Path::GetExtension(args->get_ResourceFileName());
        if (extension == u".ttf" || extension == u".woff")
        {
            // By default, 'ResourceFileUri' uses system folder for fonts.
            // To avoid problems in other platforms you must explicitly specify the path for the fonts.
            args->set_ResourceFileUri(ArtifactsDir + System::IO::Path::DirectorySeparatorChar + args->get_ResourceFileName());
        }

        mText->AppendLine(String(u"\t") + args->get_ResourceFileUri());

        // If we have specified a folder in the "ResourcesFolderAlias" property,
        // we will also need to redirect each stream to put its resource in that folder.
        args->set_ResourceStream(MakeObject<System::IO::FileStream>(args->get_ResourceFileUri(), System::IO::FileMode::Create));
        args->set_KeepResourceStreamOpen(false);
    }
};

See Also