search/mag_sel search/close
Aspose::Words::Saving Namespace Reference

The Aspose.Words.Saving namespace provides classes and enumerations that allow to specify additional options for saving or converting documents.

Classes

class  BookmarksOutlineLevelCollection
 A collection of individual bookmarks outline level. More...
 
class  CssSavingArgs
 Provides data for the CssSaving() event. More...
 
class  DocSaveOptions
 Can be used to specify additional options when saving a document into the Doc or Dot format. More...
 
class  DocumentPartSavingArgs
 Provides data for the DocumentPartSaving() callback. More...
 
class  DownsampleOptions
 Allows to specify downsample options. More...
 
class  FixedPageSaveOptions
 Contains common options that can be specified when saving a document into fixed page formats (PDF, XPS, images etc). More...
 
class  FontSavingArgs
 Provides data for the FontSaving() event. More...
 
class  HtmlFixedSaveOptions
 Can be used to specify additional options when saving a document into the HtmlFixed format. More...
 
class  HtmlSaveOptions
 Can be used to specify additional options when saving a document into the Html, Mhtml or Epub format. More...
 
interface  ICssSavingCallback
 Implement this interface if you want to control how Aspose.Words saves CSS (Cascading Style Sheet) when saving a document to HTML. More...
 
interface  IDocumentPartSavingCallback
 Implement this interface if you want to receive notifications and control how Aspose.Words saves document parts when exporting a document to Html or Epub format. More...
 
interface  IFontSavingCallback
 Implement this interface if you want to receive notifications and control how Aspose.Words saves fonts when exporting a document to HTML format. More...
 
interface  IImageSavingCallback
 Implement this interface if you want to control how Aspose.Words saves images when saving a document to HTML. May be used by other formats. More...
 
class  ImageSaveOptions
 Allows to specify additional options when rendering document pages or shapes to images. More...
 
class  ImageSavingArgs
 Provides data for the ImageSaving() event. More...
 
interface  IPageSavingCallback
 Implement this interface if you want to control how Aspose.Words saves separate pages when saving a document to fixed page formats. More...
 
interface  IResourceSavingCallback
 Implement this interface if you want to control how Aspose.Words saves external resources (images, fonts and css) when saving a document to fixed page HTML or SVG. More...
 
class  MarkdownSaveOptions
 Class to specify additional options when saving a document into the Markdown format. More...
 
class  MetafileRenderingOptions
 Allows to specify additional metafile rendering options. More...
 
class  OdtSaveOptions
 Can be used to specify additional options when saving a document into the Odt or Ott format. More...
 
class  OoxmlSaveOptions
 Can be used to specify additional options when saving a document into the Docx, Docm, Dotx, Dotm or FlatOpc format. More...
 
class  OutlineOptions
 Allows to specify outline options. More...
 
class  PageRange
 Represents a continuous range of pages. More...
 
class  PageSavingArgs
 Provides data for the PageSaving() event. More...
 
class  PageSet
 Describes a random set of pages. More...
 
class  PclSaveOptions
 Can be used to specify additional options when saving a document into the Pcl format. More...
 
class  PdfDigitalSignatureDetails
 Contains details for signing a PDF document with a digital signature. More...
 
class  PdfDigitalSignatureTimestampSettings
 Contains settings of the digital signature timestamp. More...
 
class  PdfEncryptionDetails
 Contains details for encrypting and access permissions for a PDF document. More...
 
class  PdfSaveOptions
 Can be used to specify additional options when saving a document into the Pdf format. More...
 
class  PsSaveOptions
 Can be used to specify additional options when saving a document into the Ps format. More...
 
class  ResourceSavingArgs
 Provides data for the ResourceSaving() event. More...
 
class  RtfSaveOptions
 Can be used to specify additional options when saving a document into the Rtf format. More...
 
class  SaveOptions
 This is an abstract base class for classes that allow the user to specify additional options when saving a document into a particular format. More...
 
class  SaveOutputParameters
 This object is returned to the caller after a document is saved and contains additional information that has been generated or calculated during the save operation. The caller can use or ignore this object. More...
 
class  SvgSaveOptions
 Can be used to specify additional options when saving a document into the Svg format. More...
 
class  TxtListIndentation
 Specifies how list levels are indented when document is exporting to Text format. More...
 
class  TxtSaveOptions
 Can be used to specify additional options when saving a document into the Text format. More...
 
class  TxtSaveOptionsBase
 The base class for specifying additional options when saving a document into a text based formats. More...
 
class  WordML2003SaveOptions
 Can be used to specify additional options when saving a document into the WordML format. More...
 
class  XamlFixedSaveOptions
 Can be used to specify additional options when saving a document into the XamlFixed format. More...
 
class  XamlFlowSaveOptions
 Can be used to specify additional options when saving a document into the XamlFlow or XamlFlowPack format. More...
 
class  XpsSaveOptions
 Can be used to specify additional options when saving a document into the Xps format. More...
 

Enumerations

enum class  ColorMode
 Specifies how colors are rendered. More...
 
enum class  CompressionLevel
 Compression level for OOXML files. (DOCX and DOTX files are internally a ZIP-archive, this property controls the compression level of the archive. Note, that FlatOpc file is not a ZIP-archive, therefore, this property does not affect the FlatOpc files.) More...
 
enum class  CssStyleSheetType
 Specifies how CSS (Cascading Style Sheet) styles are exported to HTML. More...
 
enum class  Dml3DEffectsRenderingMode
 Specifies how 3D shape effects are rendered. More...
 
enum class  DmlEffectsRenderingMode
 Specifies how DrawingML effects are rendered to fixed page formats. More...
 
enum class  DmlRenderingMode
 Specifies how DrawingML shapes are rendered to fixed page formats. More...
 
enum class  DocumentSplitCriteria
 Specifies how the document is split into parts when saving to Html or Epub format. More...
 
enum class  EmfPlusDualRenderingMode
 Specifies how Aspose.Words should render EMF+ Dual metafiles. More...
 
enum class  ExportFontFormat
 Indicates the format that is used to export fonts while rendering to HTML fixed format. More...
 
enum class  ExportHeadersFootersMode
 Specifies how headers and footers are exported to HTML, MHTML or EPUB. More...
 
enum class  ExportListLabels
 Specifies how list labels are exported to HTML, MHTML and EPUB. More...
 
enum class  HeaderFooterBookmarksExportMode
 Specifies how bookmarks in headers/footers are exported. More...
 
enum class  HtmlElementSizeOutputMode
 Specifies how Aspose.Words exports element widths and heights to HTML, MHTML and EPUB. More...
 
enum class  HtmlFixedPageHorizontalAlignment
 Specifies the horizontal alignment for pages in output HTML document. More...
 
enum class  HtmlMetafileFormat
 Indicates the format in which metafiles are saved to HTML documents. More...
 
enum class  HtmlOfficeMathOutputMode
 Specifies how Aspose.Words exports OfficeMath to HTML, MHTML and EPUB. More...
 
enum class  HtmlVersion
 Indicates the version of HTML is used when saving the document to Html and Mhtml formats. More...
 
enum class  ImageBinarizationMethod
 Specifies the method used to binarize image. More...
 
enum class  ImageColorMode
 Specifies the color mode for the generated images of document pages. More...
 
enum class  ImagePixelFormat
 Specifies the pixel format for the generated images of document pages. More...
 
enum class  ImlRenderingMode
 Specifies how ink (InkML) objects are rendered to fixed page formats. More...
 
enum class  MetafileRenderingMode
 Specifies how Aspose.Words should render WMF and EMF metafiles. More...
 
enum class  NumeralFormat
 Indicates the symbol set that is used to represent numbers while rendering to fixed page formats. More...
 
enum class  OdtSaveMeasureUnit
 Specified units of measure to apply to measurable document content such as shape, widths and other during saving. More...
 
enum class  OoxmlCompliance
 Allows to specify which OOXML specification will be used when saving in the DOCX format. More...
 
enum class  PdfCompliance
 Specifies the PDF standards compliance level. More...
 
enum class  PdfCustomPropertiesExport
 Specifies the way CustomDocumentProperties are exported to PDF file. More...
 
enum class  PdfDigitalSignatureHashAlgorithm
 Specifies a digital hash algorithm used by a digital signature. More...
 
enum class  PdfEncryptionAlgorithm
 Specifies the encryption algorithm to use for encrypting a PDF document. More...
 
enum class  PdfFontEmbeddingMode
 Specifies how Aspose.Words should embed fonts. More...
 
enum class  PdfImageColorSpaceExportMode
 Specifies how the color space will be selected for the images in PDF document. More...
 
enum class  PdfImageCompression
 Specifies the type of compression applied to images in the PDF file. More...
 
enum class  PdfPageMode
 Specifies how the PDF document should be displayed when opened in the PDF reader. More...
 
enum class  PdfPermissions
 Specifies the operations that are allowed to a user on an encrypted PDF document. More...
 
enum class  PdfTextCompression
 Specifies a type of compression applied to all content in the PDF file except images. More...
 
enum class  PdfZoomBehavior
 Specifies the type of zoom applied to a PDF document when it is opened in a PDF viewer. More...
 
enum class  SvgTextOutputMode
 
enum class  TableContentAlignment
 Allows to specify the alignment of the content of the table to be used when exporting into Markdown format. More...
 
enum class  TiffCompression
 Specifies what type of compression to apply when saving page images into a TIFF file. More...
 
enum class  TxtExportHeadersFootersMode
 Specifies the way headers and footers are exported to plain text format. More...
 

Enumeration Type Documentation

◆ ColorMode

Specifies how colors are rendered.

Examples

Shows how to change image color with saving options property.

auto doc = MakeObject<Document>(MyDir + u"Images.docx");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
// Set the "ColorMode" property to "Grayscale" to render all images from the document in black and white.
// The size of the output document may be larger with this setting.
// Set the "ColorMode" property to "Normal" to render all images in color.
auto pdfSaveOptions = MakeObject<PdfSaveOptions>();
pdfSaveOptions->set_ColorMode(colorMode);
doc->Save(ArtifactsDir + u"PdfSaveOptions.ColorRendering.pdf", pdfSaveOptions);
Enumerator
Normal 

Rendering with unmodified colors.

Grayscale 

Rendering with colors in a range of gray shades from white to black.

◆ CompressionLevel

Compression level for OOXML files. (DOCX and DOTX files are internally a ZIP-archive, this property controls the compression level of the archive. Note, that FlatOpc file is not a ZIP-archive, therefore, this property does not affect the FlatOpc files.)

Examples

Shows how to specify the compression level to use while saving an OOXML document.

auto doc = MakeObject<Document>(MyDir + u"Big document.docx");
// When we save the document to an OOXML format, we can create an OoxmlSaveOptions object
// and then pass it to the document's saving method to modify how we save the document.
// Set the "CompressionLevel" property to "CompressionLevel.Maximum" to apply the strongest and slowest compression.
// Set the "CompressionLevel" property to "CompressionLevel.Normal" to apply
// the default compression that Aspose.Words uses while saving OOXML documents.
// Set the "CompressionLevel" property to "CompressionLevel.Fast" to apply a faster and weaker compression.
// Set the "CompressionLevel" property to "CompressionLevel.SuperFast" to apply
// the default compression that Microsoft Word uses.
auto saveOptions = MakeObject<OoxmlSaveOptions>(SaveFormat::Docx);
saveOptions->set_CompressionLevel(compressionLevel);
SharedPtr<System::Diagnostics::Stopwatch> st = System::Diagnostics::Stopwatch::StartNew();
doc->Save(ArtifactsDir + u"OoxmlSaveOptions.DocumentCompression.docx", saveOptions);
st->Stop();
auto fileInfo = MakeObject<System::IO::FileInfo>(ArtifactsDir + u"OoxmlSaveOptions.DocumentCompression.docx");
std::cout << String::Format(u"Saving operation done using the \"{0}\" compression level:", compressionLevel) << std::endl;
std::cout << "\tDuration:\t" << st->get_ElapsedMilliseconds() << " ms" << std::endl;
std::cout << "\tFile Size:\t" << fileInfo->get_Length() << " bytes" << std::endl;
Enumerator
Normal 

Normal compression level. Default compression level used by Aspose.Words.

Maximum 

Maximum compression level.

Fast 

Fast compression level.

SuperFast 

Super Fast compression level. Microsoft Word uses this compression level.

◆ CssStyleSheetType

Specifies how CSS (Cascading Style Sheet) styles are exported to HTML.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_CssStyleSheetType
Examples

Shows how to work with CSS stylesheets that an HTML conversion creates.

void ExternalCssFilenames()
{
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// 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>();
// Set the "CssStylesheetType" property to "CssStyleSheetType.External" to
// accompany a saved HTML document with an external CSS stylesheet file.
options->set_CssStyleSheetType(CssStyleSheetType::External);
// Below are two ways of specifying directories and filenames for output CSS stylesheets.
// 1 - Use the "CssStyleSheetFileName" property to assign a filename to our stylesheet:
options->set_CssStyleSheetFileName(ArtifactsDir + u"SavingCallback.ExternalCssFilenames.css");
// 2 - Use a custom callback to name our stylesheet:
options->set_CssSavingCallback(
MakeObject<ExSavingCallback::CustomCssSavingCallback>(ArtifactsDir + u"SavingCallback.ExternalCssFilenames.css", true, false));
doc->Save(ArtifactsDir + u"SavingCallback.ExternalCssFilenames.html", options);
}
class CustomCssSavingCallback : public ICssSavingCallback
{
public:
CustomCssSavingCallback(String cssDocFilename, bool isExportNeeded, bool keepCssStreamOpen) : mIsExportNeeded(false), mKeepCssStreamOpen(false)
{
mCssTextFileName = cssDocFilename;
mIsExportNeeded = isExportNeeded;
mKeepCssStreamOpen = keepCssStreamOpen;
}
void CssSaving(SharedPtr<CssSavingArgs> args) override
{
// We can access the entire source document via the "Document" property.
ASSERT_TRUE(args->get_Document()->get_OriginalFileName().EndsWith(u"Rendering.docx"));
args->set_CssStream(MakeObject<System::IO::FileStream>(mCssTextFileName, System::IO::FileMode::Create));
args->set_IsExportNeeded(mIsExportNeeded);
args->set_KeepCssStreamOpen(mKeepCssStreamOpen);
ASSERT_TRUE(args->get_CssStream()->get_CanWrite());
}
private:
String mCssTextFileName;
bool mIsExportNeeded;
bool mKeepCssStreamOpen;
};
Enumerator
Inline 

CSS styles are written inline (as a value of the style attribute on every element).

Embedded 

CSS styles are written separately from the content in a style sheet embedded in the HTML file.

External 

CSS styles are written separately from the content in a style sheet in an external file. The HTML file links the style sheet.

◆ Dml3DEffectsRenderingMode

Specifies how 3D shape effects are rendered.

Enumerator
Basic 

A lightweight and stable rendering, based on the internal engine, but advanced effects such as lighting, materials and other additional effects are not displayed when using this mode. Please see documentation for details.

Advanced 

Rendering of an extended list of special effects including advanced 3D effects such as bevels, lighting and materials.

◆ DmlEffectsRenderingMode

Specifies how DrawingML effects are rendered to fixed page formats.

Examples

Shows how to configure the rendering quality of DrawingML effects in a document as we save it to PDF.

auto doc = MakeObject<Document>(MyDir + u"DrawingML shape effects.docx");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto options = MakeObject<PdfSaveOptions>();
// Set the "DmlEffectsRenderingMode" property to "DmlEffectsRenderingMode.None" to discard all DrawingML effects.
// Set the "DmlEffectsRenderingMode" property to "DmlEffectsRenderingMode.Simplified"
// to render a simplified version of DrawingML effects.
// Set the "DmlEffectsRenderingMode" property to "DmlEffectsRenderingMode.Fine" to
// render DrawingML effects with more accuracy and also with more processing cost.
options->set_DmlEffectsRenderingMode(effectsRenderingMode);
ASSERT_EQ(DmlRenderingMode::DrawingML, options->get_DmlRenderingMode());
doc->Save(ArtifactsDir + u"PdfSaveOptions.DrawingMLEffects.pdf", options);
Enumerator
Simplified 

Rendering of DrawingML effects are simplified.

None 

No DrawingML effects are rendered.

Fine 

DrawingML effects are rendered in fine mode which involves advanced processing. In this mode rendering of effects gives better results but at a higher performance cost than Simplified mode.

◆ DmlRenderingMode

Specifies how DrawingML shapes are rendered to fixed page formats.

Examples

Shows how to configure the rendering quality of DrawingML effects in a document as we save it to PDF.

auto doc = MakeObject<Document>(MyDir + u"DrawingML shape effects.docx");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto options = MakeObject<PdfSaveOptions>();
// Set the "DmlEffectsRenderingMode" property to "DmlEffectsRenderingMode.None" to discard all DrawingML effects.
// Set the "DmlEffectsRenderingMode" property to "DmlEffectsRenderingMode.Simplified"
// to render a simplified version of DrawingML effects.
// Set the "DmlEffectsRenderingMode" property to "DmlEffectsRenderingMode.Fine" to
// render DrawingML effects with more accuracy and also with more processing cost.
options->set_DmlEffectsRenderingMode(effectsRenderingMode);
ASSERT_EQ(DmlRenderingMode::DrawingML, options->get_DmlRenderingMode());
doc->Save(ArtifactsDir + u"PdfSaveOptions.DrawingMLEffects.pdf", options);

Shows how to render fallback shapes when saving to PDF.

auto doc = MakeObject<Document>(MyDir + u"DrawingML shape fallbacks.docx");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto options = MakeObject<PdfSaveOptions>();
// Set the "DmlRenderingMode" property to "DmlRenderingMode.Fallback"
// to substitute DML shapes with their fallback shapes.
// Set the "DmlRenderingMode" property to "DmlRenderingMode.DrawingML"
// to render the DML shapes themselves.
options->set_DmlRenderingMode(dmlRenderingMode);
doc->Save(ArtifactsDir + u"PdfSaveOptions.DrawingMLFallback.pdf", options);
Enumerator
Fallback 

If fall-back shape is available for DrawingML, Aspose.Words renders fall-back shape instead of the DrawingML.

DrawingML 

Aspose.Words ignores fall-back shape of DrawingML and renders DrawingML itself. This is the default mode.

◆ DocumentSplitCriteria

Specifies how the document is split into parts when saving to Html or Epub format.

DocumentSplitCriteria is a set of flags which can be combined. For instance you can split the document at page breaks and heading paragraphs in the same export operation.

Different criteria can partially overlap. For instance, Heading 1 style is frequently given PageBreakBefore property so it falls under two criteria: PageBreak and HeadingParagraph. Some section breaks can cause page breaks and so on. In typical cases specifying only one flag is the most practical option.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_DocumentSplitCriteria
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);
Enumerator
None 

The document is not split.

PageBreak 

The document is split into parts at explicit page breaks. A page break can be specified by a PageBreak character, a section break specifying start of new section on a new page, or a paragraph that has its PageBreakBefore property set to true.

ColumnBreak 

The document is split into parts at column breaks. A column break can be specified by a ColumnBreak character or a section break specifying start of new section in a new column.

SectionBreak 

The document is split into parts at a section break of any type.

HeadingParagraph 

The document is split into parts at a paragraph formatted using a heading style Heading 1, Heading 2 etc. Use together with DocumentSplitHeadingLevel to specify the heading levels (from 1 to the specified level) at which to split.

◆ EmfPlusDualRenderingMode

Specifies how Aspose.Words should render EMF+ Dual metafiles.

Examples

Shows how to configure Enhanced Windows Metafile-related rendering options when saving to PDF.

auto doc = MakeObject<Document>(MyDir + u"EMF.docx");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto saveOptions = MakeObject<PdfSaveOptions>();
// Set the "EmfPlusDualRenderingMode" property to "EmfPlusDualRenderingMode.Emf"
// to only render the EMF part of an EMF+ dual metafile.
// Set the "EmfPlusDualRenderingMode" property to "EmfPlusDualRenderingMode.EmfPlus" to
// to render the EMF+ part of an EMF+ dual metafile.
// Set the "EmfPlusDualRenderingMode" property to "EmfPlusDualRenderingMode.EmfPlusWithFallback"
// to render the EMF+ part of an EMF+ dual metafile if all of the EMF+ records are supported.
// Otherwise, Aspose.Words will render the EMF part.
saveOptions->get_MetafileRenderingOptions()->set_EmfPlusDualRenderingMode(renderingMode);
// Set the "UseEmfEmbeddedToWmf" property to "true" to render embedded EMF data
// for metafiles that we can render as vector graphics.
saveOptions->get_MetafileRenderingOptions()->set_UseEmfEmbeddedToWmf(true);
doc->Save(ArtifactsDir + u"PdfSaveOptions.RenderMetafile.pdf", saveOptions);
Enumerator
EmfPlusWithFallback 

Aspose.Words tries to render EMF+ part of EMF+ Dual metafile. If some of the EMF+ records are not supported then Aspose.Words renders EMF part of EMF+ Dual metafile.

EmfPlus 

Aspose.Words renders EMF+ part of EMF+ Dual metafile.

Emf 

Aspose.Words renders EMF part of EMF+ Dual metafile.

◆ ExportFontFormat

Indicates the format that is used to export fonts while rendering to HTML fixed format.

See also
Aspose::Words::Saving::HtmlFixedSaveOptions::get_FontFormat
Examples

Shows how use fonts only from the target machine when saving a document to HTML.

auto doc = MakeObject<Document>(MyDir + u"Bullet points with alternative font.docx");
auto saveOptions = MakeObject<HtmlFixedSaveOptions>();
saveOptions->set_ExportEmbeddedCss(true);
saveOptions->set_UseTargetMachineFonts(useTargetMachineFonts);
saveOptions->set_FontFormat(ExportFontFormat::Ttf);
saveOptions->set_ExportEmbeddedFonts(false);
doc->Save(ArtifactsDir + u"HtmlFixedSaveOptions.UsingMachineFonts.html", saveOptions);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlFixedSaveOptions.UsingMachineFonts.html");
if (useTargetMachineFonts)
{
ASSERT_FALSE(System::Text::RegularExpressions::Regex::Match(outDocContents, u"@font-face")->get_Success());
}
else
{
outDocContents, String(u"@font-face { font-family:'Arial'; font-style:normal; font-weight:normal; src:local[(]'☺'[)], ") +
u"url[(]'HtmlFixedSaveOptions.UsingMachineFonts/font001.ttf'[)] format[(]'truetype'[)]; }")
->get_Success());
}
Enumerator
Woff 

WOFF (Web Open Font Format).

Ttf 

TTF (TrueType Font format).

◆ ExportHeadersFootersMode

Specifies how headers and footers are exported to HTML, MHTML or EPUB.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_ExportHeadersFootersMode
Examples

Shows how to omit headers/footers when saving a document to HTML.

auto doc = MakeObject<Document>(MyDir + u"Header and footer types.docx");
// This document contains headers and footers. We can access them via the "HeadersFooters" collection.
ASSERT_EQ(u"First header", doc->get_FirstSection()->get_HeadersFooters()->idx_get(HeaderFooterType::HeaderFirst)->GetText().Trim());
// Formats such as .html do not split the document into pages, so headers/footers will not function the same way
// they would when we open the document as a .docx using Microsoft Word.
// If we convert a document with headers/footers to html, the conversion will assimilate the headers/footers into body text.
// We can use a SaveOptions object to omit headers/footers while converting to html.
auto saveOptions = MakeObject<HtmlSaveOptions>(SaveFormat::Html);
saveOptions->set_ExportHeadersFootersMode(ExportHeadersFootersMode::None);
doc->Save(ArtifactsDir + u"HeaderFooter.ExportMode.html", saveOptions);
// Open our saved document and verify that it does not contain the header's text
doc = MakeObject<Document>(ArtifactsDir + u"HeaderFooter.ExportMode.html");
ASSERT_FALSE(doc->get_Range()->get_Text().Contains(u"First header"));
Enumerator
None 

Headers and footers are not exported.

PerSection 

Primary headers and footers are exported at the beginning and the end of each section.

FirstSectionHeaderLastSectionFooter 

Primary header of the first section is exported at the beginning of the document and primary footer is at the end.

FirstPageHeaderFooterPerSection 

First page header and footer are exported at the beginning and the end of each section.

◆ ExportListLabels

Specifies how list labels are exported to HTML, MHTML and EPUB.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_ExportListLabels
Examples

Shows how to configure list exporting to HTML.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Aspose::Words::Lists::List> list = doc->get_Lists()->Add(ListTemplate::NumberDefault);
builder->get_ListFormat()->set_List(list);
builder->Writeln(u"Default numbered list item 1.");
builder->Writeln(u"Default numbered list item 2.");
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"Default numbered list item 3.");
builder->get_ListFormat()->RemoveNumbers();
list = doc->get_Lists()->Add(ListTemplate::OutlineHeadingsLegal);
builder->get_ListFormat()->set_List(list);
builder->Writeln(u"Outline legal heading list item 1.");
builder->Writeln(u"Outline legal heading list item 2.");
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"Outline legal heading list item 3.");
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"Outline legal heading list item 4.");
builder->get_ListFormat()->ListIndent();
builder->Writeln(u"Outline legal heading list item 5.");
builder->get_ListFormat()->RemoveNumbers();
// When saving the document to HTML, we can pass a SaveOptions object
// to decide which HTML elements the document will use to represent lists.
// Setting the "ExportListLabels" property to "ExportListLabels.AsInlineText"
// will create lists by formatting spans.
// Setting the "ExportListLabels" property to "ExportListLabels.Auto" will use the <p> tag
// to build lists in cases when using the <ol> and <li> tags may cause loss of formatting.
// Setting the "ExportListLabels" property to "ExportListLabels.ByHtmlTags"
// will use <ol> and <li> tags to build all lists.
auto options = MakeObject<HtmlSaveOptions>();
options->set_ExportListLabels(exportListLabels);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.List.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.List.html");
switch (exportListLabels)
{
ASSERT_TRUE(outDocContents.Contains(
String(u"<p style=\"margin-top:0pt; margin-left:72pt; margin-bottom:0pt; text-indent:-18pt; -aw-import:list-item; -aw-list-level-number:1; "
u"-aw-list-number-format:'%1.'; -aw-list-number-styles:'lowerLetter'; -aw-list-number-values:'1'; -aw-list-padding-sml:9.67pt\">") +
u"<span style=\"-aw-import:ignore\">" + u"<span>a.</span>" +
u"<span style=\"width:9.67pt; font:7pt 'Times New Roman'; display:inline-block; -aw-import:spaces\">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; "
u"</span>" +
u"</span>" + u"<span>Default numbered list item 3.</span>" + u"</p>"));
ASSERT_TRUE(
outDocContents.Contains(String(u"<p style=\"margin-top:0pt; margin-left:43.2pt; margin-bottom:0pt; text-indent:-43.2pt; -aw-import:list-item; "
u"-aw-list-level-number:3; -aw-list-number-format:'%0.%1.%2.%3'; -aw-list-number-styles:'decimal decimal "
u"decimal decimal'; -aw-list-number-values:'2 1 1 1'; -aw-list-padding-sml:10.2pt\">") +
u"<span style=\"-aw-import:ignore\">" + u"<span>2.1.1.1</span>" +
u"<span style=\"width:10.2pt; font:7pt 'Times New Roman'; display:inline-block; "
u"-aw-import:spaces\">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span>" +
u"</span>" + u"<span>Outline legal heading list item 5.</span>" + u"</p>"));
break;
ASSERT_TRUE(outDocContents.Contains(String(u"<ol type=\"a\" style=\"margin-right:0pt; margin-left:0pt; padding-left:0pt\">") +
u"<li style=\"margin-left:31.33pt; padding-left:4.67pt\">" + u"<span>Default numbered list item 3.</span>" +
u"</li>" + u"</ol>"));
ASSERT_TRUE(outDocContents.Contains(
String(
u"<p style=\"margin-top:0pt; margin-left:43.2pt; margin-bottom:0pt; text-indent:-43.2pt; -aw-import:list-item; -aw-list-level-number:3; ") +
u"-aw-list-number-format:'%0.%1.%2.%3'; -aw-list-number-styles:'decimal decimal decimal decimal'; " +
u"-aw-list-number-values:'2 1 1 1'; -aw-list-padding-sml:10.2pt\">" + u"<span style=\"-aw-import:ignore\">" + u"<span>2.1.1.1</span>" +
u"<span style=\"width:10.2pt; font:7pt 'Times New Roman'; display:inline-block; -aw-import:spaces\">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; "
u"</span>" +
u"</span>" + u"<span>Outline legal heading list item 5.</span>" + u"</p>"));
break;
ASSERT_TRUE(outDocContents.Contains(String(u"<ol type=\"a\" style=\"margin-right:0pt; margin-left:0pt; padding-left:0pt\">") +
u"<li style=\"margin-left:31.33pt; padding-left:4.67pt\">" + u"<span>Default numbered list item 3.</span>" +
u"</li>" + u"</ol>"));
ASSERT_TRUE(outDocContents.Contains(String(u"<ol type=\"1\" class=\"awlist3\" style=\"margin-right:0pt; margin-left:0pt; padding-left:0pt\">") +
u"<li style=\"margin-left:7.2pt; text-indent:-43.2pt; -aw-list-padding-sml:10.2pt\">" +
u"<span style=\"width:10.2pt; font:7pt 'Times New Roman'; display:inline-block; "
u"-aw-import:ignore\">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span>" +
u"<span>Outline legal heading list item 5.</span>" + u"</li>" + u"</ol>"));
break;
}
Enumerator
Auto 

Outputs list labels in auto mode. Uses HTML native elements when possible.

AsInlineText 

Outputs all list labels as inline text.

ByHtmlTags 

Outputs all list labels as HTML native elements.

◆ HeaderFooterBookmarksExportMode

Specifies how bookmarks in headers/footers are exported.

Examples

Shows to process bookmarks in headers/footers in a document that we are rendering to PDF.

auto doc = MakeObject<Document>(MyDir + u"Bookmarks in headers and footers.docx");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto saveOptions = MakeObject<PdfSaveOptions>();
// Set the "PageMode" property to "PdfPageMode.UseOutlines" to display the outline navigation pane in the output PDF.
saveOptions->set_PageMode(PdfPageMode::UseOutlines);
// Set the "DefaultBookmarksOutlineLevel" property to "1" to display all
// bookmarks at the first level of the outline in the output PDF.
saveOptions->get_OutlineOptions()->set_DefaultBookmarksOutlineLevel(1);
// Set the "HeaderFooterBookmarksExportMode" property to "HeaderFooterBookmarksExportMode.None" to
// not export any bookmarks that are inside headers/footers.
// Set the "HeaderFooterBookmarksExportMode" property to "HeaderFooterBookmarksExportMode.First" to
// only export bookmarks in the first section's header/footers.
// Set the "HeaderFooterBookmarksExportMode" property to "HeaderFooterBookmarksExportMode.All" to
// export bookmarks that are in all headers/footers.
saveOptions->set_HeaderFooterBookmarksExportMode(headerFooterBookmarksExportMode);
doc->Save(ArtifactsDir + u"PdfSaveOptions.HeaderFooterBookmarksExportMode.pdf", saveOptions);
Enumerator
None 

Bookmarks in headers/footers are not exported.

First 

Only bookmark in first header/footer of the section is exported.

All 

Bookmarks in all headers/footers are exported.

◆ HtmlElementSizeOutputMode

Specifies how Aspose.Words exports element widths and heights to HTML, MHTML and EPUB.

See also
Aspose::Words::Saving::HtmlSaveOptions::get_TableWidthOutputMode
Examples

Shows how to preserve negative indents in the output .html.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a table with a negative indent, which will push it to the left past the left page boundary.
SharedPtr<Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Row 1, Cell 1");
builder->InsertCell();
builder->Write(u"Row 1, Cell 2");
builder->EndTable();
table->set_LeftIndent(-36);
table->set_PreferredWidth(PreferredWidth::FromPoints(144));
builder->InsertBreak(BreakType::ParagraphBreak);
// Insert a table with a positive indent, which will push the table to the right.
table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Row 1, Cell 1");
builder->InsertCell();
builder->Write(u"Row 1, Cell 2");
builder->EndTable();
table->set_LeftIndent(36);
table->set_PreferredWidth(PreferredWidth::FromPoints(144));
// When we save a document to HTML, Aspose.Words will only preserve negative indents
// such as the one we have applied to the first table if we set the "AllowNegativeIndent" flag
// in a SaveOptions object that we will pass to "true".
auto options = MakeObject<HtmlSaveOptions>(SaveFormat::Html);
options->set_AllowNegativeIndent(allowNegativeIndent);
options->set_TableWidthOutputMode(HtmlElementSizeOutputMode::RelativeOnly);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.NegativeIndent.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.NegativeIndent.html");
if (allowNegativeIndent)
{
ASSERT_TRUE(outDocContents.Contains(
u"<table cellspacing=\"0\" cellpadding=\"0\" style=\"margin-left:-41.65pt; border:0.75pt solid #000000; -aw-border:0.5pt single; "
u"-aw-border-insideh:0.5pt single #000000; -aw-border-insidev:0.5pt single #000000; border-collapse:collapse\">"));
ASSERT_TRUE(outDocContents.Contains(
u"<table cellspacing=\"0\" cellpadding=\"0\" style=\"margin-left:30.35pt; border:0.75pt solid #000000; -aw-border:0.5pt single; "
u"-aw-border-insideh:0.5pt single #000000; -aw-border-insidev:0.5pt single #000000; border-collapse:collapse\">"));
}
else
{
ASSERT_TRUE(
outDocContents.Contains(u"<table cellspacing=\"0\" cellpadding=\"0\" style=\"border:0.75pt solid #000000; -aw-border:0.5pt single; "
u"-aw-border-insideh:0.5pt single #000000; -aw-border-insidev:0.5pt single #000000; border-collapse:collapse\">"));
ASSERT_TRUE(outDocContents.Contains(
u"<table cellspacing=\"0\" cellpadding=\"0\" style=\"margin-left:30.35pt; border:0.75pt solid #000000; -aw-border:0.5pt single; "
u"-aw-border-insideh:0.5pt single #000000; -aw-border-insidev:0.5pt single #000000; border-collapse:collapse\">"));
}
Enumerator
All 

All element sizes, both in absolute and relative units, specified in the document are exported.

RelativeOnly 

Element sizes are exported only if they are specified in relative units in the document. Fixed sizes are not exported in this mode. Visual agents will calculate missing sizes to make document layout more natural.

None 

Element sizes are not exported. Visual agents will build layout automatically according to relationship between elements.

◆ HtmlFixedPageHorizontalAlignment

Specifies the horizontal alignment for pages in output HTML document.

Examples

Shows how to set the horizontal alignment of pages when saving a document to HTML.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto htmlFixedSaveOptions = MakeObject<HtmlFixedSaveOptions>();
htmlFixedSaveOptions->set_PageHorizontalAlignment(pageHorizontalAlignment);
doc->Save(ArtifactsDir + u"HtmlFixedSaveOptions.HorizontalAlignment.html", htmlFixedSaveOptions);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlFixedSaveOptions.HorizontalAlignment/styles.css");
switch (pageHorizontalAlignment)
{
outDocContents, u"[.]awpage { position:relative; border:solid 1pt black; margin:10pt auto 10pt auto; overflow:hidden; }")
->get_Success());
break;
outDocContents, u"[.]awpage { position:relative; border:solid 1pt black; margin:10pt auto 10pt 10pt; overflow:hidden; }")
->get_Success());
break;
outDocContents, u"[.]awpage { position:relative; border:solid 1pt black; margin:10pt 10pt 10pt auto; overflow:hidden; }")
->get_Success());
break;
}
Enumerator
Left 

Align pages to the left.

Center 

Center pages. This is the default value.

Right 

Align pages to the right.

◆ HtmlMetafileFormat

Indicates the format in which metafiles are saved to HTML documents.

Examples

Shows how to convert SVG objects to a different format when saving HTML documents.

String html =
u"<html>\r\n <svg xmlns='http://www.w3.org/2000/svg' width='500' height='40' viewBox='0 0 500 40'>\r\n "
u"<text x='0' y='35' font-family='Verdana' font-size='35'>Hello world!</text>\r\n </svg>\r\n </html>";
auto doc = MakeObject<Document>(MakeObject<System::IO::MemoryStream>(System::Text::Encoding::get_UTF8()->GetBytes(html)));
// This document contains a <svg> element in the form of text.
// When we save the document to HTML, we can pass a SaveOptions object
// to determine how the saving operation handles this object.
// Setting the "MetafileFormat" property to "HtmlMetafileFormat.Png" to convert it to a PNG image.
// Setting the "MetafileFormat" property to "HtmlMetafileFormat.Svg" preserve it as a SVG object.
// Setting the "MetafileFormat" property to "HtmlMetafileFormat.EmfOrWmf" to convert it to a metafile.
auto options = MakeObject<HtmlSaveOptions>();
options->set_MetafileFormat(htmlMetafileFormat);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.MetafileFormat.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.MetafileFormat.html");
switch (htmlMetafileFormat)
{
ASSERT_TRUE(outDocContents.Contains(
String(u"<p style=\"margin-top:0pt; margin-bottom:0pt\">") +
u"<img src=\"HtmlSaveOptions.MetafileFormat.001.png\" width=\"500\" height=\"40\" alt=\"\" " +
u"style=\"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\" />" + u"</p>"));
break;
ASSERT_TRUE(outDocContents.Contains(
String(u"<span style=\"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\">") +
u"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" width=\"499\" height=\"40\">"));
break;
ASSERT_TRUE(outDocContents.Contains(
String(u"<p style=\"margin-top:0pt; margin-bottom:0pt\">") +
u"<img src=\"HtmlSaveOptions.MetafileFormat.001.emf\" width=\"500\" height=\"40\" alt=\"\" " +
u"style=\"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\" />" + u"</p>"));
break;
}
Enumerator
Png 

Metafiles are rendered to raster PNG images.

Svg 

Metafiles are converted to vector SVG images.

EmfOrWmf 

Metafiles are saved as is, without conversion.

◆ HtmlOfficeMathOutputMode

Specifies how Aspose.Words exports OfficeMath to HTML, MHTML and EPUB.

Examples

Shows how to specify how to export Microsoft OfficeMath objects to HTML.

auto doc = MakeObject<Document>(MyDir + u"Office math.docx");
// When we save the document to HTML, we can pass a SaveOptions object
// to determine how the saving operation handles OfficeMath objects.
// Setting the "OfficeMathOutputMode" property to "HtmlOfficeMathOutputMode.Image"
// will render each OfficeMath object into an image.
// Setting the "OfficeMathOutputMode" property to "HtmlOfficeMathOutputMode.MathML"
// will convert each OfficeMath object into MathML.
// Setting the "OfficeMathOutputMode" property to "HtmlOfficeMathOutputMode.Text"
// will represent each OfficeMath formula using plain HTML text.
auto options = MakeObject<HtmlSaveOptions>();
options->set_OfficeMathOutputMode(htmlOfficeMathOutputMode);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.OfficeMathOutputMode.html", options);
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.OfficeMathOutputMode.html");
switch (htmlOfficeMathOutputMode)
{
ASSERT_TRUE(
outDocContents,
String(u"<p style=\"margin-top:0pt; margin-bottom:10pt\">") +
u"<img src=\"HtmlSaveOptions.OfficeMathOutputMode.001.png\" width=\"159\" height=\"19\" alt=\"\" style=\"vertical-align:middle; " +
u"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\" />" + u"</p>")
->get_Success());
break;
outDocContents, String(u"<p style=\"margin-top:0pt; margin-bottom:10pt; text-align:center\">") +
u"<math xmlns=\"http://www.w3.org/1998/Math/MathML\">" + u"<mi>i</mi>" + u"<mo>[+]</mo>" + u"<mi>b</mi>" +
u"<mo>-</mo>" + u"<mi>c</mi>" + u"<mo>≥</mo>" + u".*" + u"</math>" + u"</p>")
->get_Success());
break;
outDocContents, String(u"<p style=\\\"margin-top:0pt; margin-bottom:10pt; text-align:center\\\">") +
u"<span style=\\\"font-family:'Cambria Math'\\\">i[+]b-c≥iM[+]bM-cM </span>" + u"</p>")
->get_Success());
break;
}
Enumerator
Image 

OfficeMath is converted to HTML as image specified by <img> tag.

MathML 

OfficeMath is converted to HTML using MathML.

Text 

OfficeMath is converted to HTML as sequence of runs specified by <span> tags.

◆ HtmlVersion

Indicates the version of HTML is used when saving the document to Html and Mhtml formats.

Examples

Shows how to save a document to a specific version of HTML.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<HtmlSaveOptions>(SaveFormat::Html);
options->set_HtmlVersion(htmlVersion);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.HtmlVersions.html", options);
// Our HTML documents will have minor differences to be compatible with different HTML versions.
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.HtmlVersions.html");
switch (htmlVersion)
{
ASSERT_TRUE(outDocContents.Contains(u"<a id=\"_Toc76372689\"></a>"));
ASSERT_TRUE(outDocContents.Contains(u"<a id=\"_Toc76372689\"></a>"));
ASSERT_TRUE(outDocContents.Contains(
u"<table style=\"-aw-border-insideh:0.5pt single #000000; -aw-border-insidev:0.5pt single #000000; border-collapse:collapse\">"));
break;
ASSERT_TRUE(outDocContents.Contains(u"<a name=\"_Toc76372689\"></a>"));
ASSERT_TRUE(outDocContents.Contains(u"<ul type=\"disc\" style=\"margin:0pt; padding-left:0pt\">"));
ASSERT_TRUE(outDocContents.Contains(u"<table cellspacing=\"0\" cellpadding=\"0\" style=\"-aw-border-insideh:0.5pt single #000000; "
u"-aw-border-insidev:0.5pt single #000000; border-collapse:collapse\""));
break;
}

Shows how to display a DOCTYPE heading when converting documents to the Xhtml 1.0 transitional standard.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
auto options = MakeObject<HtmlSaveOptions>(SaveFormat::Html);
options->set_HtmlVersion(HtmlVersion::Xhtml);
options->set_ExportXhtmlTransitional(showDoctypeDeclaration);
options->set_PrettyFormat(true);
doc->Save(ArtifactsDir + u"HtmlSaveOptions.ExportXhtmlTransitional.html", options);
// Our document will only contain a DOCTYPE declaration heading if we have set the "ExportXhtmlTransitional" flag to "true".
String outDocContents = System::IO::File::ReadAllText(ArtifactsDir + u"HtmlSaveOptions.ExportXhtmlTransitional.html");
if (showDoctypeDeclaration)
{
ASSERT_TRUE(outDocContents.Contains(String(u"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n") +
u"<!DOCTYPE html\r\nPUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\r\n "
u"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n" +
u"<html xmlns=\"http://www.w3.org/1999/xhtml\">"));
}
else
{
ASSERT_TRUE(outDocContents.Contains(u"<html>"));
}
Enumerator
Xhtml 

Saves the document in compliance with the XHTML 1.0 Transitional standard.

Aspose.Words aims to output XHTML according to the XHTML 1.0 Transitional standard, but the output will not always validate against the DTD. Some structures inside a Microsoft Word document are hard or impossible to map to a document that will validate against the XHTML schema. For example, XHTML does not allow nested lists (UL cannot be nested inside another UL element), but in Microsoft Word document multilevel lists occur quite often.

Html5 

Saves the document in compliance with the HTML 5 standard.

◆ ImageBinarizationMethod

Specifies the method used to binarize image.

Examples

Shows how to set the TIFF binarization error threshold when using the Floyd-Steinberg method to render a TIFF image.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_ParagraphFormat()->set_Style(doc->get_Styles()->idx_get(u"Heading 1"));
builder->Writeln(u"Hello world!");
builder->InsertImage(ImageDir + u"Logo.jpg");
// When we save the document as a TIFF, we can pass a SaveOptions object to
// adjust the dithering that Aspose.Words will apply when rendering this image.
// The default value of the "ThresholdForFloydSteinbergDithering" property is 128.
// Higher values tend to produce darker images.
auto options = MakeObject<ImageSaveOptions>(SaveFormat::Tiff);
options->set_TiffCompression(TiffCompression::Ccitt3);
options->set_TiffBinarizationMethod(ImageBinarizationMethod::FloydSteinbergDithering);
options->set_ThresholdForFloydSteinbergDithering(240);
doc->Save(ArtifactsDir + u"ImageSaveOptions.FloydSteinbergDithering.tiff", options);
Enumerator
Threshold 

Specifies threshold method.

FloydSteinbergDithering 

Specifies dithering using Floyd-Steinberg error diffusion method.

◆ ImageColorMode

Specifies the color mode for the generated images of document pages.

Examples

Shows how to set a color mode when rendering documents.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_ParagraphFormat()->set_Style(doc->get_Styles()->idx_get(u"Heading 1"));
builder->Writeln(u"Hello world!");
builder->InsertImage(ImageDir + u"Logo.jpg");
ASSERT_LT(20000, MakeObject<System::IO::FileInfo>(ImageDir + u"Logo.jpg")->get_Length());
// When we save the document as an image, we can pass a SaveOptions object to
// select a color mode for the image that the saving operation will generate.
// If we set the "ImageColorMode" property to "ImageColorMode.BlackAndWhite",
// the saving operation will apply grayscale color reduction while rendering the document.
// If we set the "ImageColorMode" property to "ImageColorMode.Grayscale",
// the saving operation will render the document into a monochrome image.
// If we set the "ImageColorMode" property to "None", the saving operation will apply the default method
// and preserve all the document's colors in the output image.
auto imageSaveOptions = MakeObject<ImageSaveOptions>(SaveFormat::Png);
imageSaveOptions->set_ImageColorMode(imageColorMode);
doc->Save(ArtifactsDir + u"ImageSaveOptions.ColorMode.png", imageSaveOptions);
Enumerator
None 

The pages of the document will be rendered as color images.

Grayscale 

The pages of the document will be rendered as grayscale images.

BlackAndWhite 

The pages of the document will be rendered as black and white images.

◆ ImagePixelFormat

Specifies the pixel format for the generated images of document pages.

Examples

Shows how to select a bit-per-pixel rate with which to render a document to an image.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_ParagraphFormat()->set_Style(doc->get_Styles()->idx_get(u"Heading 1"));
builder->Writeln(u"Hello world!");
builder->InsertImage(ImageDir + u"Logo.jpg");
ASSERT_LT(20000, MakeObject<System::IO::FileInfo>(ImageDir + u"Logo.jpg")->get_Length());
// When we save the document as an image, we can pass a SaveOptions object to
// select a pixel format for the image that the saving operation will generate.
// Various bit per pixel rates will affect the quality and file size of the generated image.
auto imageSaveOptions = MakeObject<ImageSaveOptions>(SaveFormat::Png);
imageSaveOptions->set_PixelFormat(imagePixelFormat);
// We can clone ImageSaveOptions instances.
ASPOSE_ASSERT_NE(imageSaveOptions, imageSaveOptions->Clone());
doc->Save(ArtifactsDir + u"ImageSaveOptions.PixelFormat.png", imageSaveOptions);
Enumerator
Format16BppRgb555 

16 bits per pixel, RGB.

Format16BppRgb565 

16 bits per pixel, RGB.

Format16BppArgb1555 

16 bits per pixel, ARGB.

Format24BppRgb 

24 bits per pixel, RGB.

Format32BppRgb 

32 bits per pixel, RGB.

Format32BppArgb 

32 bits per pixel, ARGB.

Format32BppPArgb 

32 bits per pixel, ARGB, premultiplied alpha.

Format48BppRgb 

48 bits per pixel, RGB.

Format64BppArgb 

64 bits per pixel, ARGB.

Format64BppPArgb 

64 bits per pixel, ARGB, premultiplied alpha.

Format1bppIndexed 

1 bit per pixel, Indexed.

◆ ImlRenderingMode

Specifies how ink (InkML) objects are rendered to fixed page formats.

Enumerator
Fallback 

If fall-back shape is available for ink (InkML) object, Aspose.Words renders fall-back shape instead of the InkML.

InkML 

Aspose.Words ignores fall-back shape of ink (InkML) object and renders InkML itself. This is the default mode.

◆ MetafileRenderingMode

Specifies how Aspose.Words should render WMF and EMF metafiles.

Examples

Shows added a fallback to bitmap rendering and changing type of warnings about unsupported metafile records.

void HandleBinaryRasterWarnings()
{
auto doc = MakeObject<Document>(MyDir + u"WMF with image.docx");
auto metafileRenderingOptions = MakeObject<MetafileRenderingOptions>();
// Set the "EmulateRasterOperations" property to "false" to fall back to bitmap when
// it encounters a metafile, which will require raster operations to render in the output PDF.
metafileRenderingOptions->set_EmulateRasterOperations(false);
// Set the "RenderingMode" property to "VectorWithFallback" to try to render every metafile using vector graphics.
metafileRenderingOptions->set_RenderingMode(MetafileRenderingMode::VectorWithFallback);
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF and applies the configuration
// in our MetafileRenderingOptions object to the saving operation.
auto saveOptions = MakeObject<PdfSaveOptions>();
saveOptions->set_MetafileRenderingOptions(metafileRenderingOptions);
auto callback = MakeObject<ExPdfSaveOptions::HandleDocumentWarnings>();
doc->set_WarningCallback(callback);
doc->Save(ArtifactsDir + u"PdfSaveOptions.HandleBinaryRasterWarnings.pdf", saveOptions);
ASSERT_EQ(1, callback->Warnings->get_Count());
ASSERT_EQ(u"'R2_XORPEN' binary raster operation is partly supported.", callback->Warnings->idx_get(0)->get_Description());
}
class HandleDocumentWarnings : public IWarningCallback
{
public:
SharedPtr<WarningInfoCollection> Warnings;
void Warning(SharedPtr<WarningInfo> info) override
{
if (info->get_WarningType() == WarningType::MinorFormattingLoss)
{
std::cout << (String(u"Unsupported operation: ") + info->get_Description()) << std::endl;
Warnings->Warning(info);
}
}
HandleDocumentWarnings() : Warnings(MakeObject<WarningInfoCollection>())
{
}
};
Enumerator
VectorWithFallback 

Aspose.Words tries to render a metafile as vector graphics. If Aspose.Words cannot correctly render some of the metafile records to vector graphics then Aspose.Words renders this metafile to a bitmap.

Vector 

Aspose.Words renders a metafile as vector graphics.

Bitmap 

Aspose.Words invokes GDI+ to render a metafile to a bitmap and then saves the bitmap to the output document.

◆ NumeralFormat

Indicates the symbol set that is used to represent numbers while rendering to fixed page formats.

Examples

Shows how to set the numeral format used when saving to PDF.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->get_Font()->set_LocaleId(MakeObject<System::Globalization::CultureInfo>(u"ar-AR")->get_LCID());
builder->Writeln(u"1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 50, 100");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto options = MakeObject<PdfSaveOptions>();
// Set the "NumeralFormat" property to "NumeralFormat.ArabicIndic" to
// use glyphs from the U+0660 to U+0669 range as numbers.
// Set the "NumeralFormat" property to "NumeralFormat.Context" to
// look up the locale to determine what number of glyphs to use.
// Set the "NumeralFormat" property to "NumeralFormat.EasternArabicIndic" to
// use glyphs from the U+06F0 to U+06F9 range as numbers.
// Set the "NumeralFormat" property to "NumeralFormat.European" to use european numerals.
// Set the "NumeralFormat" property to "NumeralFormat.System" to determine the symbol set from regional settings.
options->set_NumeralFormat(numeralFormat);
doc->Save(ArtifactsDir + u"PdfSaveOptions.SetNumeralFormat.pdf", options);
Enumerator
European 

European numerals: 0123456789.

ArabicIndic 

Numerals used in Arabic: ٠١٢٣٤٥٦٧٨٩. Unicode range U+0660 - u+0669.

EasternArabicIndic 

Numerals used in Persian and Urdu: Û°Û±Û²Û³Û´ÛµÛ¶Û·Û¸Û¹. Unicode range U+06F0 - u+06F9.

Context 

Symbol set is decided from context(locale and RTL property).

◆ OdtSaveMeasureUnit

Specified units of measure to apply to measurable document content such as shape, widths and other during saving.

Examples

Shows how to use different measurement units to define style parameters of a saved ODT document.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// When we export the document to .odt, we can use an OdtSaveOptions object to modify how we save the document.
// We can set the "MeasureUnit" property to "OdtSaveMeasureUnit.Centimeters"
// to define content such as style parameters using the metric system, which Open Office uses.
// We can set the "MeasureUnit" property to "OdtSaveMeasureUnit.Inches"
// to define content such as style parameters using the imperial system, which Microsoft Word uses.
auto saveOptions = MakeObject<OdtSaveOptions>();
saveOptions->set_MeasureUnit(odtSaveMeasureUnit);
doc->Save(ArtifactsDir + u"OdtSaveOptions.Odt11Schema.odt", saveOptions);
Enumerator
Centimeters 

Specifies that the document content is saved using centimeters.

Inches 

Specifies that the document content is saved using inches.

◆ OoxmlCompliance

Allows to specify which OOXML specification will be used when saving in the DOCX format.

Examples

Shows how to set an OOXML compliance specification for a saved document to adhere to.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// If we configure compatibility options to comply with Microsoft Word 2003,
// inserting an image will define its shape using VML.
doc->get_CompatibilityOptions()->OptimizeFor(MsWordVersion::Word2003);
builder->InsertImage(ImageDir + u"Transparent background logo.png");
ASSERT_EQ(ShapeMarkupLanguage::Vml, (System::DynamicCast<Shape>(doc->GetChild(NodeType::Shape, 0, true)))->get_MarkupLanguage());
// The "ISO/IEC 29500:2008" OOXML standard does not support VML shapes.
// If we set the "Compliance" property of the SaveOptions object to "OoxmlCompliance.Iso29500_2008_Strict",
// any document we save while passing this object will have to follow that standard.
auto saveOptions = MakeObject<OoxmlSaveOptions>();
saveOptions->set_Compliance(OoxmlCompliance::Iso29500_2008_Strict);
saveOptions->set_SaveFormat(SaveFormat::Docx);
doc->Save(ArtifactsDir + u"OoxmlSaveOptions.Iso29500Strict.docx", saveOptions);
// Our saved document defines the shape using DML to adhere to the "ISO/IEC 29500:2008" OOXML standard.
doc = MakeObject<Document>(ArtifactsDir + u"OoxmlSaveOptions.Iso29500Strict.docx");
ASSERT_EQ(ShapeMarkupLanguage::Dml, (System::DynamicCast<Shape>(doc->GetChild(NodeType::Shape, 0, true)))->get_MarkupLanguage());

Shows how to configure a list to restart numbering at each section.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
doc->get_Lists()->Add(ListTemplate::NumberDefault);
SharedPtr<Aspose::Words::Lists::List> list = doc->get_Lists()->idx_get(0);
list->set_IsRestartAtEachSection(restartListAtEachSection);
// The "IsRestartAtEachSection" property will only be applicable when
// the document's OOXML compliance level is to a standard that is newer than "OoxmlComplianceCore.Ecma376".
auto options = MakeObject<OoxmlSaveOptions>();
builder->get_ListFormat()->set_List(list);
builder->Writeln(u"List item 1");
builder->Writeln(u"List item 2");
builder->InsertBreak(BreakType::SectionBreakNewPage);
builder->Writeln(u"List item 3");
builder->Writeln(u"List item 4");
doc->Save(ArtifactsDir + u"OoxmlSaveOptions.RestartingDocumentList.docx", options);
doc = MakeObject<Document>(ArtifactsDir + u"OoxmlSaveOptions.RestartingDocumentList.docx");
ASPOSE_ASSERT_EQ(restartListAtEachSection, doc->get_Lists()->idx_get(0)->get_IsRestartAtEachSection());

Shows how to insert DML shapes into a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Below are two wrapping types that shapes may have.
// 1 - Floating:
builder->InsertShape(ShapeType::TopCornersRounded, RelativeHorizontalPosition::Page, 100, RelativeVerticalPosition::Page, 100, 50, 50, WrapType::None);
// 2 - Inline:
builder->InsertShape(ShapeType::DiagonalCornersRounded, 50, 50);
// If you need to create "non-primitive" shapes, such as SingleCornerSnipped, TopCornersSnipped, DiagonalCornersSnipped,
// TopCornersOneRoundedOneSnipped, SingleCornerRounded, TopCornersRounded, or DiagonalCornersRounded,
// then save the document with "Strict" or "Transitional" compliance, which allows saving shape as DML.
auto saveOptions = MakeObject<OoxmlSaveOptions>(SaveFormat::Docx);
saveOptions->set_Compliance(OoxmlCompliance::Iso29500_2008_Transitional);
doc->Save(ArtifactsDir + u"Shape.ShapeInsertion.docx", saveOptions);
Enumerator
Ecma376_2006 

ECMA-376 1st Edition, 2006.

Iso29500_2008_Transitional 

ISO/IEC 29500:2008 Transitional compliance level.

Iso29500_2008_Strict 

ISO/IEC 29500:2008 Strict compliance level.

◆ PdfCompliance

Specifies the PDF standards compliance level.

Examples

Shows how to set the PDF standards compliance level of saved PDF documents.

auto doc = MakeObject<Document>(MyDir + u"Images.docx");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto saveOptions = MakeObject<PdfSaveOptions>();
// Set the "Compliance" property to "PdfCompliance.PdfA1b" to comply with the "PDF/A-1b" standard,
// which aims to preserve the visual appearance of the document as Aspose.Words convert it to PDF.
// Set the "Compliance" property to "PdfCompliance.Pdf17" to comply with the "1.7" standard.
// Set the "Compliance" property to "PdfCompliance.PdfA1a" to comply with the "PDF/A-1a" standard,
// which complies with "PDF/A-1b" as well as preserving the document structure of the original document.
// This helps with making documents searchable but may significantly increase the size of already large documents.
saveOptions->set_Compliance(pdfCompliance);
doc->Save(ArtifactsDir + u"PdfSaveOptions.Compliance.pdf", saveOptions);
Enumerator
Pdf17 

The output file will comply with the PDF 1.7 standard.

Pdf15 
PdfA1a 

The output file will comply with the PDF/A-1a standard. This level includes all the requirements of PDF/A-1b and additionally requires that document structure be included (also known as being "tagged"), with the objective of ensuring that document content can be searched and repurposed.

PdfA1b 

The output file will comply with the PDF/A-1b standard. PDF/A-1b has the objective of ensuring reliable reproduction of the visual appearance of the document.

◆ PdfCustomPropertiesExport

Specifies the way CustomDocumentProperties are exported to PDF file.

Examples

Shows how to export custom properties while converting a document to PDF.

auto doc = MakeObject<Document>();
doc->get_CustomDocumentProperties()->Add(u"Company", String(u"My value"));
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto options = MakeObject<PdfSaveOptions>();
// Set the "CustomPropertiesExport" property to "PdfCustomPropertiesExport.None" to discard
// custom document properties as we save the document to .PDF.
// Set the "CustomPropertiesExport" property to "PdfCustomPropertiesExport.Standard"
// to preserve custom properties within the output PDF document.
// Set the "CustomPropertiesExport" property to "PdfCustomPropertiesExport.Metadata"
// to preserve custom properties in an XMP packet.
options->set_CustomPropertiesExport(pdfCustomPropertiesExportMode);
doc->Save(ArtifactsDir + u"PdfSaveOptions.CustomPropertiesExport.pdf", options);
Enumerator
None 

No custom properties are exported.

Standard 

Custom properties are exported as entries in /Info dictionary. Custom properties with the following names are not exported: "Title", "Author", "Subject", "Keywords", "Creator", "Producer", "CreationDate", "ModDate", "Trapped".

Metadata 

Custom properties are Metadata.

The namespace of exported properties in XMP packet is "custprops". Every property has an associated xml-element "custprops:Property1", "custprops:Property2" and so on. There is "rdf:Description" element inside property element. The description element has two elements "custprops:Name", containing custom property's name as a value of this xml-element, and "custprops:Value", containing custom property's value as value of this xml-element.

◆ PdfDigitalSignatureHashAlgorithm

Specifies a digital hash algorithm used by a digital signature.

Examples

Shows how to sign a generated PDF document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Contents of signed PDF.");
SharedPtr<CertificateHolder> certificateHolder = CertificateHolder::Create(MyDir + u"morzal.pfx", u"aw");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto options = MakeObject<PdfSaveOptions>();
// Configure the "DigitalSignatureDetails" object of the "SaveOptions" object to
// digitally sign the document as we render it with the "Save" method.
options->set_DigitalSignatureDetails(MakeObject<PdfDigitalSignatureDetails>(certificateHolder, u"Test Signing", u"My Office", signingTime));
options->get_DigitalSignatureDetails()->set_HashAlgorithm(PdfDigitalSignatureHashAlgorithm::Sha256);
ASSERT_EQ(u"Test Signing", options->get_DigitalSignatureDetails()->get_Reason());
ASSERT_EQ(u"My Office", options->get_DigitalSignatureDetails()->get_Location());
ASSERT_EQ(signingTime.ToUniversalTime(), options->get_DigitalSignatureDetails()->get_SignatureDate().ToUniversalTime());
doc->Save(ArtifactsDir + u"PdfSaveOptions.PdfDigitalSignature.pdf", options);
Enumerator
Sha1 

SHA-1 hash algorithm.

Sha256 

SHA-256 hash algorithm.

Sha384 

SHA-384 hash algorithm.

Sha512 

SHA-512 hash algorithm.

Md5 

SHA-1 hash algorithm.

◆ PdfEncryptionAlgorithm

Specifies the encryption algorithm to use for encrypting a PDF document.

Examples

Shows how to set permissions on a saved PDF document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
auto encryptionDetails = MakeObject<PdfEncryptionDetails>(u"password", String::Empty, PdfEncryptionAlgorithm::RC4_128);
// Start by disallowing all permissions.
encryptionDetails->set_Permissions(PdfPermissions::DisallowAll);
// Extend permissions to allow the editing of annotations.
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto saveOptions = MakeObject<PdfSaveOptions>();
// Enable encryption via the "EncryptionDetails" property.
saveOptions->set_EncryptionDetails(encryptionDetails);
// When we open this document, we will need to provide the password before accessing its contents.
doc->Save(ArtifactsDir + u"PdfSaveOptions.EncryptionPermissions.pdf", saveOptions);
Enumerator
RC4_40 

RC4 encryption, key length of 40 bits.

RC4_128 

RC4 encryption, key length of 128 bits.

◆ PdfFontEmbeddingMode

Specifies how Aspose.Words should embed fonts.

Examples

Shows how to set Aspose.Words to skip embedding Arial and Times New Roman fonts into a PDF document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// "Arial" is a standard font, and "Courier New" is a nonstandard font.
builder->get_Font()->set_Name(u"Arial");
builder->Writeln(u"Hello world!");
builder->get_Font()->set_Name(u"Courier New");
builder->Writeln(u"The quick brown fox jumps over the lazy dog.");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto options = MakeObject<PdfSaveOptions>();
// Set the "EmbedFullFonts" property to "true" to embed every glyph of every embedded font in the output PDF.
options->set_EmbedFullFonts(true);
// Set the "FontEmbeddingMode" property to "EmbedAll" to embed all fonts in the output PDF.
// Set the "FontEmbeddingMode" property to "EmbedNonstandard" to only allow nonstandard fonts' embedding in the output PDF.
// Set the "FontEmbeddingMode" property to "EmbedNone" to not embed any fonts in the output PDF.
options->set_FontEmbeddingMode(pdfFontEmbeddingMode);
doc->Save(ArtifactsDir + u"PdfSaveOptions.EmbedWindowsFonts.pdf", options);
switch (pdfFontEmbeddingMode)
{
ASSERT_LT(1000000, MakeObject<System::IO::FileInfo>(ArtifactsDir + u"PdfSaveOptions.EmbedWindowsFonts.pdf")->get_Length());
break;
ASSERT_LT(480000, MakeObject<System::IO::FileInfo>(ArtifactsDir + u"PdfSaveOptions.EmbedWindowsFonts.pdf")->get_Length());
break;
ASSERT_GE(4000, MakeObject<System::IO::FileInfo>(ArtifactsDir + u"PdfSaveOptions.EmbedWindowsFonts.pdf")->get_Length());
break;
}
Enumerator
EmbedAll 

Aspose.Words embeds all fonts.

EmbedNonstandard 

Aspose.Words embeds all fonts excepting standard Windows fonts Arial and Times New Roman. Only Arial and Times New Roman fonts are affected in this mode because MS Word doesn't embed only these fonts when saving document to PDF.

EmbedNone 

Aspose.Words do not embed any fonts.

◆ PdfImageColorSpaceExportMode

Specifies how the color space will be selected for the images in PDF document.

Examples

Shows how to set a different color space for images in a document as we export it to PDF.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Jpeg image:");
builder->InsertImage(ImageDir + u"Logo.jpg");
builder->InsertParagraph();
builder->Writeln(u"Png image:");
builder->InsertImage(ImageDir + u"Transparent background logo.png");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto pdfSaveOptions = MakeObject<PdfSaveOptions>();
// Set the "ImageColorSpaceExportMode" property to "PdfImageColorSpaceExportMode.Auto" to get Aspose.Words to
// automatically select the color space for images in the document that it converts to PDF.
// In most cases, the color space will be RGB.
// Set the "ImageColorSpaceExportMode" property to "PdfImageColorSpaceExportMode.SimpleCmyk"
// to use the CMYK color space for all images in the saved PDF.
// Aspose.Words will also apply Flate compression to all images and ignore the "ImageCompression" property's value.
pdfSaveOptions->set_ImageColorSpaceExportMode(pdfImageColorSpaceExportMode);
doc->Save(ArtifactsDir + u"PdfSaveOptions.ImageColorSpaceExportMode.pdf", pdfSaveOptions);
Enumerator
Auto 

Aspose.Words automatically selects the most appropriate color space for each image.

Most of the images are saved in RGB color space. Also Indexed and Grayscale color spaces may be used. CMYK color space is never used.

For some images the color space may be different on different platforms.

SimpleCmyk 

Aspose.Words coverts RGB images to CMYK color space using simple formula.

Images in RGB color space are converted to CMYK using formula: Black = minimum(1-Red,1-Green,1-Blue). Cyan = (1-Red-Black)/(1-Black). Magenta = (1-Green-Black)/(1-Black). Yellow = (1-Blue-Black)/(1-Black). RGB values are normalized - they are between 0 and 1.0.

◆ PdfImageCompression

Specifies the type of compression applied to images in the PDF file.

Examples

Shows how to specify a compression type for all images in a document that we are converting to PDF.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Jpeg image:");
builder->InsertImage(ImageDir + u"Logo.jpg");
builder->InsertParagraph();
builder->Writeln(u"Png image:");
builder->InsertImage(ImageDir + u"Transparent background logo.png");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto pdfSaveOptions = MakeObject<PdfSaveOptions>();
// Set the "ImageCompression" property to "PdfImageCompression.Auto" to use the
// "ImageCompression" property to control the quality of the Jpeg images that end up in the output PDF.
// Set the "ImageCompression" property to "PdfImageCompression.Jpeg" to use the
// "ImageCompression" property to control the quality of all images that end up in the output PDF.
pdfSaveOptions->set_ImageCompression(pdfImageCompression);
// Set the "JpegQuality" property to "10" to strengthen compression at the cost of image quality.
pdfSaveOptions->set_JpegQuality(10);
doc->Save(ArtifactsDir + u"PdfSaveOptions.ImageCompression.pdf", pdfSaveOptions);
Enumerator
Auto 

Automatically selects the most appropriate compression for each image.

Jpeg 

Jpeg compression. Does not support transparency.

◆ PdfPageMode

Specifies how the PDF document should be displayed when opened in the PDF reader.

Examples

Shows to process bookmarks in headers/footers in a document that we are rendering to PDF.

auto doc = MakeObject<Document>(MyDir + u"Bookmarks in headers and footers.docx");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto saveOptions = MakeObject<PdfSaveOptions>();
// Set the "PageMode" property to "PdfPageMode.UseOutlines" to display the outline navigation pane in the output PDF.
saveOptions->set_PageMode(PdfPageMode::UseOutlines);
// Set the "DefaultBookmarksOutlineLevel" property to "1" to display all
// bookmarks at the first level of the outline in the output PDF.
saveOptions->get_OutlineOptions()->set_DefaultBookmarksOutlineLevel(1);
// Set the "HeaderFooterBookmarksExportMode" property to "HeaderFooterBookmarksExportMode.None" to
// not export any bookmarks that are inside headers/footers.
// Set the "HeaderFooterBookmarksExportMode" property to "HeaderFooterBookmarksExportMode.First" to
// only export bookmarks in the first section's header/footers.
// Set the "HeaderFooterBookmarksExportMode" property to "HeaderFooterBookmarksExportMode.All" to
// export bookmarks that are in all headers/footers.
saveOptions->set_HeaderFooterBookmarksExportMode(headerFooterBookmarksExportMode);
doc->Save(ArtifactsDir + u"PdfSaveOptions.HeaderFooterBookmarksExportMode.pdf", saveOptions);

Shows how to set instructions for some PDF readers to follow when opening an output document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto options = MakeObject<PdfSaveOptions>();
// Set the "PageMode" property to "PdfPageMode.FullScreen" to get the PDF reader to open the saved
// document in full-screen mode, which takes over the monitor's display and has no controls visible.
// Set the "PageMode" property to "PdfPageMode.UseThumbs" to get the PDF reader to display a separate panel
// with a thumbnail for each page in the document.
// Set the "PageMode" property to "PdfPageMode.UseOC" to get the PDF reader to display a separate panel
// that allows us to work with any layers present in the document.
// Set the "PageMode" property to "PdfPageMode.UseOutlines" to get the PDF reader
// also to display the outline, if possible.
// Set the "PageMode" property to "PdfPageMode.UseNone" to get the PDF reader to display just the document itself.
options->set_PageMode(pageMode);
doc->Save(ArtifactsDir + u"PdfSaveOptions.PageMode.pdf", options);
Enumerator
UseNone 

Neither document outline nor thumbnail images are visible.

UseOutlines 

Document outline is visible. Note that if there're no outlines in the PDF document then outline navigation pane will not be visible anyway.

UseThumbs 

Thumbnail images are visible.

FullScreen 

Full-screen mode, with no menu bar, window controls, or any other window visible.

UseOC 

Optional content group panel is visible.

◆ PdfPermissions

Specifies the operations that are allowed to a user on an encrypted PDF document.

Examples

Shows how to set permissions on a saved PDF document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
auto encryptionDetails = MakeObject<PdfEncryptionDetails>(u"password", String::Empty, PdfEncryptionAlgorithm::RC4_128);
// Start by disallowing all permissions.
encryptionDetails->set_Permissions(PdfPermissions::DisallowAll);
// Extend permissions to allow the editing of annotations.
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto saveOptions = MakeObject<PdfSaveOptions>();
// Enable encryption via the "EncryptionDetails" property.
saveOptions->set_EncryptionDetails(encryptionDetails);
// When we open this document, we will need to provide the password before accessing its contents.
doc->Save(ArtifactsDir + u"PdfSaveOptions.EncryptionPermissions.pdf", saveOptions);
Enumerator
DisallowAll 

Disallows all operations on the PDF document. This is the default value.

AllowAll 

Allows all operations on the PDF document.

ContentCopy 

Allows copying or otherwise extracting text and graphics from the document, including extraction for accessibility purposes.

ContentCopyForAccessibility 

Allows extract text and graphics in support of accessibility to disabled users or for other purposes. When using RC4 40-bit encryption, this option is ignored and accessibility is allowed whenever ContentCopy is set.

ModifyContents 

Allows modifying the document’s contents.

ModifyAnnotations 

Allows adding or modifying text annotations. When using RC4 40-bit encryption, this option also allows filling in form fields.

FillIn 

Allows filling in forms and signing the document. When using RC4 40-bit encryption, this option is ignored and filling in form is allowed whenever ModifyAnnotations is set.

DocumentAssembly 

Allows assembling the document: inserting, rotating, or deleting pages and creating navigation elements such as bookmarks or thumbnail images. When using RC4 40-bit encryption, this option is ignored and document assembly is allowed when ModifyContents is set.

Printing 

Allows printing the document.

HighResolutionPrinting 

Allows printing the document to the highest resolution possible. When using RC4 40-bit encryption, this option is ignored and high resolution printing is allowed when Printing is set.

◆ PdfTextCompression

Specifies a type of compression applied to all content in the PDF file except images.

Examples

Shows how to apply text compression when saving a document to PDF.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
for (int i = 0; i < 100; i++)
{
builder->Writeln(String(u"Lorem ipsum dolor sit amet, consectetur adipiscing elit, ") +
u"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
}
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto options = MakeObject<PdfSaveOptions>();
// Set the "TextCompression" property to "PdfTextCompression.None" to not apply any
// compression to text when we save the document to PDF.
// Set the "TextCompression" property to "PdfTextCompression.Flate" to apply ZIP compression
// to text when we save the document to PDF. The larger the document, the bigger the impact that this will have.
options->set_TextCompression(pdfTextCompression);
doc->Save(ArtifactsDir + u"PdfSaveOptions.TextCompression.pdf", options);
Enumerator
None 

No compression.

Flate 

Flate (ZIP) compression.

◆ PdfZoomBehavior

Specifies the type of zoom applied to a PDF document when it is opened in a PDF viewer.

Examples

Shows how to set the default zooming that a reader applies when opening a rendered PDF document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Hello world!");
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
// Set the "ZoomBehavior" property to "PdfZoomBehavior.ZoomFactor" to get a PDF reader to
// apply a percentage-based zoom factor when we open the document with it.
// Set the "ZoomFactor" property to "25" to give the zoom factor a value of 25%.
auto options = MakeObject<PdfSaveOptions>();
options->set_ZoomBehavior(PdfZoomBehavior::ZoomFactor);
options->set_ZoomFactor(25);
// When we open this document using a reader such as Adobe Acrobat, we will see the document scaled at 1/4 of its actual size.
doc->Save(ArtifactsDir + u"PdfSaveOptions.ZoomBehaviour.pdf", options);
Enumerator
None 

How the document is displayed is left to the PDF viewer. Usually the viewer displays the document to fit page width.

ZoomFactor 

Displays the page using the specified zoom factor.

FitPage 

Displays the page so it visible entirely.

FitWidth 

Fits the width of the page.

FitHeight 

Fits the height of the page.

FitBox 

Fits the bounding box (rectangle containing all visible elements on the page).

◆ SvgTextOutputMode

Examples

Shows how to mimic the properties of images when converting a .docx document to .svg.

auto doc = MakeObject<Document>(MyDir + u"Document.docx");
// Configure the SvgSaveOptions object to save with no page borders or selectable text.
auto options = MakeObject<SvgSaveOptions>();
options->set_FitToViewPort(true);
options->set_ShowPageBorder(false);
options->set_TextOutputMode(SvgTextOutputMode::UsePlacedGlyphs);
doc->Save(ArtifactsDir + u"SvgSaveOptions.SaveLikeImage.svg", options);
Enumerator
UseSvgFonts 

SVG fonts are used to render text. Note, not all browsers support SVG fonts.

UseTargetMachineFonts 

Fonts installed on the target machine are used to render text. Note, if some of fonts used in the document are not available on the target machine, document can look differently.

UsePlacedGlyphs 

Text is rendered using curves. Note, text selection will not work if you use this option.

◆ TableContentAlignment

Allows to specify the alignment of the content of the table to be used when exporting into Markdown format.

Enumerator
Auto 

The alignment will be taken from the first paragraph in corresponding table column.

Left 

The content of tables will be aligned to the Left.

Center 

The content of tables will be aligned to the Center.

Right 

The content of tables will be aligned to the Right.

◆ TiffCompression

Specifies what type of compression to apply when saving page images into a TIFF file.

Examples

Shows how to select the compression scheme to apply to a document that we convert into a TIFF image.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->InsertImage(ImageDir + u"Logo.jpg");
// Create an "ImageSaveOptions" object which we can pass to the document's "Save" method
// to modify the way in which that method renders the document into an image.
auto options = MakeObject<ImageSaveOptions>(SaveFormat::Tiff);
// Set the "TiffCompression" property to "TiffCompression.None" to apply no compression while saving,
// which may result in a very large output file.
// Set the "TiffCompression" property to "TiffCompression.Rle" to apply RLE compression
// Set the "TiffCompression" property to "TiffCompression.Lzw" to apply LZW compression.
// Set the "TiffCompression" property to "TiffCompression.Ccitt3" to apply CCITT3 compression.
// Set the "TiffCompression" property to "TiffCompression.Ccitt4" to apply CCITT4 compression.
options->set_TiffCompression(tiffCompression);
doc->Save(ArtifactsDir + u"ImageSaveOptions.TiffImageCompression.tiff", options);
switch (tiffCompression)
{
ASSERT_LT(3000000, MakeObject<System::IO::FileInfo>(ArtifactsDir + u"ImageSaveOptions.TiffImageCompression.tiff")->get_Length());
break;
ASSERT_LT(600000, MakeObject<System::IO::FileInfo>(ArtifactsDir + u"ImageSaveOptions.TiffImageCompression.tiff")->get_Length());
break;
ASSERT_LT(200000, MakeObject<System::IO::FileInfo>(ArtifactsDir + u"ImageSaveOptions.TiffImageCompression.tiff")->get_Length());
break;
ASSERT_GE(90000, MakeObject<System::IO::FileInfo>(ArtifactsDir + u"ImageSaveOptions.TiffImageCompression.tiff")->get_Length());
break;
ASSERT_GE(20000, MakeObject<System::IO::FileInfo>(ArtifactsDir + u"ImageSaveOptions.TiffImageCompression.tiff")->get_Length());
break;
}
Enumerator
None 

Specifies no compression.

Rle 

Specifies the RLE compression scheme.

Lzw 

Specifies the LZW compression scheme. In Java emulated by Deflate (Zip) compression.

Ccitt3 

Specifies the CCITT3 compression scheme.

Ccitt4 

Specifies the CCITT4 compression scheme.

◆ TxtExportHeadersFootersMode

Specifies the way headers and footers are exported to plain text format.

Examples

Shows how to specify how to export headers and footers to plain text format.

auto doc = MakeObject<Document>();
// Insert even and primary headers/footers into the document.
// The primary header/footers will override the even headers/footers.
doc->get_FirstSection()->get_HeadersFooters()->Add(MakeObject<HeaderFooter>(doc, HeaderFooterType::HeaderEven));
doc->get_FirstSection()->get_HeadersFooters()->idx_get(HeaderFooterType::HeaderEven)->AppendParagraph(u"Even header");
doc->get_FirstSection()->get_HeadersFooters()->Add(MakeObject<HeaderFooter>(doc, HeaderFooterType::FooterEven));
doc->get_FirstSection()->get_HeadersFooters()->idx_get(HeaderFooterType::FooterEven)->AppendParagraph(u"Even footer");
doc->get_FirstSection()->get_HeadersFooters()->Add(MakeObject<HeaderFooter>(doc, HeaderFooterType::HeaderPrimary));
doc->get_FirstSection()->get_HeadersFooters()->idx_get(HeaderFooterType::HeaderPrimary)->AppendParagraph(u"Primary header");
doc->get_FirstSection()->get_HeadersFooters()->Add(MakeObject<HeaderFooter>(doc, HeaderFooterType::FooterPrimary));
doc->get_FirstSection()->get_HeadersFooters()->idx_get(HeaderFooterType::FooterPrimary)->AppendParagraph(u"Primary footer");
// Insert pages to display these headers and footers.
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Page 1");
builder->InsertBreak(BreakType::PageBreak);
builder->Writeln(u"Page 2");
builder->InsertBreak(BreakType::PageBreak);
builder->Write(u"Page 3");
// Create a "TxtSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we save the document to plaintext.
auto saveOptions = MakeObject<TxtSaveOptions>();
// Set the "ExportHeadersFootersMode" property to "TxtExportHeadersFootersMode.None"
// to not export any headers/footers.
// Set the "ExportHeadersFootersMode" property to "TxtExportHeadersFootersMode.PrimaryOnly"
// to only export primary headers/footers.
// Set the "ExportHeadersFootersMode" property to "TxtExportHeadersFootersMode.AllAtEnd"
// to place all headers and footers for all section bodies at the end of the document.
saveOptions->set_ExportHeadersFootersMode(txtExportHeadersFootersMode);
doc->Save(ArtifactsDir + u"TxtSaveOptions.ExportHeadersFooters.txt", saveOptions);
String docText = System::IO::File::ReadAllText(ArtifactsDir + u"TxtSaveOptions.ExportHeadersFooters.txt");
switch (txtExportHeadersFootersMode)
{
ASSERT_EQ(String(u"Page 1\r\n") + u"Page 2\r\n" + u"Page 3\r\n" + u"Even header\r\n\r\n" + u"Primary header\r\n\r\n" + u"Even footer\r\n\r\n" +
u"Primary footer\r\n\r\n",
docText);
break;
ASSERT_EQ(String(u"Primary header\r\n") + u"Page 1\r\n" + u"Page 2\r\n" + u"Page 3\r\n" + u"Primary footer\r\n", docText);
break;
ASSERT_EQ(String(u"Page 1\r\n") + u"Page 2\r\n" + u"Page 3\r\n", docText);
break;
}
Enumerator
None 

No headers and footers are exported.

PrimaryOnly 

Only primary headers and footers are exported at the beginning and end of each section.

It is hard to meaningfully output headers and footers to plain text because it is not paginated.

When this mode is used, only primary headers and footers are exported at the beginning and end of each section.

AllAtEnd 

All headers and footers are placed after all section bodies at the very end of a document.