DocumentSave Method (String, SaveOptions)
Saves the document to a file using the specified save options.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.9
Syntax
public SaveOutputParameters Save(
	string fileName,
	SaveOptions saveOptions
)

Parameters

fileName
Type: SystemString
The name for the document. If a document with the specified file name already exists, the existing document is overwritten.
saveOptions
Type: Aspose.Words.SavingSaveOptions
Specifies the options that control how the document is saved. Can be null.

Return Value

Type: SaveOutputParameters
Additional information that you can optionally use.
Examples
Converts a whole document to PDF with three levels in the document outline.
[C#]

Document doc = new Document(MyDir + "Rendering.doc");

PdfSaveOptions options = new PdfSaveOptions();
options.OutlineOptions.HeadingsOutlineLevels = 3;
options.OutlineOptions.ExpandedOutlineLevels = 1;

doc.Save(ArtifactsDir + "Rendering.SaveToPdfWithOutline.pdf", options);
Examples
Converts a page of a Word document into a TIFF image and uses the CCITT compression.
[C#]

Document doc = new Document(MyDir + "Rendering.doc");

ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Tiff)
{
    TiffCompression = TiffCompression.Ccitt3,
    PageIndex = 0,
    PageCount = 1
};

doc.Save(ArtifactsDir + "Rendering.SaveToTiffCompression.tiff", options);
Examples
Converts every page of a DOC file into a separate scalable EMF file.
[C#]

Document doc = new Document(MyDir + "Rendering.doc");

ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Emf) { PageCount = 1 };

for (int i = 0; i < doc.PageCount; i++)
{
    options.PageIndex = i;
    doc.Save(ArtifactsDir + "Rendering.SaveToEmf." + i.ToString() + ".emf", options);
}
Examples
Shows how to save a document to the XPS format using the Save method and the XpsSaveOptions class.
[C#]

// Open the document
Document doc = new Document(MyDir + "Rendering.doc");
// Save document to file in the XPS format with default options
doc.Save(ArtifactsDir + "Rendering.XpsDefaultOptions.xps");

// Save document to stream in the XPS format with default options
MemoryStream docStream = new MemoryStream();
doc.Save(docStream, SaveFormat.Xps);
// Rewind the stream position back to the beginning, ready for use
docStream.Seek(0, SeekOrigin.Begin);

// Save document to file in the XPS format with specified options
// Render the first page only
XpsSaveOptions xpsOptions = new XpsSaveOptions();
xpsOptions.PageIndex = 0;
xpsOptions.PageCount = 1;
doc.Save(ArtifactsDir + "Rendering.XpsCustomOptions.xps", xpsOptions);
Examples
Shows how to save a document to the PDF format using the Save method and the PdfSaveOptions class.
[C#]

// Open the document
Document doc = new Document(MyDir + "Rendering.doc");

// Option 1: Save document to file in the PDF format with default options
doc.Save(ArtifactsDir + "Rendering.PdfDefaultOptions.pdf");

// Option 2: Save the document to stream in the PDF format with default options
MemoryStream stream = new MemoryStream();
doc.Save(stream, SaveFormat.Pdf);
// Rewind the stream position back to the beginning, ready for use
stream.Seek(0, SeekOrigin.Begin);

// Option 3: Save document to the PDF format with specified options
// Render the first page only and preserve form fields as usable controls and not as plain text
PdfSaveOptions pdfOptions = new PdfSaveOptions();
pdfOptions.PageIndex = 0;
pdfOptions.PageCount = 1;
pdfOptions.PreserveFormFields = true;
doc.Save(ArtifactsDir + "Rendering.PdfCustomOptions.pdf", pdfOptions);
Examples
Shows how to save a document to the JPEG format using the Save method and the ImageSaveOptions class.
[C#]

// Open the document
Document doc = new Document(MyDir + "Rendering.doc");
// Save as a JPEG image file with default options
doc.Save(ArtifactsDir + "Rendering.JpegDefaultOptions.jpg");

// Save document to stream as a JPEG with default options
MemoryStream docStream = new MemoryStream();
doc.Save(docStream, SaveFormat.Jpeg);
// Rewind the stream position back to the beginning, ready for use
docStream.Seek(0, SeekOrigin.Begin);

// Save document to a JPEG image with specified options.
// Render the third page only and set the JPEG quality to 80%
// In this case we need to pass the desired SaveFormat to the ImageSaveOptions constructor 
// to signal what type of image to save as.
ImageSaveOptions imageOptions = new ImageSaveOptions(SaveFormat.Jpeg);
imageOptions.PageIndex = 2;
imageOptions.PageCount = 1;
imageOptions.JpegQuality = 80;
doc.Save(ArtifactsDir + "Rendering.JpegCustomOptions.jpg", imageOptions);
See Also