public class OoxmlSaveOptions extends SaveOptions
SaveFormat.DOCX, SaveFormat.DOCM, SaveFormat.DOTX, SaveFormat.DOTM or SaveFormat.FLAT_OPC format.
To learn more, visit the Specify Save Options documentation article.
Examples:
Shows how to set an OOXML compliance specification for a saved document to adhere to.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we configure compatibility options to comply with Microsoft Word 2003,
// inserting an image will define its shape using VML.
doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2003);
builder.insertImage(getImageDir() + "Transparent background logo.png");
Assert.assertEquals(ShapeMarkupLanguage.VML, ((Shape) doc.getChild(NodeType.SHAPE, 0, true)).getMarkupLanguage());
// The "ISO/IEC 29500:2008" OOXML standard does not support VML shapes.
// If we set the "Compliance" property of the SaveOptions object to "OoxmlCompliance.Iso29500_2008_Strict",
// any document we save while passing this object will have to follow that standard.
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.setCompliance(OoxmlCompliance.ISO_29500_2008_STRICT);
saveOptions.setSaveFormat(SaveFormat.DOCX);
doc.save(getArtifactsDir() + "OoxmlSaveOptions.Iso29500Strict.docx", saveOptions);
// Our saved document defines the shape using DML to adhere to the "ISO/IEC 29500:2008" OOXML standard.
doc = new Document(getArtifactsDir() + "OoxmlSaveOptions.Iso29500Strict.docx");
Assert.assertEquals(ShapeMarkupLanguage.DML, ((Shape) doc.getChild(NodeType.SHAPE, 0, true)).getMarkupLanguage());
| Constructor and Description |
|---|
OoxmlSaveOptions()
Initializes a new instance of this class that can be used to save a document in the
SaveFormat.DOCX format. |
OoxmlSaveOptions(int saveFormat)
Initializes a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getCompliance()
Specifies the OOXML version for the output document.
|
int |
getCompressionLevel()
Specifies the compression level used to save document.
|
DigitalSignatureDetails |
getDigitalSignatureDetails()
Gets
DigitalSignatureDetails object used to sign a document. |
boolean |
getKeepLegacyControlChars()
Keeps original representation of legacy control characters.
|
java.lang.String |
getPassword()
Gets/sets a password to encrypt document using ECMA376 Standard encryption algorithm.
|
int |
getSaveFormat()
Specifies the format in which the document will be saved if this save options object is used.
|
int |
getZip64Mode()
Specifies whether or not to use ZIP64 format extensions for the output document.
|
void |
setCompliance(int value)
Specifies the OOXML version for the output document.
|
void |
setCompressionLevel(int value)
Specifies the compression level used to save document.
|
void |
setDigitalSignatureDetails(DigitalSignatureDetails value)
Sets
DigitalSignatureDetails object used to sign a document. |
void |
setKeepLegacyControlChars(boolean value)
Keeps original representation of legacy control characters.
|
void |
setPassword(java.lang.String value)
Gets/sets a password to encrypt document using ECMA376 Standard encryption algorithm.
|
void |
setSaveFormat(int value)
Specifies the format in which the document will be saved if this save options object is used.
|
void |
setZip64Mode(int value)
Specifies whether or not to use ZIP64 format extensions for the 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 OoxmlSaveOptions()
SaveFormat.DOCX format.
Examples:
Shows how to set an OOXML compliance specification for a saved document to adhere to.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we configure compatibility options to comply with Microsoft Word 2003,
// inserting an image will define its shape using VML.
doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2003);
builder.insertImage(getImageDir() + "Transparent background logo.png");
Assert.assertEquals(ShapeMarkupLanguage.VML, ((Shape) doc.getChild(NodeType.SHAPE, 0, true)).getMarkupLanguage());
// The "ISO/IEC 29500:2008" OOXML standard does not support VML shapes.
// If we set the "Compliance" property of the SaveOptions object to "OoxmlCompliance.Iso29500_2008_Strict",
// any document we save while passing this object will have to follow that standard.
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.setCompliance(OoxmlCompliance.ISO_29500_2008_STRICT);
saveOptions.setSaveFormat(SaveFormat.DOCX);
doc.save(getArtifactsDir() + "OoxmlSaveOptions.Iso29500Strict.docx", saveOptions);
// Our saved document defines the shape using DML to adhere to the "ISO/IEC 29500:2008" OOXML standard.
doc = new Document(getArtifactsDir() + "OoxmlSaveOptions.Iso29500Strict.docx");
Assert.assertEquals(ShapeMarkupLanguage.DML, ((Shape) doc.getChild(NodeType.SHAPE, 0, true)).getMarkupLanguage());
public OoxmlSaveOptions(int saveFormat)
public int getSaveFormat()
SaveFormat.DOCX, SaveFormat.DOCM, SaveFormat.DOTX, SaveFormat.DOTM or SaveFormat.FLAT_OPC.
Examples:
Shows how to set an OOXML compliance specification for a saved document to adhere to.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we configure compatibility options to comply with Microsoft Word 2003,
// inserting an image will define its shape using VML.
doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2003);
builder.insertImage(getImageDir() + "Transparent background logo.png");
Assert.assertEquals(ShapeMarkupLanguage.VML, ((Shape) doc.getChild(NodeType.SHAPE, 0, true)).getMarkupLanguage());
// The "ISO/IEC 29500:2008" OOXML standard does not support VML shapes.
// If we set the "Compliance" property of the SaveOptions object to "OoxmlCompliance.Iso29500_2008_Strict",
// any document we save while passing this object will have to follow that standard.
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.setCompliance(OoxmlCompliance.ISO_29500_2008_STRICT);
saveOptions.setSaveFormat(SaveFormat.DOCX);
doc.save(getArtifactsDir() + "OoxmlSaveOptions.Iso29500Strict.docx", saveOptions);
// Our saved document defines the shape using DML to adhere to the "ISO/IEC 29500:2008" OOXML standard.
doc = new Document(getArtifactsDir() + "OoxmlSaveOptions.Iso29500Strict.docx");
Assert.assertEquals(ShapeMarkupLanguage.DML, ((Shape) doc.getChild(NodeType.SHAPE, 0, true)).getMarkupLanguage());
getSaveFormat in class SaveOptionsint value. The returned value is one of SaveFormat constants.public void setSaveFormat(int value)
SaveFormat.DOCX, SaveFormat.DOCM, SaveFormat.DOTX, SaveFormat.DOTM or SaveFormat.FLAT_OPC.
Examples:
Shows how to set an OOXML compliance specification for a saved document to adhere to.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we configure compatibility options to comply with Microsoft Word 2003,
// inserting an image will define its shape using VML.
doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2003);
builder.insertImage(getImageDir() + "Transparent background logo.png");
Assert.assertEquals(ShapeMarkupLanguage.VML, ((Shape) doc.getChild(NodeType.SHAPE, 0, true)).getMarkupLanguage());
// The "ISO/IEC 29500:2008" OOXML standard does not support VML shapes.
// If we set the "Compliance" property of the SaveOptions object to "OoxmlCompliance.Iso29500_2008_Strict",
// any document we save while passing this object will have to follow that standard.
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.setCompliance(OoxmlCompliance.ISO_29500_2008_STRICT);
saveOptions.setSaveFormat(SaveFormat.DOCX);
doc.save(getArtifactsDir() + "OoxmlSaveOptions.Iso29500Strict.docx", saveOptions);
// Our saved document defines the shape using DML to adhere to the "ISO/IEC 29500:2008" OOXML standard.
doc = new Document(getArtifactsDir() + "OoxmlSaveOptions.Iso29500Strict.docx");
Assert.assertEquals(ShapeMarkupLanguage.DML, ((Shape) doc.getChild(NodeType.SHAPE, 0, true)).getMarkupLanguage());
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 create a password encrypted Office Open XML document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("Hello world!");
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.setPassword("MyPassword");
doc.save(getArtifactsDir() + "OoxmlSaveOptions.Password.docx", saveOptions);
// We will not be able to open this document with Microsoft Word or
// Aspose.Words without providing the correct password.
Assert.assertThrows(IncorrectPasswordException.class, () -> new Document(getArtifactsDir() + "OoxmlSaveOptions.Password.docx"));
// Open the encrypted document by passing the correct password in a LoadOptions object.
doc = new Document(getArtifactsDir() + "OoxmlSaveOptions.Password.docx", new LoadOptions("MyPassword"));
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 create a password encrypted Office Open XML document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("Hello world!");
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.setPassword("MyPassword");
doc.save(getArtifactsDir() + "OoxmlSaveOptions.Password.docx", saveOptions);
// We will not be able to open this document with Microsoft Word or
// Aspose.Words without providing the correct password.
Assert.assertThrows(IncorrectPasswordException.class, () -> new Document(getArtifactsDir() + "OoxmlSaveOptions.Password.docx"));
// Open the encrypted document by passing the correct password in a LoadOptions object.
doc = new Document(getArtifactsDir() + "OoxmlSaveOptions.Password.docx", new LoadOptions("MyPassword"));
Assert.assertEquals("Hello world!", doc.getText().trim());
value - The corresponding String value.public int getCompliance()
OoxmlCompliance.ECMA_376_2006.
Examples:
Shows how to insert DML shapes into a document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Below are two wrapping types that shapes may have.
// 1 - Floating:
builder.insertShape(ShapeType.TOP_CORNERS_ROUNDED, RelativeHorizontalPosition.PAGE, 100.0,
RelativeVerticalPosition.PAGE, 100.0, 50.0, 50.0, WrapType.NONE);
// 2 - Inline:
builder.insertShape(ShapeType.DIAGONAL_CORNERS_ROUNDED, 50.0, 50.0);
// If you need to create "non-primitive" shapes, such as SingleCornerSnipped, TopCornersSnipped, DiagonalCornersSnipped,
// TopCornersOneRoundedOneSnipped, SingleCornerRounded, TopCornersRounded, or DiagonalCornersRounded,
// then save the document with "Strict" or "Transitional" compliance, which allows saving shape as DML.
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.DOCX);
saveOptions.setCompliance(OoxmlCompliance.ISO_29500_2008_TRANSITIONAL);
doc.save(getArtifactsDir() + "Shape.ShapeInsertion.docx", saveOptions);
Shows how to configure a list to restart numbering at each section.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
doc.getLists().add(ListTemplate.NUMBER_DEFAULT);
List list = doc.getLists().get(0);
list.isRestartAtEachSection(restartListAtEachSection);
// The "IsRestartAtEachSection" property will only be applicable when
// the document's OOXML compliance level is to a standard that is newer than "OoxmlComplianceCore.Ecma376".
OoxmlSaveOptions options = new OoxmlSaveOptions();
{
options.setCompliance(OoxmlCompliance.ISO_29500_2008_TRANSITIONAL);
}
builder.getListFormat().setList(list);
builder.writeln("List item 1");
builder.writeln("List item 2");
builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
builder.writeln("List item 3");
builder.writeln("List item 4");
doc.save(getArtifactsDir() + "OoxmlSaveOptions.RestartingDocumentList.docx", options);
doc = new Document(getArtifactsDir() + "OoxmlSaveOptions.RestartingDocumentList.docx");
Assert.assertEquals(restartListAtEachSection, doc.getLists().get(0).isRestartAtEachSection());
Shows how to set an OOXML compliance specification for a saved document to adhere to.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we configure compatibility options to comply with Microsoft Word 2003,
// inserting an image will define its shape using VML.
doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2003);
builder.insertImage(getImageDir() + "Transparent background logo.png");
Assert.assertEquals(ShapeMarkupLanguage.VML, ((Shape) doc.getChild(NodeType.SHAPE, 0, true)).getMarkupLanguage());
// The "ISO/IEC 29500:2008" OOXML standard does not support VML shapes.
// If we set the "Compliance" property of the SaveOptions object to "OoxmlCompliance.Iso29500_2008_Strict",
// any document we save while passing this object will have to follow that standard.
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.setCompliance(OoxmlCompliance.ISO_29500_2008_STRICT);
saveOptions.setSaveFormat(SaveFormat.DOCX);
doc.save(getArtifactsDir() + "OoxmlSaveOptions.Iso29500Strict.docx", saveOptions);
// Our saved document defines the shape using DML to adhere to the "ISO/IEC 29500:2008" OOXML standard.
doc = new Document(getArtifactsDir() + "OoxmlSaveOptions.Iso29500Strict.docx");
Assert.assertEquals(ShapeMarkupLanguage.DML, ((Shape) doc.getChild(NodeType.SHAPE, 0, true)).getMarkupLanguage());
int value. The returned value is one of OoxmlCompliance constants.public void setCompliance(int value)
OoxmlCompliance.ECMA_376_2006.
Examples:
Shows how to insert DML shapes into a document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Below are two wrapping types that shapes may have.
// 1 - Floating:
builder.insertShape(ShapeType.TOP_CORNERS_ROUNDED, RelativeHorizontalPosition.PAGE, 100.0,
RelativeVerticalPosition.PAGE, 100.0, 50.0, 50.0, WrapType.NONE);
// 2 - Inline:
builder.insertShape(ShapeType.DIAGONAL_CORNERS_ROUNDED, 50.0, 50.0);
// If you need to create "non-primitive" shapes, such as SingleCornerSnipped, TopCornersSnipped, DiagonalCornersSnipped,
// TopCornersOneRoundedOneSnipped, SingleCornerRounded, TopCornersRounded, or DiagonalCornersRounded,
// then save the document with "Strict" or "Transitional" compliance, which allows saving shape as DML.
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.DOCX);
saveOptions.setCompliance(OoxmlCompliance.ISO_29500_2008_TRANSITIONAL);
doc.save(getArtifactsDir() + "Shape.ShapeInsertion.docx", saveOptions);
Shows how to configure a list to restart numbering at each section.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
doc.getLists().add(ListTemplate.NUMBER_DEFAULT);
List list = doc.getLists().get(0);
list.isRestartAtEachSection(restartListAtEachSection);
// The "IsRestartAtEachSection" property will only be applicable when
// the document's OOXML compliance level is to a standard that is newer than "OoxmlComplianceCore.Ecma376".
OoxmlSaveOptions options = new OoxmlSaveOptions();
{
options.setCompliance(OoxmlCompliance.ISO_29500_2008_TRANSITIONAL);
}
builder.getListFormat().setList(list);
builder.writeln("List item 1");
builder.writeln("List item 2");
builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
builder.writeln("List item 3");
builder.writeln("List item 4");
doc.save(getArtifactsDir() + "OoxmlSaveOptions.RestartingDocumentList.docx", options);
doc = new Document(getArtifactsDir() + "OoxmlSaveOptions.RestartingDocumentList.docx");
Assert.assertEquals(restartListAtEachSection, doc.getLists().get(0).isRestartAtEachSection());
Shows how to set an OOXML compliance specification for a saved document to adhere to.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we configure compatibility options to comply with Microsoft Word 2003,
// inserting an image will define its shape using VML.
doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2003);
builder.insertImage(getImageDir() + "Transparent background logo.png");
Assert.assertEquals(ShapeMarkupLanguage.VML, ((Shape) doc.getChild(NodeType.SHAPE, 0, true)).getMarkupLanguage());
// The "ISO/IEC 29500:2008" OOXML standard does not support VML shapes.
// If we set the "Compliance" property of the SaveOptions object to "OoxmlCompliance.Iso29500_2008_Strict",
// any document we save while passing this object will have to follow that standard.
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.setCompliance(OoxmlCompliance.ISO_29500_2008_STRICT);
saveOptions.setSaveFormat(SaveFormat.DOCX);
doc.save(getArtifactsDir() + "OoxmlSaveOptions.Iso29500Strict.docx", saveOptions);
// Our saved document defines the shape using DML to adhere to the "ISO/IEC 29500:2008" OOXML standard.
doc = new Document(getArtifactsDir() + "OoxmlSaveOptions.Iso29500Strict.docx");
Assert.assertEquals(ShapeMarkupLanguage.DML, ((Shape) doc.getChild(NodeType.SHAPE, 0, true)).getMarkupLanguage());
value - The corresponding int value. The value must be one of OoxmlCompliance constants.public boolean getKeepLegacyControlChars()
Examples:
Shows how to support legacy control characters when converting to .docx.
Document doc = new Document(getMyDir() + "Legacy control character.doc");
// When we save the document to an OOXML format, we can create an OoxmlSaveOptions object
// and then pass it to the document's saving method to modify how we save the document.
// Set the "KeepLegacyControlChars" property to "true" to preserve
// the "ShortDateTime" legacy character while saving.
// Set the "KeepLegacyControlChars" property to "false" to remove
// the "ShortDateTime" legacy character from the output document.
OoxmlSaveOptions so = new OoxmlSaveOptions(SaveFormat.DOCX);
so.setKeepLegacyControlChars(keepLegacyControlChars);
doc.save(getArtifactsDir() + "OoxmlSaveOptions.KeepLegacyControlChars.docx", so);
doc = new Document(getArtifactsDir() + "OoxmlSaveOptions.KeepLegacyControlChars.docx");
if (keepLegacyControlChars)
Assert.assertEquals("date \\@ \"M/d/yyyy\"\f", doc.getFirstSection().getBody().getText());
else
Assert.assertEquals("\f", doc.getFirstSection().getBody().getText());
boolean value.public void setKeepLegacyControlChars(boolean value)
Examples:
Shows how to support legacy control characters when converting to .docx.
Document doc = new Document(getMyDir() + "Legacy control character.doc");
// When we save the document to an OOXML format, we can create an OoxmlSaveOptions object
// and then pass it to the document's saving method to modify how we save the document.
// Set the "KeepLegacyControlChars" property to "true" to preserve
// the "ShortDateTime" legacy character while saving.
// Set the "KeepLegacyControlChars" property to "false" to remove
// the "ShortDateTime" legacy character from the output document.
OoxmlSaveOptions so = new OoxmlSaveOptions(SaveFormat.DOCX);
so.setKeepLegacyControlChars(keepLegacyControlChars);
doc.save(getArtifactsDir() + "OoxmlSaveOptions.KeepLegacyControlChars.docx", so);
doc = new Document(getArtifactsDir() + "OoxmlSaveOptions.KeepLegacyControlChars.docx");
if (keepLegacyControlChars)
Assert.assertEquals("date \\@ \"M/d/yyyy\"\f", doc.getFirstSection().getBody().getText());
else
Assert.assertEquals("\f", doc.getFirstSection().getBody().getText());
value - The corresponding boolean value.public int getCompressionLevel()
CompressionLevel.NORMAL.
Examples:
Shows how to specify the compression level to use while saving an OOXML document.
Document doc = new Document(getMyDir() + "Big document.docx");
// When we save the document to an OOXML format, we can create an OoxmlSaveOptions object
// and then pass it to the document's saving method to modify how we save the document.
// Set the "CompressionLevel" property to "CompressionLevel.Maximum" to apply the strongest and slowest compression.
// Set the "CompressionLevel" property to "CompressionLevel.Normal" to apply
// the default compression that Aspose.Words uses while saving OOXML documents.
// Set the "CompressionLevel" property to "CompressionLevel.Fast" to apply a faster and weaker compression.
// Set the "CompressionLevel" property to "CompressionLevel.SuperFast" to apply
// the default compression that Microsoft Word uses.
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.DOCX);
saveOptions.setCompressionLevel(compressionLevel);
StopWatch st = new StopWatch();
st.start();
doc.save(getArtifactsDir() + "OoxmlSaveOptions.DocumentCompression.docx", saveOptions);
st.stop();
File fileInfo = new File(getArtifactsDir() + "OoxmlSaveOptions.DocumentCompression.docx");
System.out.println(MessageFormat.format("Saving operation done using the \"{0}\" compression level:", compressionLevel));
System.out.println(MessageFormat.format("\tDuration:\t{0}", st.getTime()));
System.out.println(MessageFormat.format("\tFile Size:\t{0} bytes", fileInfo.length()));
int value. The returned value is one of CompressionLevel constants.public void setCompressionLevel(int value)
CompressionLevel.NORMAL.
Examples:
Shows how to specify the compression level to use while saving an OOXML document.
Document doc = new Document(getMyDir() + "Big document.docx");
// When we save the document to an OOXML format, we can create an OoxmlSaveOptions object
// and then pass it to the document's saving method to modify how we save the document.
// Set the "CompressionLevel" property to "CompressionLevel.Maximum" to apply the strongest and slowest compression.
// Set the "CompressionLevel" property to "CompressionLevel.Normal" to apply
// the default compression that Aspose.Words uses while saving OOXML documents.
// Set the "CompressionLevel" property to "CompressionLevel.Fast" to apply a faster and weaker compression.
// Set the "CompressionLevel" property to "CompressionLevel.SuperFast" to apply
// the default compression that Microsoft Word uses.
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.DOCX);
saveOptions.setCompressionLevel(compressionLevel);
StopWatch st = new StopWatch();
st.start();
doc.save(getArtifactsDir() + "OoxmlSaveOptions.DocumentCompression.docx", saveOptions);
st.stop();
File fileInfo = new File(getArtifactsDir() + "OoxmlSaveOptions.DocumentCompression.docx");
System.out.println(MessageFormat.format("Saving operation done using the \"{0}\" compression level:", compressionLevel));
System.out.println(MessageFormat.format("\tDuration:\t{0}", st.getTime()));
System.out.println(MessageFormat.format("\tFile Size:\t{0} bytes", fileInfo.length()));
value - The corresponding int value. The value must be one of CompressionLevel constants.public int getZip64Mode()
Zip64Mode.NEVER.
Examples:
Shows how to use ZIP64 format extensions.
Random random = new Random();
DocumentBuilder builder = new DocumentBuilder();
for (int i = 0; i < 10000; i++)
{
BufferedImage bmp = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = bmp.createGraphics();
g.setColor(new Color(random.nextInt(254), random.nextInt(254), random.nextInt(254)));
g.drawImage(bmp, 0, 0, null);
g.dispose();
builder.insertImage(bmp);
}
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.setZip64Mode(Zip64Mode.ALWAYS);
builder.getDocument().save(getArtifactsDir() + "OoxmlSaveOptions.Zip64ModeOption.docx", saveOptions);
int value. The returned value is one of Zip64Mode constants.getZip64Mode(),
setZip64Mode(int)public void setZip64Mode(int value)
Zip64Mode.NEVER.
Examples:
Shows how to use ZIP64 format extensions.
Random random = new Random();
DocumentBuilder builder = new DocumentBuilder();
for (int i = 0; i < 10000; i++)
{
BufferedImage bmp = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = bmp.createGraphics();
g.setColor(new Color(random.nextInt(254), random.nextInt(254), random.nextInt(254)));
g.drawImage(bmp, 0, 0, null);
g.dispose();
builder.insertImage(bmp);
}
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.setZip64Mode(Zip64Mode.ALWAYS);
builder.getDocument().save(getArtifactsDir() + "OoxmlSaveOptions.Zip64ModeOption.docx", saveOptions);
value - The corresponding int value. The value must be one of Zip64Mode constants.getZip64Mode(),
setZip64Mode(int)public DigitalSignatureDetails getDigitalSignatureDetails()
DigitalSignatureDetails object used to sign a document.
Examples:
Shows how to sign OOXML document.
Document doc = new Document(getMyDir() + "Document.docx");
CertificateHolder certificateHolder = CertificateHolder.create(getMyDir() + "morzal.pfx", "aw");
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
SignOptions signOptions = new SignOptions();
signOptions.setComments("Some comments");
signOptions.setSignTime(new Date());
saveOptions.setDigitalSignatureDetails(new DigitalSignatureDetails(
certificateHolder,
signOptions));
doc.save(getArtifactsDir() + "OoxmlSaveOptions.DigitalSignature.docx", saveOptions);
DigitalSignatureDetails object used to sign a document.public void setDigitalSignatureDetails(DigitalSignatureDetails value)
DigitalSignatureDetails object used to sign a document.
Examples:
Shows how to sign OOXML document.
Document doc = new Document(getMyDir() + "Document.docx");
CertificateHolder certificateHolder = CertificateHolder.create(getMyDir() + "morzal.pfx", "aw");
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
SignOptions signOptions = new SignOptions();
signOptions.setComments("Some comments");
signOptions.setSignTime(new Date());
saveOptions.setDigitalSignatureDetails(new DigitalSignatureDetails(
certificateHolder,
signOptions));
doc.save(getArtifactsDir() + "OoxmlSaveOptions.DigitalSignature.docx", saveOptions);
value - DigitalSignatureDetails object used to sign a document.