DocumentSave(String) Method

Saves the document to a file. Automatically determines the save format from the extension.

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


public SaveOutputParameters Save(
	string fileName


Type: SystemString
The name for the document. If a document with the specified file name already exists, the existing document is overwritten.

Return Value

Type: SaveOutputParameters
Additional information that you can optionally use.


Shows how to open a document and convert it to .PDF.
// Open a document that exists in the local file system
Document doc = new Document(MyDir + "Document.docx");

// Save that document as a PDF to another location
doc.Save(ArtifactsDir + "Document.ConvertToPdf.pdf");
Shows how to save a document to the JPEG format using the Save method and the ImageSaveOptions class.
// Open the document
Document doc = new Document(MyDir + "Rendering.docx");
// Save as a JPEG image file with default options
doc.Save(ArtifactsDir + "Rendering.SaveAsImage.DefaultJpgOptions.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.SaveAsImage.CustomJpgOptions.jpg", imageOptions);

See Also