Class DocSaveOptions

Class DocSaveOptions

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.Doc or Aspose.Words.SaveFormat.Dot format.

To learn more, visit the Specify Save Options documentation article.

public class DocSaveOptions : SaveOptions

Inheritance

object SaveOptions DocSaveOptions

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 set save options for older Microsoft Word formats.

Document doc = new Document();
                                                                          DocumentBuilder builder = new DocumentBuilder(doc);
                                                                          builder.Write("Hello world!");

                                                                          DocSaveOptions options = new DocSaveOptions(SaveFormat.Doc);

                                                                          // Set a password which will protect the loading of the document by Microsoft Word or Aspose.Words.
                                                                          // Note that this does not encrypt the contents of the document in any way.
                                                                          options.Password = "MyPassword";

                                                                          // If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
                                                                          options.SaveRoutingSlip = true;

                                                                          doc.Save(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc", options);

                                                                          // To be able to load the document,
                                                                          // we will need to apply the password we specified in the DocSaveOptions object in a LoadOptions object.
                                                                          Assert.Throws<IncorrectPasswordException>(() => doc = new Document(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc"));

                                                                          LoadOptions loadOptions = new LoadOptions("MyPassword");
                                                                          doc = new Document(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc", loadOptions);

                                                                          Assert.That(doc.GetText().Trim(), Is.EqualTo("Hello world!"));

Remarks

At the moment provides only the Aspose.Words.Saving.DocSaveOptions.SaveFormat property, but in the future will have other options added, such as an encryption password or digital signature settings.

Constructors

DocSaveOptions()

Initializes a new instance of this class that can be used to save a document in the Aspose.Words.SaveFormat.Doc format.

public DocSaveOptions()

Examples

Shows how to set save options for older Microsoft Word formats.

Document doc = new Document();
                                                                          DocumentBuilder builder = new DocumentBuilder(doc);
                                                                          builder.Write("Hello world!");

                                                                          DocSaveOptions options = new DocSaveOptions(SaveFormat.Doc);

                                                                          // Set a password which will protect the loading of the document by Microsoft Word or Aspose.Words.
                                                                          // Note that this does not encrypt the contents of the document in any way.
                                                                          options.Password = "MyPassword";

                                                                          // If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
                                                                          options.SaveRoutingSlip = true;

                                                                          doc.Save(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc", options);

                                                                          // To be able to load the document,
                                                                          // we will need to apply the password we specified in the DocSaveOptions object in a LoadOptions object.
                                                                          Assert.Throws<IncorrectPasswordException>(() => doc = new Document(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc"));

                                                                          LoadOptions loadOptions = new LoadOptions("MyPassword");
                                                                          doc = new Document(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc", loadOptions);

                                                                          Assert.That(doc.GetText().Trim(), Is.EqualTo("Hello world!"));

DocSaveOptions(SaveFormat)

Initializes a new instance of this class that can be used to save a document in the Aspose.Words.SaveFormat.Doc or Aspose.Words.SaveFormat.Dot format.

public DocSaveOptions(SaveFormat saveFormat)

Parameters

saveFormat SaveFormat

Can be Aspose.Words.SaveFormat.Doc or Aspose.Words.SaveFormat.Dot.

Examples

Shows how to set save options for older Microsoft Word formats.

Document doc = new Document();
                                                                          DocumentBuilder builder = new DocumentBuilder(doc);
                                                                          builder.Write("Hello world!");

                                                                          DocSaveOptions options = new DocSaveOptions(SaveFormat.Doc);

                                                                          // Set a password which will protect the loading of the document by Microsoft Word or Aspose.Words.
                                                                          // Note that this does not encrypt the contents of the document in any way.
                                                                          options.Password = "MyPassword";

                                                                          // If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
                                                                          options.SaveRoutingSlip = true;

                                                                          doc.Save(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc", options);

                                                                          // To be able to load the document,
                                                                          // we will need to apply the password we specified in the DocSaveOptions object in a LoadOptions object.
                                                                          Assert.Throws<IncorrectPasswordException>(() => doc = new Document(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc"));

                                                                          LoadOptions loadOptions = new LoadOptions("MyPassword");
                                                                          doc = new Document(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc", loadOptions);

                                                                          Assert.That(doc.GetText().Trim(), Is.EqualTo("Hello world!"));

Properties

AlwaysCompressMetafiles

When false, small metafiles are not compressed for performance reason. Default value is true, all metafiles are compressed regardless of its size.

public bool AlwaysCompressMetafiles { get; set; }

Property Value

bool

Examples

Shows how to change metafiles compression in a document while saving.

// Open a document that contains a Microsoft Equation 3.0 formula.
                                                                                Document doc = new Document(MyDir + "Microsoft equation object.docx");

                                                                                // When we save a document, smaller metafiles are not compressed for performance reasons.
                                                                                // We can set a flag in a SaveOptions object to compress every metafile when saving.
                                                                                // Some editors such as LibreOffice cannot read uncompressed metafiles.
                                                                                DocSaveOptions saveOptions = new DocSaveOptions();
                                                                                saveOptions.AlwaysCompressMetafiles = compressAllMetafiles;

                                                                                doc.Save(ArtifactsDir + "DocSaveOptions.AlwaysCompressMetafiles.docx", saveOptions);

DigitalSignatureDetails

Gets or sets Aspose.Words.Saving.DigitalSignatureDetails object used to sign a document.

public DigitalSignatureDetails DigitalSignatureDetails { get; set; }

Property Value

DigitalSignatureDetails

Password

Gets/sets a password to encrypt document using RC4 encryption method.

public string Password { get; set; }

Property Value

string

Examples

Shows how to set save options for older Microsoft Word formats.

Document doc = new Document();
                                                                          DocumentBuilder builder = new DocumentBuilder(doc);
                                                                          builder.Write("Hello world!");

                                                                          DocSaveOptions options = new DocSaveOptions(SaveFormat.Doc);

                                                                          // Set a password which will protect the loading of the document by Microsoft Word or Aspose.Words.
                                                                          // Note that this does not encrypt the contents of the document in any way.
                                                                          options.Password = "MyPassword";

                                                                          // If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
                                                                          options.SaveRoutingSlip = true;

                                                                          doc.Save(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc", options);

                                                                          // To be able to load the document,
                                                                          // we will need to apply the password we specified in the DocSaveOptions object in a LoadOptions object.
                                                                          Assert.Throws<IncorrectPasswordException>(() => doc = new Document(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc"));

                                                                          LoadOptions loadOptions = new LoadOptions("MyPassword");
                                                                          doc = new Document(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc", loadOptions);

                                                                          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.Doc or Aspose.Words.SaveFormat.Dot.

public override SaveFormat SaveFormat { get; set; }

Property Value

SaveFormat

Examples

Shows how to set save options for older Microsoft Word formats.

Document doc = new Document();
                                                                          DocumentBuilder builder = new DocumentBuilder(doc);
                                                                          builder.Write("Hello world!");

                                                                          DocSaveOptions options = new DocSaveOptions(SaveFormat.Doc);

                                                                          // Set a password which will protect the loading of the document by Microsoft Word or Aspose.Words.
                                                                          // Note that this does not encrypt the contents of the document in any way.
                                                                          options.Password = "MyPassword";

                                                                          // If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
                                                                          options.SaveRoutingSlip = true;

                                                                          doc.Save(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc", options);

                                                                          // To be able to load the document,
                                                                          // we will need to apply the password we specified in the DocSaveOptions object in a LoadOptions object.
                                                                          Assert.Throws<IncorrectPasswordException>(() => doc = new Document(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc"));

                                                                          LoadOptions loadOptions = new LoadOptions("MyPassword");
                                                                          doc = new Document(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc", loadOptions);

                                                                          Assert.That(doc.GetText().Trim(), Is.EqualTo("Hello world!"));

SavePictureBullet

When false, PictureBullet data is not saved to output document. Default value is true.

public bool SavePictureBullet { get; set; }

Property Value

bool

Examples

Shows how to omit PictureBullet data from the document when saving.

Document doc = new Document(MyDir + "Image bullet points.docx");
                                                                              // Some word processors, such as Microsoft Word 97, are incompatible with PictureBullet data.
                                                                              // By setting a flag in the SaveOptions object,
                                                                              // we can convert all image bullet points to ordinary bullet points while saving.
                                                                              DocSaveOptions saveOptions = new DocSaveOptions(SaveFormat.Doc);
                                                                              saveOptions.SavePictureBullet = false;

                                                                              doc.Save(ArtifactsDir + "DocSaveOptions.PictureBullets.doc", saveOptions);

Remarks

This option is provided for Word 97, which cannot work correctly with PictureBullet data. To remove PictureBullet data, set the option to "false".

SaveRoutingSlip

When false, RoutingSlip data is not saved to output document. Default value is true.

public bool SaveRoutingSlip { get; set; }

Property Value

bool

Examples

Shows how to set save options for older Microsoft Word formats.

Document doc = new Document();
                                                                          DocumentBuilder builder = new DocumentBuilder(doc);
                                                                          builder.Write("Hello world!");

                                                                          DocSaveOptions options = new DocSaveOptions(SaveFormat.Doc);

                                                                          // Set a password which will protect the loading of the document by Microsoft Word or Aspose.Words.
                                                                          // Note that this does not encrypt the contents of the document in any way.
                                                                          options.Password = "MyPassword";

                                                                          // If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
                                                                          options.SaveRoutingSlip = true;

                                                                          doc.Save(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc", options);

                                                                          // To be able to load the document,
                                                                          // we will need to apply the password we specified in the DocSaveOptions object in a LoadOptions object.
                                                                          Assert.Throws<IncorrectPasswordException>(() => doc = new Document(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc"));

                                                                          LoadOptions loadOptions = new LoadOptions("MyPassword");
                                                                          doc = new Document(ArtifactsDir + "DocSaveOptions.SaveAsDoc.doc", loadOptions);

                                                                          Assert.That(doc.GetText().Trim(), Is.EqualTo("Hello world!"));
 English