Class RtfSaveOptions
Namespace: Aspose.Words.Saving
Assembly: Aspose.Words.dll (25.12.0)
Can be used to specify additional options when saving a document into the Aspose.Words.SaveFormat.Rtf format.
To learn more, visit the Specify Save Options documentation article.
public class RtfSaveOptions : SaveOptionsInheritance
object ← SaveOptions ← RtfSaveOptions
Inherited Members
SaveOptions.CreateSaveOptions(SaveFormat) , SaveOptions.CreateSaveOptions(string) , SaveOptions.SaveFormat , SaveOptions.ExportGeneratorName , SaveOptions.TempFolder , SaveOptions.PrettyFormat , SaveOptions.UseAntiAliasing , SaveOptions.UseHighQualityRendering , SaveOptions.DmlRenderingMode , SaveOptions.DmlEffectsRenderingMode , SaveOptions.ImlRenderingMode , SaveOptions.DefaultTemplate , SaveOptions.UpdateFields , SaveOptions.UpdateLastSavedTimeProperty , SaveOptions.UpdateLastPrintedProperty , SaveOptions.UpdateCreatedTimeProperty , SaveOptions.MemoryOptimization , SaveOptions.UpdateAmbiguousTextFont , SaveOptions.Dml3DEffectsRenderingMode , SaveOptions.ProgressCallback , SaveOptions.AllowEmbeddingPostScriptFonts , SaveOptions.CustomTimeZoneInfo , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Shows how to save a document to .rtf with custom options.
Document doc = new Document(MyDir + "Rendering.docx");
// Create an "RtfSaveOptions" object to pass to the document's "Save" method to modify how we save it to an RTF.
RtfSaveOptions options = new RtfSaveOptions();
Assert.That(options.SaveFormat, Is.EqualTo(SaveFormat.Rtf));
// Set the "ExportCompactSize" property to "true" to
// reduce the saved document's size at the cost of right-to-left text compatibility.
options.ExportCompactSize = true;
// Set the "ExportImagesFotOldReaders" property to "true" to use extra keywords to ensure that our document is
// compatible with pre-Microsoft Word 97 readers and WordPad.
// Set the "ExportImagesFotOldReaders" property to "false" to reduce the size of the document,
// but prevent old readers from being able to read any non-metafile or BMP images that the document may contain.
options.ExportImagesForOldReaders = exportImagesForOldReaders;
doc.Save(ArtifactsDir + "RtfSaveOptions.ExportImages.rtf", options);Constructors
RtfSaveOptions()
public RtfSaveOptions()Properties
ExportCompactSize
Allows to make output RTF documents smaller in size, but if they contain RTL (right-to-left) text, it will not be displayed correctly.
Default value is false.
public bool ExportCompactSize { get; set; }Property Value
Examples
Shows how to save a document to .rtf with custom options.
Document doc = new Document(MyDir + "Rendering.docx");
// Create an "RtfSaveOptions" object to pass to the document's "Save" method to modify how we save it to an RTF.
RtfSaveOptions options = new RtfSaveOptions();
Assert.That(options.SaveFormat, Is.EqualTo(SaveFormat.Rtf));
// Set the "ExportCompactSize" property to "true" to
// reduce the saved document's size at the cost of right-to-left text compatibility.
options.ExportCompactSize = true;
// Set the "ExportImagesFotOldReaders" property to "true" to use extra keywords to ensure that our document is
// compatible with pre-Microsoft Word 97 readers and WordPad.
// Set the "ExportImagesFotOldReaders" property to "false" to reduce the size of the document,
// but prevent old readers from being able to read any non-metafile or BMP images that the document may contain.
options.ExportImagesForOldReaders = exportImagesForOldReaders;
doc.Save(ArtifactsDir + "RtfSaveOptions.ExportImages.rtf", options);Remarks
If the document that you want to convert to RTF using Aspose.Words does not contain
right-to-left text in languages like Arabic, then you can set this option to true
to reduce the size of the resulting RTF.
ExportImagesForOldReaders
Specifies whether the keywords for “old readers” are written to RTF or not. This can significantly affect the size of the RTF document.
Default value is true.
public bool ExportImagesForOldReaders { get; set; }Property Value
Examples
Shows how to save a document to .rtf with custom options.
Document doc = new Document(MyDir + "Rendering.docx");
// Create an "RtfSaveOptions" object to pass to the document's "Save" method to modify how we save it to an RTF.
RtfSaveOptions options = new RtfSaveOptions();
Assert.That(options.SaveFormat, Is.EqualTo(SaveFormat.Rtf));
// Set the "ExportCompactSize" property to "true" to
// reduce the saved document's size at the cost of right-to-left text compatibility.
options.ExportCompactSize = true;
// Set the "ExportImagesFotOldReaders" property to "true" to use extra keywords to ensure that our document is
// compatible with pre-Microsoft Word 97 readers and WordPad.
// Set the "ExportImagesFotOldReaders" property to "false" to reduce the size of the document,
// but prevent old readers from being able to read any non-metafile or BMP images that the document may contain.
options.ExportImagesForOldReaders = exportImagesForOldReaders;
doc.Save(ArtifactsDir + "RtfSaveOptions.ExportImages.rtf", options);Remarks
"Old readers" are pre-Microsoft Word 97 applications and also WordPad.
When this option is true Aspose.Words writes additional RTF keywords.
These keywords allow the document to be displayed correctly when opened in an
"old reader" application, but can significantly increase the size of the document.
If you set this option to false, then only images in WMF, EMF and BMP formats
will be displayed in "old readers".
SaveFormat
Specifies the format in which the document will be saved if this save options object is used. Can only be Aspose.Words.SaveFormat.Rtf.
public override SaveFormat SaveFormat { get; set; }Property Value
Examples
Shows how to save a document to .rtf with custom options.
Document doc = new Document(MyDir + "Rendering.docx");
// Create an "RtfSaveOptions" object to pass to the document's "Save" method to modify how we save it to an RTF.
RtfSaveOptions options = new RtfSaveOptions();
Assert.That(options.SaveFormat, Is.EqualTo(SaveFormat.Rtf));
// Set the "ExportCompactSize" property to "true" to
// reduce the saved document's size at the cost of right-to-left text compatibility.
options.ExportCompactSize = true;
// Set the "ExportImagesFotOldReaders" property to "true" to use extra keywords to ensure that our document is
// compatible with pre-Microsoft Word 97 readers and WordPad.
// Set the "ExportImagesFotOldReaders" property to "false" to reduce the size of the document,
// but prevent old readers from being able to read any non-metafile or BMP images that the document may contain.
options.ExportImagesForOldReaders = exportImagesForOldReaders;
doc.Save(ArtifactsDir + "RtfSaveOptions.ExportImages.rtf", options);SaveImagesAsWmf
When true all images will be saved as WMF.
public bool SaveImagesAsWmf { get; set; }Property Value
Examples
Shows how to convert all images in a document to the Windows Metafile format as we save the document as an RTF.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Jpeg image:");
Shape imageShape = builder.InsertImage(ImageDir + "Logo.jpg");
Assert.That(imageShape.ImageData.ImageType, Is.EqualTo(ImageType.Jpeg));
builder.InsertParagraph();
builder.Writeln("Png image:");
imageShape = builder.InsertImage(ImageDir + "Transparent background logo.png");
Assert.That(imageShape.ImageData.ImageType, Is.EqualTo(ImageType.Png));
// Create an "RtfSaveOptions" object to pass to the document's "Save" method to modify how we save it to an RTF.
RtfSaveOptions rtfSaveOptions = new RtfSaveOptions();
// Set the "SaveImagesAsWmf" property to "true" to convert all images in the document to WMF as we save it to RTF.
// Doing so will help readers such as WordPad to read our document.
// Set the "SaveImagesAsWmf" property to "false" to preserve the original format of all images in the document
// as we save it to RTF. This will preserve the quality of the images at the cost of compatibility with older RTF readers.
rtfSaveOptions.SaveImagesAsWmf = saveImagesAsWmf;
doc.Save(ArtifactsDir + "RtfSaveOptions.SaveImagesAsWmf.rtf", rtfSaveOptions);
doc = new Document(ArtifactsDir + "RtfSaveOptions.SaveImagesAsWmf.rtf");
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
if (saveImagesAsWmf)
{
Assert.That(((Shape)shapes[0]).ImageData.ImageType, Is.EqualTo(ImageType.Wmf));
Assert.That(((Shape)shapes[1]).ImageData.ImageType, Is.EqualTo(ImageType.Wmf));
}
else
{
Assert.That(((Shape)shapes[0]).ImageData.ImageType, Is.EqualTo(ImageType.Jpeg));
Assert.That(((Shape)shapes[1]).ImageData.ImageType, Is.EqualTo(ImageType.Png));
}Remarks
This option might help to avoid WordPad warning messages.