Class OdtSaveOptions
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.Odt or Aspose.Words.SaveFormat.Ott format.
To learn more, visit the Specify Save Options documentation article.
public class OdtSaveOptions : SaveOptionsInheritance
object ← SaveOptions ← OdtSaveOptions
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 make a saved document conform to an older ODT schema.
Document doc = new Document(MyDir + "Rendering.docx");
OdtSaveOptions saveOptions = new OdtSaveOptions
{
MeasureUnit = OdtSaveMeasureUnit.Centimeters,
IsStrictSchema11 = exportToOdt11Specs
};
doc.Save(ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt", saveOptions);
doc = new Document(ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt");
Assert.That(doc.LayoutOptions.RevisionOptions.MeasurementUnit, Is.EqualTo(Aspose.Words.MeasurementUnits.Centimeters));Shows how to use different measurement units to define style parameters of a saved ODT document.
Document doc = new Document(MyDir + "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.
OdtSaveOptions saveOptions = new OdtSaveOptions
{
MeasureUnit = odtSaveMeasureUnit
};
doc.Save(ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt", saveOptions);Remarks
At the moment provides only the Aspose.Words.Saving.OdtSaveOptions.SaveFormat property, but in the future will have other options added, such as an encryption password or digital signature settings.
Constructors
OdtSaveOptions()
Initializes a new instance of this class that can be used to save a document in the Aspose.Words.SaveFormat.Odt format.
public OdtSaveOptions()Examples
Shows how to make a saved document conform to an older ODT schema.
Document doc = new Document(MyDir + "Rendering.docx");
OdtSaveOptions saveOptions = new OdtSaveOptions
{
MeasureUnit = OdtSaveMeasureUnit.Centimeters,
IsStrictSchema11 = exportToOdt11Specs
};
doc.Save(ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt", saveOptions);
doc = new Document(ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt");
Assert.That(doc.LayoutOptions.RevisionOptions.MeasurementUnit, Is.EqualTo(Aspose.Words.MeasurementUnits.Centimeters));OdtSaveOptions(string)
Initializes a new instance of this class that can be used to save a document in the Aspose.Words.SaveFormat.Odt format encrypted with a password.
public OdtSaveOptions(string password)Parameters
password string
OdtSaveOptions(SaveFormat)
Initializes a new instance of this class that can be used to save a document in the Aspose.Words.SaveFormat.Odt or Aspose.Words.SaveFormat.Ott format.
public OdtSaveOptions(SaveFormat saveFormat)Parameters
saveFormat SaveFormat
Can be Aspose.Words.SaveFormat.Odt or Aspose.Words.SaveFormat.Ott.
Examples
Shows how to encrypt a saved ODT/OTT document with a password, and then load it using Aspose.Words.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Hello world!");
// Create a new OdtSaveOptions, and pass either "SaveFormat.Odt",
// or "SaveFormat.Ott" as the format to save the document in.
OdtSaveOptions saveOptions = new OdtSaveOptions(saveFormat);
saveOptions.Password = "@sposeEncrypted_1145";
string extensionString = FileFormatUtil.SaveFormatToExtension(saveFormat);
// If we open this document with an appropriate editor,
// it will prompt us for the password we specified in the SaveOptions object.
doc.Save(ArtifactsDir + "OdtSaveOptions.Encrypt" + extensionString, saveOptions);
FileFormatInfo docInfo = FileFormatUtil.DetectFileFormat(ArtifactsDir + "OdtSaveOptions.Encrypt" + extensionString);
Assert.That(docInfo.IsEncrypted, Is.True);
// If we wish to open or edit this document again using Aspose.Words,
// we will have to provide a LoadOptions object with the correct password to the loading constructor.
doc = new Document(ArtifactsDir + "OdtSaveOptions.Encrypt" + extensionString,
new LoadOptions("@sposeEncrypted_1145"));
Assert.That(doc.GetText().Trim(), Is.EqualTo("Hello world!"));Properties
DigitalSignatureDetails
Gets or sets Aspose.Words.Saving.DigitalSignatureDetails object used to sign a document.
public DigitalSignatureDetails DigitalSignatureDetails { get; set; }Property Value
IsStrictSchema11
Specifies whether export should correspond to ODT specification 1.1 strictly.
OOo 3.0 displays files correctly when they contain elements and attributes of ODT 1.2.
Use “false” for this purpose, or “true” for strict conformity of specification 1.1.
The default value is false.
public bool IsStrictSchema11 { get; set; }Property Value
Examples
Shows how to make a saved document conform to an older ODT schema.
Document doc = new Document(MyDir + "Rendering.docx");
OdtSaveOptions saveOptions = new OdtSaveOptions
{
MeasureUnit = OdtSaveMeasureUnit.Centimeters,
IsStrictSchema11 = exportToOdt11Specs
};
doc.Save(ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt", saveOptions);
doc = new Document(ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt");
Assert.That(doc.LayoutOptions.RevisionOptions.MeasurementUnit, Is.EqualTo(Aspose.Words.MeasurementUnits.Centimeters));MeasureUnit
Allows to specify units of measure to apply to document content. The default value is Aspose.Words.Saving.OdtSaveMeasureUnit.Centimeters
public OdtSaveMeasureUnit MeasureUnit { get; set; }Property Value
Examples
Shows how to make a saved document conform to an older ODT schema.
Document doc = new Document(MyDir + "Rendering.docx");
OdtSaveOptions saveOptions = new OdtSaveOptions
{
MeasureUnit = OdtSaveMeasureUnit.Centimeters,
IsStrictSchema11 = exportToOdt11Specs
};
doc.Save(ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt", saveOptions);
doc = new Document(ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt");
Assert.That(doc.LayoutOptions.RevisionOptions.MeasurementUnit, Is.EqualTo(Aspose.Words.MeasurementUnits.Centimeters));Shows how to use different measurement units to define style parameters of a saved ODT document.
Document doc = new Document(MyDir + "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.
OdtSaveOptions saveOptions = new OdtSaveOptions
{
MeasureUnit = odtSaveMeasureUnit
};
doc.Save(ArtifactsDir + "OdtSaveOptions.Odt11Schema.odt", saveOptions);Remarks
Open Office uses centimeters when specifying lengths, widths and other measurable formatting and content properties in documents whereas MS Office uses inches.
Password
Gets or sets a password to encrypt document.
public string Password { get; set; }Property Value
Examples
Shows how to encrypt a saved ODT/OTT document with a password, and then load it using Aspose.Words.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Hello world!");
// Create a new OdtSaveOptions, and pass either "SaveFormat.Odt",
// or "SaveFormat.Ott" as the format to save the document in.
OdtSaveOptions saveOptions = new OdtSaveOptions(saveFormat);
saveOptions.Password = "@sposeEncrypted_1145";
string extensionString = FileFormatUtil.SaveFormatToExtension(saveFormat);
// If we open this document with an appropriate editor,
// it will prompt us for the password we specified in the SaveOptions object.
doc.Save(ArtifactsDir + "OdtSaveOptions.Encrypt" + extensionString, saveOptions);
FileFormatInfo docInfo = FileFormatUtil.DetectFileFormat(ArtifactsDir + "OdtSaveOptions.Encrypt" + extensionString);
Assert.That(docInfo.IsEncrypted, Is.True);
// If we wish to open or edit this document again using Aspose.Words,
// we will have to provide a LoadOptions object with the correct password to the loading constructor.
doc = new Document(ArtifactsDir + "OdtSaveOptions.Encrypt" + extensionString,
new LoadOptions("@sposeEncrypted_1145"));
Assert.That(doc.GetText().Trim(), Is.EqualTo("Hello world!"));Remarks
In order to save document without encryption this property should be null or empty string.
SaveFormat
Specifies the format in which the document will be saved if this save options object is used. Can be Aspose.Words.SaveFormat.Odt or Aspose.Words.SaveFormat.Ott.
public override SaveFormat SaveFormat { get; set; }Property Value
Examples
Shows how to encrypt a saved ODT/OTT document with a password, and then load it using Aspose.Words.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Hello world!");
// Create a new OdtSaveOptions, and pass either "SaveFormat.Odt",
// or "SaveFormat.Ott" as the format to save the document in.
OdtSaveOptions saveOptions = new OdtSaveOptions(saveFormat);
saveOptions.Password = "@sposeEncrypted_1145";
string extensionString = FileFormatUtil.SaveFormatToExtension(saveFormat);
// If we open this document with an appropriate editor,
// it will prompt us for the password we specified in the SaveOptions object.
doc.Save(ArtifactsDir + "OdtSaveOptions.Encrypt" + extensionString, saveOptions);
FileFormatInfo docInfo = FileFormatUtil.DetectFileFormat(ArtifactsDir + "OdtSaveOptions.Encrypt" + extensionString);
Assert.That(docInfo.IsEncrypted, Is.True);
// If we wish to open or edit this document again using Aspose.Words,
// we will have to provide a LoadOptions object with the correct password to the loading constructor.
doc = new Document(ArtifactsDir + "OdtSaveOptions.Encrypt" + extensionString,
new LoadOptions("@sposeEncrypted_1145"));
Assert.That(doc.GetText().Trim(), Is.EqualTo("Hello world!"));