public class RtfSaveOptions extends SaveOptions
SaveFormat.RTF format.
To learn more, visit the Specify Save Options documentation article.
Examples:
Shows how to save a document to .rtf with custom options.
Document doc = new Document(getMyDir() + "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.assertEquals(SaveFormat.RTF, options.getSaveFormat());
// Set the "ExportCompactSize" property to "true" to
// reduce the saved document's size at the cost of right-to-left text compatibility.
options.setExportCompactSize(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.setExportImagesForOldReaders(exportImagesForOldReaders);
doc.save(getArtifactsDir() + "RtfSaveOptions.ExportImages.rtf", options);
| Modifier and Type | Method and Description |
|---|---|
boolean |
getExportCompactSize()
Allows to make output RTF documents smaller in size, but if they contain RTL (right-to-left) text, it will not be displayed correctly.
|
boolean |
getExportImagesForOldReaders()
Specifies whether the keywords for "old readers" are written to RTF or not.
|
int |
getSaveFormat()
Specifies the format in which the document will be saved if this save options object is used.
|
boolean |
getSaveImagesAsWmf()
When
true all images will be saved as WMF. |
void |
setExportCompactSize(boolean value)
Allows to make output RTF documents smaller in size, but if they contain RTL (right-to-left) text, it will not be displayed correctly.
|
void |
setExportImagesForOldReaders(boolean value)
Specifies whether the keywords for "old readers" are written to RTF or not.
|
void |
setSaveFormat(int value)
Specifies the format in which the document will be saved if this save options object is used.
|
void |
setSaveImagesAsWmf(boolean value)
When
true all images will be saved as WMF. |
createSaveOptions, createSaveOptions, getAllowEmbeddingPostScriptFonts, getCustomTimeZoneInfo, getDefaultTemplate, getDml3DEffectsRenderingMode, getDmlEffectsRenderingMode, getDmlRenderingMode, getExportGeneratorName, getImlRenderingMode, getMemoryOptimization, getPrettyFormat, getProgressCallback, getTempFolder, getUpdateAmbiguousTextFont, getUpdateCreatedTimeProperty, getUpdateFields, getUpdateLastPrintedProperty, getUpdateLastSavedTimeProperty, getUseAntiAliasing, getUseHighQualityRendering, setAllowEmbeddingPostScriptFonts, setCustomTimeZoneInfo, setDefaultTemplate, setDml3DEffectsRenderingMode, setDmlEffectsRenderingMode, setDmlRenderingMode, setExportGeneratorName, setImlRenderingMode, setMemoryOptimization, setPrettyFormat, setProgressCallback, setTempFolder, setUpdateAmbiguousTextFont, setUpdateCreatedTimeProperty, setUpdateFields, setUpdateLastPrintedProperty, setUpdateLastSavedTimeProperty, setUseAntiAliasing, setUseHighQualityRenderingpublic int getSaveFormat()
SaveFormat.RTF.
Examples:
Shows how to save a document to .rtf with custom options.
Document doc = new Document(getMyDir() + "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.assertEquals(SaveFormat.RTF, options.getSaveFormat());
// Set the "ExportCompactSize" property to "true" to
// reduce the saved document's size at the cost of right-to-left text compatibility.
options.setExportCompactSize(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.setExportImagesForOldReaders(exportImagesForOldReaders);
doc.save(getArtifactsDir() + "RtfSaveOptions.ExportImages.rtf", options);
getSaveFormat in class SaveOptionsint value. The returned value is one of SaveFormat constants.public void setSaveFormat(int value)
SaveFormat.RTF.
Examples:
Shows how to save a document to .rtf with custom options.
Document doc = new Document(getMyDir() + "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.assertEquals(SaveFormat.RTF, options.getSaveFormat());
// Set the "ExportCompactSize" property to "true" to
// reduce the saved document's size at the cost of right-to-left text compatibility.
options.setExportCompactSize(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.setExportImagesForOldReaders(exportImagesForOldReaders);
doc.save(getArtifactsDir() + "RtfSaveOptions.ExportImages.rtf", options);
setSaveFormat in class SaveOptionsvalue - The corresponding int value. The value must be one of SaveFormat constants.public boolean getExportCompactSize()
false.
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.
Examples:
Shows how to save a document to .rtf with custom options.
Document doc = new Document(getMyDir() + "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.assertEquals(SaveFormat.RTF, options.getSaveFormat());
// Set the "ExportCompactSize" property to "true" to
// reduce the saved document's size at the cost of right-to-left text compatibility.
options.setExportCompactSize(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.setExportImagesForOldReaders(exportImagesForOldReaders);
doc.save(getArtifactsDir() + "RtfSaveOptions.ExportImages.rtf", options);
boolean value.public void setExportCompactSize(boolean value)
false.
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.
Examples:
Shows how to save a document to .rtf with custom options.
Document doc = new Document(getMyDir() + "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.assertEquals(SaveFormat.RTF, options.getSaveFormat());
// Set the "ExportCompactSize" property to "true" to
// reduce the saved document's size at the cost of right-to-left text compatibility.
options.setExportCompactSize(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.setExportImagesForOldReaders(exportImagesForOldReaders);
doc.save(getArtifactsDir() + "RtfSaveOptions.ExportImages.rtf", options);
value - The corresponding boolean value.public boolean getExportImagesForOldReaders()
true.
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".
Examples:
Shows how to save a document to .rtf with custom options.
Document doc = new Document(getMyDir() + "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.assertEquals(SaveFormat.RTF, options.getSaveFormat());
// Set the "ExportCompactSize" property to "true" to
// reduce the saved document's size at the cost of right-to-left text compatibility.
options.setExportCompactSize(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.setExportImagesForOldReaders(exportImagesForOldReaders);
doc.save(getArtifactsDir() + "RtfSaveOptions.ExportImages.rtf", options);
boolean value.public void setExportImagesForOldReaders(boolean value)
true.
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".
Examples:
Shows how to save a document to .rtf with custom options.
Document doc = new Document(getMyDir() + "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.assertEquals(SaveFormat.RTF, options.getSaveFormat());
// Set the "ExportCompactSize" property to "true" to
// reduce the saved document's size at the cost of right-to-left text compatibility.
options.setExportCompactSize(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.setExportImagesForOldReaders(exportImagesForOldReaders);
doc.save(getArtifactsDir() + "RtfSaveOptions.ExportImages.rtf", options);
value - The corresponding boolean value.public boolean getSaveImagesAsWmf()
true all images will be saved as WMF.
Remarks:
This option might help to avoid WordPad warning messages.
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(getImageDir() + "Logo.jpg");
Assert.assertEquals(ImageType.JPEG, imageShape.getImageData().getImageType());
builder.insertParagraph();
builder.writeln("Png image:");
imageShape = builder.insertImage(getImageDir() + "Transparent background logo.png");
Assert.assertEquals(ImageType.PNG, imageShape.getImageData().getImageType());
// 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.setSaveImagesAsWmf(saveImagesAsWmf);
doc.save(getArtifactsDir() + "RtfSaveOptions.SaveImagesAsWmf.rtf", rtfSaveOptions);
doc = new Document(getArtifactsDir() + "RtfSaveOptions.SaveImagesAsWmf.rtf");
NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
if (saveImagesAsWmf) {
Assert.assertEquals(ImageType.WMF, ((Shape) shapes.get(0)).getImageData().getImageType());
Assert.assertEquals(ImageType.WMF, ((Shape) shapes.get(1)).getImageData().getImageType());
} else {
Assert.assertEquals(ImageType.JPEG, ((Shape) shapes.get(0)).getImageData().getImageType());
Assert.assertEquals(ImageType.PNG, ((Shape) shapes.get(1)).getImageData().getImageType());
}
boolean value.public void setSaveImagesAsWmf(boolean value)
true all images will be saved as WMF.
Remarks:
This option might help to avoid WordPad warning messages.
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(getImageDir() + "Logo.jpg");
Assert.assertEquals(ImageType.JPEG, imageShape.getImageData().getImageType());
builder.insertParagraph();
builder.writeln("Png image:");
imageShape = builder.insertImage(getImageDir() + "Transparent background logo.png");
Assert.assertEquals(ImageType.PNG, imageShape.getImageData().getImageType());
// 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.setSaveImagesAsWmf(saveImagesAsWmf);
doc.save(getArtifactsDir() + "RtfSaveOptions.SaveImagesAsWmf.rtf", rtfSaveOptions);
doc = new Document(getArtifactsDir() + "RtfSaveOptions.SaveImagesAsWmf.rtf");
NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
if (saveImagesAsWmf) {
Assert.assertEquals(ImageType.WMF, ((Shape) shapes.get(0)).getImageData().getImageType());
Assert.assertEquals(ImageType.WMF, ((Shape) shapes.get(1)).getImageData().getImageType());
} else {
Assert.assertEquals(ImageType.JPEG, ((Shape) shapes.get(0)).getImageData().getImageType());
Assert.assertEquals(ImageType.PNG, ((Shape) shapes.get(1)).getImageData().getImageType());
}
value - The corresponding boolean value.