Aspose::Words::Saving::MetafileRenderingOptions Class Reference

Detailed Description

Allows to specify additional metafile rendering options.

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>())
{
}
};

#include <Aspose.Words.Cpp/Saving/MetafileRenderingOptions.h>

+ Inheritance diagram for Aspose::Words::Saving::MetafileRenderingOptions:

Public Member Functions

 MetafileRenderingOptions ()
 
EmfPlusDualRenderingMode get_EmfPlusDualRenderingMode () const
 Gets or sets a value determining how EMF+ Dual metafiles should be rendered. More...
 
bool get_EmulateRasterOperations () const
 Gets or sets a value determining whether or not the raster operations should be emulated. More...
 
MetafileRenderingMode get_RenderingMode () const
 Gets or sets a value determining how metafile images should be rendered. More...
 
bool get_ScaleWmfFontsToMetafileSize () const
 Gets or sets a value determining whether or not to scale fonts in WMF metafile according to metafile size on the page. More...
 
bool get_UseEmfEmbeddedToWmf () const
 Gets or sets a value determining how WMF metafiles with embedded EMF metafiles should be rendered. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_EmfPlusDualRenderingMode (EmfPlusDualRenderingMode value)
 Setter for get_EmfPlusDualRenderingMode. More...
 
void set_EmulateRasterOperations (bool value)
 Setter for get_EmulateRasterOperations. More...
 
void set_RenderingMode (MetafileRenderingMode value)
 Setter for get_RenderingMode. More...
 
void set_ScaleWmfFontsToMetafileSize (bool value)
 Setter for get_ScaleWmfFontsToMetafileSize. More...
 
void set_UseEmfEmbeddedToWmf (bool value)
 Setter for get_UseEmfEmbeddedToWmf. More...
 

Static Public Member Functions

static const TypeInfoType ()
 

Constructor & Destructor Documentation

◆ MetafileRenderingOptions()

Aspose::Words::Saving::MetafileRenderingOptions::MetafileRenderingOptions ( )

Member Function Documentation

◆ get_EmfPlusDualRenderingMode()

Aspose::Words::Saving::EmfPlusDualRenderingMode Aspose::Words::Saving::MetafileRenderingOptions::get_EmfPlusDualRenderingMode ( ) const

Gets or sets a value determining how EMF+ Dual metafiles should be rendered.

EMF+ Dual metafiles contains both EMF+ and EMF parts. MS Word and GDI+ always renders EMF+ part. Aspose.Words currently doesn't fully supports all EMF+ records and in some cases rendering result of EMF part looks better then rendering result of EMF+ part.

This option is used only when metafile is rendered as vector graphics. When metafile is rendered to bitmap, EMF+ part is always used.

The default value is EmfPlusWithFallback.

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);

◆ get_EmulateRasterOperations()

bool Aspose::Words::Saving::MetafileRenderingOptions::get_EmulateRasterOperations ( ) const

Gets or sets a value determining whether or not the raster operations should be emulated.

Specific raster operations could be used in metafiles. They can not be rendered directly to vector graphics. Emulating raster operations requires partial rasterization of the resulting vector graphics which may affect the metafile rendering performance.

When this value is set to true, Aspose.Words emulates the raster operations. The resulting output maybe partially rasterized and performance might be slower.

When this value is set to false, Aspose.Words does not emulate the raster operations. When Aspose.Words encounters a raster operation in a metafile it fallbacks to rendering the metafile into a bitmap by using the operating system.

This option is used only when metafile is rendered as vector graphics.

The default value is true.

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>())
{
}
};

◆ get_RenderingMode()

Aspose::Words::Saving::MetafileRenderingMode Aspose::Words::Saving::MetafileRenderingOptions::get_RenderingMode ( ) const

Gets or sets a value determining how metafile images should be rendered.

The default value depends on the save format. For images it is Bitmap. For other formats it is VectorWithFallback.

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>())
{
}
};

◆ get_ScaleWmfFontsToMetafileSize()

bool Aspose::Words::Saving::MetafileRenderingOptions::get_ScaleWmfFontsToMetafileSize ( ) const

Gets or sets a value determining whether or not to scale fonts in WMF metafile according to metafile size on the page.

When WMF metafiles are displayed in MS Word, fonts may be scaled according to actual metafile size on the page.

When this value is set to true, Aspose.Words emulates font scaling according to metafile size on the page.

When this value is set to false, Aspose.Words displays the fonts as metafile is rendered to its default size.

This option is used only when metafile is rendered as vector graphics.

The default value is true.

Examples

Shows how to WMF fonts scaling according to metafile size on the page.

auto doc = MakeObject<Document>(MyDir + u"WMF with text.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 "ScaleWmfFontsToMetafileSize" property to "true" to scale fonts
// that format text within WMF images according to the size of the metafile on the page.
// Set the "ScaleWmfFontsToMetafileSize" property to "false" to
// preserve the default scale of these fonts.
saveOptions->get_MetafileRenderingOptions()->set_ScaleWmfFontsToMetafileSize(scaleWmfFonts);
doc->Save(ArtifactsDir + u"PdfSaveOptions.FontsScaledToMetafileSize.pdf", saveOptions);

◆ get_UseEmfEmbeddedToWmf()

bool Aspose::Words::Saving::MetafileRenderingOptions::get_UseEmfEmbeddedToWmf ( ) const

Gets or sets a value determining how WMF metafiles with embedded EMF metafiles should be rendered.

WMF metafiles could contain embedded EMF data. MS Word in most cases uses embedded EMF data. GDI+ always uses WMF data.

When this value is set to true, Aspose.Words uses embedded EMF data when rendering.

When this value is set to false, Aspose.Words uses WMF data when rendering.

This option is used only when metafile is rendered as vector graphics. When metafile is rendered to bitmap, WMF data is always used.

The default value is true.

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);

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Saving::MetafileRenderingOptions::GetType ( ) const
overridevirtual

Reimplemented from System::Object.

◆ Is()

virtual bool Aspose::Words::Saving::MetafileRenderingOptions::Is ( const System::TypeInfo target) const
overridevirtual

Reimplemented from System::Object.

◆ set_EmfPlusDualRenderingMode()

void Aspose::Words::Saving::MetafileRenderingOptions::set_EmfPlusDualRenderingMode ( Aspose::Words::Saving::EmfPlusDualRenderingMode  value)

◆ set_EmulateRasterOperations()

void Aspose::Words::Saving::MetafileRenderingOptions::set_EmulateRasterOperations ( bool  value)

◆ set_RenderingMode()

void Aspose::Words::Saving::MetafileRenderingOptions::set_RenderingMode ( Aspose::Words::Saving::MetafileRenderingMode  value)

◆ set_ScaleWmfFontsToMetafileSize()

void Aspose::Words::Saving::MetafileRenderingOptions::set_ScaleWmfFontsToMetafileSize ( bool  value)

◆ set_UseEmfEmbeddedToWmf()

void Aspose::Words::Saving::MetafileRenderingOptions::set_UseEmfEmbeddedToWmf ( bool  value)

◆ Type()

static const System::TypeInfo& Aspose::Words::Saving::MetafileRenderingOptions::Type ( )
static