HtmlFixedSaveOptions Class

Can be used to specify additional options when saving a document into the HtmlFixed format.

ExpandedInheritance Hierarchy

Namespace:  Aspose.Words.Saving
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 21.5.0

ExpandedSyntax

public class HtmlFixedSaveOptions : FixedPageSaveOptions

The HtmlFixedSaveOptions type exposes the following members.

ExpandedConstructors

  NameDescription
Public methodHtmlFixedSaveOptions
Initializes a new instance of the HtmlFixedSaveOptions class

ExpandedProperties

  NameDescription
Public propertyCode exampleAllowEmbeddingPostScriptFonts
Gets 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.
(Inherited from SaveOptions.)
Public propertyCode exampleColorMode
Gets or sets a value determining how colors are rendered.
(Inherited from FixedPageSaveOptions.)
Public propertyCode exampleCssClassNamesPrefix
Specifies prefix which is added to all class names in style.css file. Default value is "aw".
Public propertyCustomTimeZoneInfo
Gets or sets custom local time zone used for date/time fields.
(Inherited from SaveOptions.)
Public propertyCode exampleDefaultTemplate
Gets or sets path to default template (including filename). Default value for this property is empty string (Empty).
(Inherited from SaveOptions.)
Public propertyDml3DEffectsRenderingMode
Gets or sets a value determining how 3D effects are rendered.
(Inherited from SaveOptions.)
Public propertyCode exampleDmlEffectsRenderingMode
Gets or sets a value determining how DrawingML effects are rendered.
(Inherited from SaveOptions.)
Public propertyCode exampleDmlRenderingMode
Gets or sets a value determining how DrawingML shapes are rendered.
(Inherited from SaveOptions.)
Public propertyCode exampleEncoding
Specifies the encoding to use when exporting to HTML. Default value is new UTF8Encoding(true) (UTF-8 with BOM).
Public propertyCode exampleExportEmbeddedCss
Specifies whether the CSS (Cascading Style Sheet) should be embedded into Html document.
Public propertyCode exampleExportEmbeddedFonts
Specifies whether fonts should be embedded into Html document in Base64 format. Note setting this flag can significantly increase size of output Html file.
Public propertyCode exampleExportEmbeddedImages
Specifies whether images should be embedded into Html document in Base64 format. Note setting this flag can significantly increase size of output Html file.
Public propertyCode exampleExportEmbeddedSvg
Specifies whether SVG resources should be embedded into Html document. Default value is true.
Public propertyCode exampleExportFormFields
Gets or sets indication of whether form fields are exported as interactive items (as 'input' tag) rather than converted to text or graphics.
Public propertyCode exampleFontFormat
Gets or sets ExportFontFormat used for font exporting. Default value is Woff.
Public propertyCode exampleJpegQuality
Gets or sets a value determining the quality of the JPEG images inside Html document.
(Inherited from FixedPageSaveOptions.)
Public propertyCode exampleMemoryOptimization
Gets or sets value determining if memory optimization should be performed before saving the document. Default value for this property is false.
(Inherited from SaveOptions.)
Public propertyCode exampleMetafileRenderingOptions
Allows to specify metafile rendering options.
(Inherited from FixedPageSaveOptions.)
Public propertyCode exampleNumeralFormat
Gets or sets NumeralFormat used for rendering of numerals. European numerals are used by default.
(Inherited from FixedPageSaveOptions.)
Public propertyCode exampleOptimizeOutput
Flag 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.
(Overrides FixedPageSaveOptionsOptimizeOutput.)
Public propertyCode examplePageHorizontalAlignment
Specifies the horizontal alignment of pages in an HTML document. Default value is HtmlFixedHorizontalPageAlignment.Center.
Public propertyCode examplePageMargins
Specifies 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.
Public propertyCode examplePageSavingCallback
Allows to control how separate pages are saved when a document is exported to fixed page format.
(Inherited from FixedPageSaveOptions.)
Public propertyCode examplePageSet
Gets or sets the pages to render. Default is all the pages in the document.
(Inherited from FixedPageSaveOptions.)
Public propertyCode examplePrettyFormat
When true, pretty formats output where applicable. Default value is false.
(Inherited from SaveOptions.)
Public propertyCode exampleResourceSavingCallback
Allows to control how resources (images, fonts and css) are saved when a document is exported to fixed page Html format.
Public propertyCode exampleResourcesFolder
Specifies the physical folder where resources (images, fonts, css) are saved when exporting a document to Html format. Default is null.
Public propertyCode exampleResourcesFolderAlias
Specifies the name of the folder used to construct image URIs written into an Html document. Default is null.
Public propertyCode exampleSaveFontFaceCssSeparately
Flag 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".
Public propertyCode exampleSaveFormat
Specifies the format in which the document will be saved if this save options object is used. Can only be HtmlFixed.
(Overrides SaveOptionsSaveFormat.)
Public propertyCode exampleShowPageBorder
Specifies whether border around pages should be shown. Default is true.
Public propertyCode exampleTempFolder
Specifies 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.
(Inherited from SaveOptions.)
Public propertyUpdateCreatedTimeProperty
Gets or sets a value determining whether the CreatedTime property is updated before saving. Default value is false;
(Inherited from SaveOptions.)
Public propertyCode exampleUpdateFields
Gets 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.
(Inherited from SaveOptions.)
Public propertyCode exampleUpdateLastPrintedProperty
Gets or sets a value determining whether the LastPrinted property is updated before saving.
(Inherited from SaveOptions.)
Public propertyCode exampleUpdateLastSavedTimeProperty
Gets or sets a value determining whether the LastSavedTime property is updated before saving.
(Inherited from SaveOptions.)
Public propertyCode exampleUpdateSdtContent
Gets or sets value determining whether content of StructuredDocumentTag is updated before saving.
(Inherited from SaveOptions.)
Public propertyCode exampleUseAntiAliasing
Gets or sets a value determining whether or not to use anti-aliasing for rendering.
(Inherited from SaveOptions.)
Public propertyCode exampleUseHighQualityRendering
Gets or sets a value determining whether or not to use high quality (i.e. slow) rendering algorithms.
(Inherited from SaveOptions.)
Public propertyCode exampleUseTargetMachineFonts
Flag 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.

ExpandedMethods

  NameDescription
Public methodEquals
Determines whether the specified object is equal in value to the current object.
(Inherited from FixedPageSaveOptions.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)

ExpandedExamples

Shows how to use a callback to print the URIs of external resources created while converting a document to HTML.
public void HtmlFixedResourceFolder()
{
    Document doc = new Document(MyDir + "Rendering.docx");

    ResourceUriPrinter callback = new ResourceUriPrinter();

    HtmlFixedSaveOptions options = new HtmlFixedSaveOptions
    {
        SaveFormat = SaveFormat.HtmlFixed,
        ExportEmbeddedImages = false,
        ResourcesFolder = ArtifactsDir + "HtmlFixedResourceFolder",
        ResourcesFolderAlias = ArtifactsDir + "HtmlFixedResourceFolderAlias",
        ShowPageBorder = false,
        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.
    Directory.CreateDirectory(options.ResourcesFolderAlias);

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

    Console.WriteLine(callback.GetText());

    string[] resourceFiles = Directory.GetFiles(ArtifactsDir + "HtmlFixedResourceFolderAlias");

    Assert.False(Directory.Exists(ArtifactsDir + "HtmlFixedResourceFolder"));
    Assert.AreEqual(6, resourceFiles.Count(f => f.EndsWith(".jpeg") || f.EndsWith(".png") || f.EndsWith(".css")));
}

/// <summary>
/// Counts and prints URIs of resources contained by as they are converted to fixed HTML.
/// </summary>
private class ResourceUriPrinter : IResourceSavingCallback
{
    void IResourceSavingCallback.ResourceSaving(ResourceSavingArgs args)
    {
        // If we set a folder alias in the SaveOptions object, we will be able to print it from here.
        mText.AppendLine($"Resource #{++mSavedResourceCount} \"{args.ResourceFileName}\"");

        string extension = Path.GetExtension(args.ResourceFileName);
        switch (extension)
        {
            case ".ttf":
            case ".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.ResourceFileUri = ArtifactsDir + Path.DirectorySeparatorChar + args.ResourceFileName;
                break;
            }
        }

        mText.AppendLine("\t" + args.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.ResourceStream = new FileStream(args.ResourceFileUri, FileMode.Create);
        args.KeepResourceStreamOpen = false;
    }

    public string GetText()
    {
        return mText.ToString();
    }

    private int mSavedResourceCount;
    private readonly StringBuilder mText = new StringBuilder();
}

ExpandedSee Also