DocumentSave(Stream, SaveOptions) Method

Saves the document to a stream using the specified save options.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 21.1.0


public SaveOutputParameters Save(
	Stream stream,
	SaveOptions saveOptions


Type: System.IOStream
Stream where to save the document.
Type: Aspose.Words.SavingSaveOptions
Specifies the options that control how the document is saved. Can be null. If this is null, the document will be saved in the binary DOC format.

Return Value

Type: SaveOutputParameters
Additional information that you can optionally use.


Shows how to convert only some of the pages in a document to PDF.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("Page 1.");
builder.Writeln("Page 2.");
builder.Writeln("Page 3.");

using (Stream stream = File.Create(ArtifactsDir + "PdfSaveOptions.OnePage.pdf"))
    // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
    // to modify how that method converts the document to .PDF.
    PdfSaveOptions options = new PdfSaveOptions();

    // Set the "PageIndex" to "1" to render a portion of the document starting from the second page.
    options.PageSet = new PageSet(1);

    // This document will contain one page starting from page two, which will only contain the second page.
    doc.Save(stream, options);

ExpandedSee Also