Class XpsSaveOptions
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.Xps format.
To learn more, visit the Specify Save Options documentation article.
public class XpsSaveOptions : FixedPageSaveOptionsInheritance
object ← SaveOptions ← FixedPageSaveOptions ← XpsSaveOptions
Inherited Members
FixedPageSaveOptions.Equals(object) , FixedPageSaveOptions.AssertValidIdPrefix(string) , FixedPageSaveOptions.IsValidIdPrefix(string) , FixedPageSaveOptions.PageSet , FixedPageSaveOptions.PageSavingCallback , FixedPageSaveOptions.NumeralFormat , FixedPageSaveOptions.MetafileRenderingOptions , FixedPageSaveOptions.JpegQuality , FixedPageSaveOptions.ColorMode , FixedPageSaveOptions.OptimizeOutput , 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 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.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
Assert.That(builder.ParagraphFormat.IsHeading, Is.True);
builder.Writeln("Heading 1");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;
builder.Writeln("Heading 1.1");
builder.Writeln("Heading 1.2");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading3;
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.That(saveOptions.SaveFormat, Is.EqualTo(SaveFormat.Xps));
// 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.OutlineOptions.HeadingsOutlineLevels = 2;
doc.Save(ArtifactsDir + "XpsSaveOptions.OutlineLevels.xps", saveOptions);Constructors
XpsSaveOptions()
Initializes a new instance of this class that can be used to save a document in the Aspose.Words.SaveFormat.Xps format.
public XpsSaveOptions()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.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
Assert.That(builder.ParagraphFormat.IsHeading, Is.True);
builder.Writeln("Heading 1");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;
builder.Writeln("Heading 1.1");
builder.Writeln("Heading 1.2");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading3;
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.That(saveOptions.SaveFormat, Is.EqualTo(SaveFormat.Xps));
// 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.OutlineOptions.HeadingsOutlineLevels = 2;
doc.Save(ArtifactsDir + "XpsSaveOptions.OutlineLevels.xps", saveOptions);XpsSaveOptions(SaveFormat)
Initializes a new instance of this class that can be used to save a document in the Aspose.Words.SaveFormat.Xps or Aspose.Words.SaveFormat.OpenXps format.
public XpsSaveOptions(SaveFormat saveFormat)Parameters
saveFormat SaveFormat
Examples
Shows how to save a document to the XPS format in the form of a book fold.
Document doc = new Document(MyDir + "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.UseBookFoldPrintingSettings = 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)
foreach (Section s in doc.Sections)
{
s.PageSetup.MultiplePages = MultiplePagesType.BookFoldPrinting;
}
// 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(ArtifactsDir + "XpsSaveOptions.BookFold.xps", xpsOptions);Properties
DigitalSignatureDetails
Gets or sets Aspose.Words.Saving.DigitalSignatureDetails object used to sign a document.
public DigitalSignatureDetails DigitalSignatureDetails { get; set; }Property Value
Examples
Shows how to sign XPS document.
Document doc = new Document(MyDir + "Document.docx");
CertificateHolder certificateHolder = CertificateHolder.Create(MyDir + "morzal.pfx", "aw");
SignOptions options = new SignOptions();
options.SignTime = DateTime.Now;
options.Comments = "Some comments";
DigitalSignatureDetails digitalSignatureDetails = new DigitalSignatureDetails(certificateHolder, options);
XpsSaveOptions saveOptions = new XpsSaveOptions();
saveOptions.DigitalSignatureDetails = digitalSignatureDetails;
Assert.That(digitalSignatureDetails.CertificateHolder, Is.EqualTo(certificateHolder));
Assert.That(digitalSignatureDetails.SignOptions.Comments, Is.EqualTo("Some comments"));
doc.Save(ArtifactsDir + "XpsSaveOptions.XpsDigitalSignature.docx", saveOptions);OutlineOptions
Allows to specify outline options.
public OutlineOptions OutlineOptions { get; }Property Value
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.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
Assert.That(builder.ParagraphFormat.IsHeading, Is.True);
builder.Writeln("Heading 1");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;
builder.Writeln("Heading 1.1");
builder.Writeln("Heading 1.2");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading3;
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.That(saveOptions.SaveFormat, Is.EqualTo(SaveFormat.Xps));
// 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.OutlineOptions.HeadingsOutlineLevels = 2;
doc.Save(ArtifactsDir + "XpsSaveOptions.OutlineLevels.xps", saveOptions);Remarks
Note that Aspose.Words.Saving.OutlineOptions.ExpandedOutlineLevels option will not work when saving to XPS.
SaveFormat
Specifies the format in which the document will be saved if this save options object is used. Can only be Aspose.Words.SaveFormat.Xps.
public override SaveFormat SaveFormat { get; set; }Property Value
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.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
Assert.That(builder.ParagraphFormat.IsHeading, Is.True);
builder.Writeln("Heading 1");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;
builder.Writeln("Heading 1.1");
builder.Writeln("Heading 1.2");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading3;
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.That(saveOptions.SaveFormat, Is.EqualTo(SaveFormat.Xps));
// 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.OutlineOptions.HeadingsOutlineLevels = 2;
doc.Save(ArtifactsDir + "XpsSaveOptions.OutlineLevels.xps", saveOptions);UseBookFoldPrintingSettings
Gets or sets a boolean value indicating whether the document should be saved using a booklet printing layout, if it is specified via Aspose.Words.PageSetup.MultiplePages.
public bool UseBookFoldPrintingSettings { get; set; }Property Value
Examples
Shows how to save a document to the XPS format in the form of a book fold.
Document doc = new Document(MyDir + "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.UseBookFoldPrintingSettings = 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)
foreach (Section s in doc.Sections)
{
s.PageSetup.MultiplePages = MultiplePagesType.BookFoldPrinting;
}
// 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(ArtifactsDir + "XpsSaveOptions.BookFold.xps", xpsOptions);Remarks
<p>
If this option is specified, Aspose.Words.Saving.FixedPageSaveOptions.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.