public class DocSaveOptions extends SaveOptions
SaveFormat.DOC or SaveFormat.DOT format.
To learn more, visit the Specify Save Options documentation article.
Remarks:
At the moment provides only the getSaveFormat() / setSaveFormat(int) property, but in the future will have other options added, such as an encryption password or digital signature settings.
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.setPassword("MyPassword");
// If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
options.setSaveRoutingSlip(true);
doc.save(getArtifactsDir() + "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.assertThrows(IncorrectPasswordException.class, () -> new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc"));
LoadOptions loadOptions = new LoadOptions("MyPassword");
doc = new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc", loadOptions);
Assert.assertEquals("Hello world!", doc.getText().trim());
| Constructor and Description |
|---|
DocSaveOptions()
Initializes a new instance of this class that can be used to save a document in the
SaveFormat.DOC format. |
DocSaveOptions(int saveFormat)
Initializes a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
getAlwaysCompressMetafiles()
When
false, small metafiles are not compressed for performance reason. |
DigitalSignatureDetails |
getDigitalSignatureDetails()
Gets
DigitalSignatureDetails object used to sign a document. |
java.lang.String |
getPassword()
Gets/sets a password to encrypt document using RC4 encryption method.
|
int |
getSaveFormat()
Specifies the format in which the document will be saved if this save options object is used.
|
boolean |
getSavePictureBullet()
When
false, PictureBullet data is not saved to output document. |
boolean |
getSaveRoutingSlip()
When
false, RoutingSlip data is not saved to output document. |
void |
setAlwaysCompressMetafiles(boolean value)
When
false, small metafiles are not compressed for performance reason. |
void |
setDigitalSignatureDetails(DigitalSignatureDetails value)
Sets
DigitalSignatureDetails object used to sign a document. |
void |
setPassword(java.lang.String value)
Gets/sets a password to encrypt document using RC4 encryption method.
|
void |
setSaveFormat(int value)
Specifies the format in which the document will be saved if this save options object is used.
|
void |
setSavePictureBullet(boolean value)
When
false, PictureBullet data is not saved to output document. |
void |
setSaveRoutingSlip(boolean value)
When
false, RoutingSlip data is not saved to output document. |
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 DocSaveOptions()
SaveFormat.DOC format.
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.setPassword("MyPassword");
// If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
options.setSaveRoutingSlip(true);
doc.save(getArtifactsDir() + "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.assertThrows(IncorrectPasswordException.class, () -> new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc"));
LoadOptions loadOptions = new LoadOptions("MyPassword");
doc = new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc", loadOptions);
Assert.assertEquals("Hello world!", doc.getText().trim());
public DocSaveOptions(int saveFormat)
public int getSaveFormat()
SaveFormat.DOC or 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.setPassword("MyPassword");
// If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
options.setSaveRoutingSlip(true);
doc.save(getArtifactsDir() + "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.assertThrows(IncorrectPasswordException.class, () -> new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc"));
LoadOptions loadOptions = new LoadOptions("MyPassword");
doc = new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc", loadOptions);
Assert.assertEquals("Hello world!", doc.getText().trim());
getSaveFormat in class SaveOptionsint value. The returned value is one of SaveFormat constants.public void setSaveFormat(int value)
SaveFormat.DOC or 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.setPassword("MyPassword");
// If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
options.setSaveRoutingSlip(true);
doc.save(getArtifactsDir() + "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.assertThrows(IncorrectPasswordException.class, () -> new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc"));
LoadOptions loadOptions = new LoadOptions("MyPassword");
doc = new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc", loadOptions);
Assert.assertEquals("Hello world!", doc.getText().trim());
setSaveFormat in class SaveOptionsvalue - The corresponding int value. The value must be one of SaveFormat constants.public java.lang.String getPassword()
Remarks:
In order to save document without encryption this property should be null or empty 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.setPassword("MyPassword");
// If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
options.setSaveRoutingSlip(true);
doc.save(getArtifactsDir() + "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.assertThrows(IncorrectPasswordException.class, () -> new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc"));
LoadOptions loadOptions = new LoadOptions("MyPassword");
doc = new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc", loadOptions);
Assert.assertEquals("Hello world!", doc.getText().trim());
String value.public void setPassword(java.lang.String value)
Remarks:
In order to save document without encryption this property should be null or empty 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.setPassword("MyPassword");
// If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
options.setSaveRoutingSlip(true);
doc.save(getArtifactsDir() + "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.assertThrows(IncorrectPasswordException.class, () -> new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc"));
LoadOptions loadOptions = new LoadOptions("MyPassword");
doc = new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc", loadOptions);
Assert.assertEquals("Hello world!", doc.getText().trim());
value - The corresponding String value.public boolean getSaveRoutingSlip()
false, RoutingSlip data is not saved to output document. Default value is true.
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.setPassword("MyPassword");
// If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
options.setSaveRoutingSlip(true);
doc.save(getArtifactsDir() + "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.assertThrows(IncorrectPasswordException.class, () -> new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc"));
LoadOptions loadOptions = new LoadOptions("MyPassword");
doc = new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc", loadOptions);
Assert.assertEquals("Hello world!", doc.getText().trim());
boolean value.public void setSaveRoutingSlip(boolean value)
false, RoutingSlip data is not saved to output document. Default value is true.
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.setPassword("MyPassword");
// If the document contains a routing slip, we can preserve it while saving by setting this flag to true.
options.setSaveRoutingSlip(true);
doc.save(getArtifactsDir() + "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.assertThrows(IncorrectPasswordException.class, () -> new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc"));
LoadOptions loadOptions = new LoadOptions("MyPassword");
doc = new Document(getArtifactsDir() + "DocSaveOptions.SaveAsDoc.doc", loadOptions);
Assert.assertEquals("Hello world!", doc.getText().trim());
value - The corresponding boolean value.public boolean getAlwaysCompressMetafiles()
false, small metafiles are not compressed for performance reason. Default value is true, all metafiles are compressed regardless of its size.
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(getMyDir() + "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.setAlwaysCompressMetafiles(compressAllMetafiles);
doc.save(getArtifactsDir() + "DocSaveOptions.AlwaysCompressMetafiles.docx", saveOptions);
boolean value.public void setAlwaysCompressMetafiles(boolean value)
false, small metafiles are not compressed for performance reason. Default value is true, all metafiles are compressed regardless of its size.
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(getMyDir() + "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.setAlwaysCompressMetafiles(compressAllMetafiles);
doc.save(getArtifactsDir() + "DocSaveOptions.AlwaysCompressMetafiles.docx", saveOptions);
value - The corresponding boolean value.public boolean getSavePictureBullet()
false, PictureBullet data is not saved to output document. Default value is true.
Remarks:
This option is provided for Word 97, which cannot work correctly with PictureBullet data. To remove PictureBullet data, set the option to "false".
Examples:
Shows how to omit PictureBullet data from the document when saving.
Document doc = new Document(getMyDir() + "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.setSavePictureBullet(false);
doc.save(getArtifactsDir() + "DocSaveOptions.PictureBullets.doc", saveOptions);
boolean value.public void setSavePictureBullet(boolean value)
false, PictureBullet data is not saved to output document. Default value is true.
Remarks:
This option is provided for Word 97, which cannot work correctly with PictureBullet data. To remove PictureBullet data, set the option to "false".
Examples:
Shows how to omit PictureBullet data from the document when saving.
Document doc = new Document(getMyDir() + "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.setSavePictureBullet(false);
doc.save(getArtifactsDir() + "DocSaveOptions.PictureBullets.doc", saveOptions);
value - The corresponding boolean value.public DigitalSignatureDetails getDigitalSignatureDetails()
DigitalSignatureDetails object used to sign a document.DigitalSignatureDetails object used to sign a document.public void setDigitalSignatureDetails(DigitalSignatureDetails value)
DigitalSignatureDetails object used to sign a document.value - DigitalSignatureDetails object used to sign a document.