public class XpsSaveOptions extends FixedPageSaveOptions
SaveFormat.XPS format.
To learn more, visit the Specify Save Options documentation article.
Examples:
Shows how to limit the headings' level that will appear in the outline of a saved XPS document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert headings that can serve as TOC entries of levels 1, 2, and then 3.
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);
Assert.assertTrue(builder.getParagraphFormat().isHeading());
builder.writeln("Heading 1");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2);
builder.writeln("Heading 1.1");
builder.writeln("Heading 1.2");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_3);
builder.writeln("Heading 1.2.1");
builder.writeln("Heading 1.2.2");
// Create an "XpsSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .XPS.
XpsSaveOptions saveOptions = new XpsSaveOptions();
Assert.assertEquals(SaveFormat.XPS, saveOptions.getSaveFormat());
// The output XPS document will contain an outline, a table of contents that lists headings in the document body.
// Clicking on an entry in this outline will take us to the location of its respective heading.
// Set the "HeadingsOutlineLevels" property to "2" to exclude all headings whose levels are above 2 from the outline.
// The last two headings we have inserted above will not appear.
saveOptions.getOutlineOptions().setHeadingsOutlineLevels(2);
doc.save(getArtifactsDir() + "XpsSaveOptions.OutlineLevels.xps", saveOptions);
| Constructor and Description |
|---|
XpsSaveOptions()
Initializes a new instance of this class that can be used to save a document in the
SaveFormat.XPS format. |
XpsSaveOptions(int saveFormat)
Initializes a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
DigitalSignatureDetails |
getDigitalSignatureDetails()
Gets
DigitalSignatureDetails object used to sign a document. |
OutlineOptions |
getOutlineOptions()
Allows to specify outline options.
|
int |
getSaveFormat()
Specifies the format in which the document will be saved if this save options object is used.
|
boolean |
getUseBookFoldPrintingSettings()
Gets a boolean value indicating whether the document should be saved using a booklet printing layout, if it is specified via
PageSetup.getMultiplePages() / PageSetup.setMultiplePages(int). |
void |
setDigitalSignatureDetails(DigitalSignatureDetails value)
Sets
DigitalSignatureDetails object used to sign a document. |
void |
setSaveFormat(int value)
Specifies the format in which the document will be saved if this save options object is used.
|
void |
setUseBookFoldPrintingSettings(boolean value)
Sets a boolean value indicating whether the document should be saved using a booklet printing layout, if it is specified via
PageSetup.getMultiplePages() / PageSetup.setMultiplePages(int). |
assertValidIdPrefix, equals, getColorMode, getJpegQuality, getMetafileRenderingOptions, getNumeralFormat, getOptimizeOutput, getPageSavingCallback, getPageSet, isValidIdPrefix, setColorMode, setJpegQuality, setMetafileRenderingOptions, setNumeralFormat, setOptimizeOutput, setPageSavingCallback, setPageSetcreateSaveOptions, 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 XpsSaveOptions()
SaveFormat.XPS format.
Examples:
Shows how to limit the headings' level that will appear in the outline of a saved XPS document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert headings that can serve as TOC entries of levels 1, 2, and then 3.
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);
Assert.assertTrue(builder.getParagraphFormat().isHeading());
builder.writeln("Heading 1");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2);
builder.writeln("Heading 1.1");
builder.writeln("Heading 1.2");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_3);
builder.writeln("Heading 1.2.1");
builder.writeln("Heading 1.2.2");
// Create an "XpsSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .XPS.
XpsSaveOptions saveOptions = new XpsSaveOptions();
Assert.assertEquals(SaveFormat.XPS, saveOptions.getSaveFormat());
// The output XPS document will contain an outline, a table of contents that lists headings in the document body.
// Clicking on an entry in this outline will take us to the location of its respective heading.
// Set the "HeadingsOutlineLevels" property to "2" to exclude all headings whose levels are above 2 from the outline.
// The last two headings we have inserted above will not appear.
saveOptions.getOutlineOptions().setHeadingsOutlineLevels(2);
doc.save(getArtifactsDir() + "XpsSaveOptions.OutlineLevels.xps", saveOptions);
public XpsSaveOptions(int saveFormat)
public int getSaveFormat()
SaveFormat.XPS.
Examples:
Shows how to limit the headings' level that will appear in the outline of a saved XPS document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert headings that can serve as TOC entries of levels 1, 2, and then 3.
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);
Assert.assertTrue(builder.getParagraphFormat().isHeading());
builder.writeln("Heading 1");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2);
builder.writeln("Heading 1.1");
builder.writeln("Heading 1.2");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_3);
builder.writeln("Heading 1.2.1");
builder.writeln("Heading 1.2.2");
// Create an "XpsSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .XPS.
XpsSaveOptions saveOptions = new XpsSaveOptions();
Assert.assertEquals(SaveFormat.XPS, saveOptions.getSaveFormat());
// The output XPS document will contain an outline, a table of contents that lists headings in the document body.
// Clicking on an entry in this outline will take us to the location of its respective heading.
// Set the "HeadingsOutlineLevels" property to "2" to exclude all headings whose levels are above 2 from the outline.
// The last two headings we have inserted above will not appear.
saveOptions.getOutlineOptions().setHeadingsOutlineLevels(2);
doc.save(getArtifactsDir() + "XpsSaveOptions.OutlineLevels.xps", saveOptions);
getSaveFormat in class SaveOptionsint value. The returned value is one of SaveFormat constants.public void setSaveFormat(int value)
SaveFormat.XPS.
Examples:
Shows how to limit the headings' level that will appear in the outline of a saved XPS document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert headings that can serve as TOC entries of levels 1, 2, and then 3.
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);
Assert.assertTrue(builder.getParagraphFormat().isHeading());
builder.writeln("Heading 1");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2);
builder.writeln("Heading 1.1");
builder.writeln("Heading 1.2");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_3);
builder.writeln("Heading 1.2.1");
builder.writeln("Heading 1.2.2");
// Create an "XpsSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .XPS.
XpsSaveOptions saveOptions = new XpsSaveOptions();
Assert.assertEquals(SaveFormat.XPS, saveOptions.getSaveFormat());
// The output XPS document will contain an outline, a table of contents that lists headings in the document body.
// Clicking on an entry in this outline will take us to the location of its respective heading.
// Set the "HeadingsOutlineLevels" property to "2" to exclude all headings whose levels are above 2 from the outline.
// The last two headings we have inserted above will not appear.
saveOptions.getOutlineOptions().setHeadingsOutlineLevels(2);
doc.save(getArtifactsDir() + "XpsSaveOptions.OutlineLevels.xps", saveOptions);
setSaveFormat in class SaveOptionsvalue - The corresponding int value. The value must be one of SaveFormat constants.public OutlineOptions getOutlineOptions()
Remarks:
Note that OutlineOptions.getExpandedOutlineLevels() / OutlineOptions.setExpandedOutlineLevels(int) option will not work when saving to XPS.
Examples:
Shows how to limit the headings' level that will appear in the outline of a saved XPS document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert headings that can serve as TOC entries of levels 1, 2, and then 3.
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);
Assert.assertTrue(builder.getParagraphFormat().isHeading());
builder.writeln("Heading 1");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2);
builder.writeln("Heading 1.1");
builder.writeln("Heading 1.2");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_3);
builder.writeln("Heading 1.2.1");
builder.writeln("Heading 1.2.2");
// Create an "XpsSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .XPS.
XpsSaveOptions saveOptions = new XpsSaveOptions();
Assert.assertEquals(SaveFormat.XPS, saveOptions.getSaveFormat());
// The output XPS document will contain an outline, a table of contents that lists headings in the document body.
// Clicking on an entry in this outline will take us to the location of its respective heading.
// Set the "HeadingsOutlineLevels" property to "2" to exclude all headings whose levels are above 2 from the outline.
// The last two headings we have inserted above will not appear.
saveOptions.getOutlineOptions().setHeadingsOutlineLevels(2);
doc.save(getArtifactsDir() + "XpsSaveOptions.OutlineLevels.xps", saveOptions);
OutlineOptions value.public boolean getUseBookFoldPrintingSettings()
PageSetup.getMultiplePages() / PageSetup.setMultiplePages(int).
Remarks:
If this option is specified, FixedPageSaveOptions.getPageSet() / FixedPageSaveOptions.setPageSet(com.aspose.words.PageSet) is ignored when saving. This behavior matches MS Word. If book fold printing settings are not specified in page setup, this option will have no effect.
Examples:
Shows how to save a document to the XPS format in the form of a book fold.
Document doc = new Document(getMyDir() + "Paragraphs.docx");
// Create an "XpsSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .XPS.
XpsSaveOptions xpsOptions = new XpsSaveOptions(SaveFormat.XPS);
// Set the "UseBookFoldPrintingSettings" property to "true" to arrange the contents
// in the output XPS in a way that helps us use it to make a booklet.
// Set the "UseBookFoldPrintingSettings" property to "false" to render the XPS normally.
xpsOptions.setUseBookFoldPrintingSettings(renderTextAsBookFold);
// If we are rendering the document as a booklet, we must set the "MultiplePages"
// properties of the page setup objects of all sections to "MultiplePagesType.BookFoldPrinting".
if (renderTextAsBookFold)
for (Section s : doc.getSections()) {
s.getPageSetup().setMultiplePages(MultiplePagesType.BOOK_FOLD_PRINTING);
}
// Once we print this document, we can turn it into a booklet by stacking the pages
// to come out of the printer and folding down the middle.
doc.save(getArtifactsDir() + "XpsSaveOptions.BookFold.xps", xpsOptions);
PageSetup.getMultiplePages() / PageSetup.setMultiplePages(int).public void setUseBookFoldPrintingSettings(boolean value)
PageSetup.getMultiplePages() / PageSetup.setMultiplePages(int).
Remarks:
If this option is specified, FixedPageSaveOptions.getPageSet() / FixedPageSaveOptions.setPageSet(com.aspose.words.PageSet) is ignored when saving. This behavior matches MS Word. If book fold printing settings are not specified in page setup, this option will have no effect.
Examples:
Shows how to save a document to the XPS format in the form of a book fold.
Document doc = new Document(getMyDir() + "Paragraphs.docx");
// Create an "XpsSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .XPS.
XpsSaveOptions xpsOptions = new XpsSaveOptions(SaveFormat.XPS);
// Set the "UseBookFoldPrintingSettings" property to "true" to arrange the contents
// in the output XPS in a way that helps us use it to make a booklet.
// Set the "UseBookFoldPrintingSettings" property to "false" to render the XPS normally.
xpsOptions.setUseBookFoldPrintingSettings(renderTextAsBookFold);
// If we are rendering the document as a booklet, we must set the "MultiplePages"
// properties of the page setup objects of all sections to "MultiplePagesType.BookFoldPrinting".
if (renderTextAsBookFold)
for (Section s : doc.getSections()) {
s.getPageSetup().setMultiplePages(MultiplePagesType.BOOK_FOLD_PRINTING);
}
// Once we print this document, we can turn it into a booklet by stacking the pages
// to come out of the printer and folding down the middle.
doc.save(getArtifactsDir() + "XpsSaveOptions.BookFold.xps", xpsOptions);
value - A boolean value indicating whether the document should be saved using a booklet printing layout, if it is specified via PageSetup.getMultiplePages() / PageSetup.setMultiplePages(int).public DigitalSignatureDetails getDigitalSignatureDetails()
DigitalSignatureDetails object used to sign a document.
Examples:
Shows how to sign XPS document.
Document doc = new Document(getMyDir() + "Document.docx");
CertificateHolder certificateHolder = CertificateHolder.create(getMyDir() + "morzal.pfx", "aw");
SignOptions signOptions = new SignOptions();
{
signOptions.setComments("My comment");
signOptions.setSignTime(new Date());
}
DigitalSignatureDetails digitalSignatureDetails = new DigitalSignatureDetails(certificateHolder, signOptions);
XpsSaveOptions saveOptions = new XpsSaveOptions();
saveOptions.setDigitalSignatureDetails(digitalSignatureDetails);
Assert.assertEquals(certificateHolder, digitalSignatureDetails.getCertificateHolder());
Assert.assertEquals("My comment", digitalSignatureDetails.getSignOptions().getComments());
doc.save(getArtifactsDir() + "XpsSaveOptions.XpsDigitalSignature.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 XPS document.
Document doc = new Document(getMyDir() + "Document.docx");
CertificateHolder certificateHolder = CertificateHolder.create(getMyDir() + "morzal.pfx", "aw");
SignOptions signOptions = new SignOptions();
{
signOptions.setComments("My comment");
signOptions.setSignTime(new Date());
}
DigitalSignatureDetails digitalSignatureDetails = new DigitalSignatureDetails(certificateHolder, signOptions);
XpsSaveOptions saveOptions = new XpsSaveOptions();
saveOptions.setDigitalSignatureDetails(digitalSignatureDetails);
Assert.assertEquals(certificateHolder, digitalSignatureDetails.getCertificateHolder());
Assert.assertEquals("My comment", digitalSignatureDetails.getSignOptions().getComments());
doc.save(getArtifactsDir() + "XpsSaveOptions.XpsDigitalSignature.docx", saveOptions);
value - DigitalSignatureDetails object used to sign a document.