---
title: "Save a Document in Python"
---


{{% alert color="grey" %}}

*Purpose Summary. What is this page about?*

This page demonstrates how to use Aspose.Words for Python via .NET to save a Document, providing code examples for saving to a file, to a stream, and to PCL format, and explains the required methods and options.

{{% /alert %}}

Most of the tasks you need to perform with Aspose.Words involve saving a document. To save a document Aspose.Words provides the [save](https://reference.aspose.com/words/python-net/aspose.words/document/save/) method of the [Document](https://reference.aspose.com/words/python-net/aspose.words/document/) class. There are overloads that allow saving a document to a file or stream. The document can be saved in any save format supported by Aspose.Words. For the list of all supported save formats, see the [SaveFormat](https://reference.aspose.com/words/python-net/aspose.words/saveformat/) enumeration.

## Save a Document to a File {#save-a-document-to-a-file}

Simply use the [save](https://reference.aspose.com/words/python-net/aspose.words/document/save/) method with a file name. Aspose.Words will determine the save format from the file extension that you specify.

The following code example shows how to load and save a document to a file:

{{< gist "aspose-words-gists" "e9d8f984dac599756ccb4a64b8c79768" "Examples-DocsExamples-DocsExamples-File Formats and Conversions-base_conversions-LoadAndSave.py" >}}

{{% alert color="primary" %}}

You can download the template file of this example from [Aspose.Words GitHub](https://github.com/aspose-words/Aspose.Words-for-Python-via-.NET/blob/master/Examples/Data/Document.docx).

{{% /alert %}}

## Save a Document to a Stream {#save-a-document-to-a-stream}

Pass a stream object to the [save](https://reference.aspose.com/words/python-net/aspose.words/document/save/) method. It's necessary to specify the save format explicitly when saving to a stream.

The following code example shows how to load and save a document to a stream:

{{< gist "aspose-words-gists" "e9d8f984dac599756ccb4a64b8c79768" "Examples-DocsExamples-DocsExamples-File Formats and Conversions-base_conversions-LoadAndSaveToStream.py" >}}

You can download the template file of this example from [Aspose.Words GitHub](https://github.com/aspose-words/Aspose.Words-for-Python-via-.NET/blob/master/Examples/Data/Document.docx).

## Save a Document to PCL {#save-a-document-to-pcl}

Aspose.Words supports saving a document into PCL (Printer Command Language). Aspose.Words can save documents into PCL 6 (PCL 6 Enhanced or PCL XL) format. The [PclSaveOptions](https://reference.aspose.com/words/python-net/aspose.words.saving/pclsaveoptions/) class can be used to specify additional options when saving a document into the PCL format.

The following code example shows how to save a document to PCL using save options:

{{< gist "aspose-words-gists" "e9d8f984dac599756ccb4a64b8c79768" "Examples-DocsExamples-DocsExamples-File Formats and Conversions-Save Options-working_with_pcl_save_options-RasterizeTransformedElements.py" >}}

------ 

## FAQ

1. **Q:** How does Aspose.Words decide which format to use when I call `document.save("output.docx")`?  
   **A:** When saving to a file, Aspose.Words infers the format from the file extension. The extension “.docx” maps to `SaveFormat.DOCX`, “.pdf” to `SaveFormat.PDF`, and so on.

2. **Q:** Do I need to specify a `SaveFormat` when saving a document to a stream?  
   **A:** Yes. When the destination is a stream, the format cannot be inferred, so you must pass the desired `SaveFormat` (e.g., `SaveFormat.PDF`) as the second argument to `save`.

3. **Q:** Can I save a document directly to a memory stream for further processing?  
   **A:** Absolutely. Create a `MemoryStream` (or `io.BytesIO` in Python), call `document.save(stream, SaveFormat.PDF)`, and then use the stream’s contents as needed, such as sending it over a network or attaching it to an email.

4. **Q:** What options are available when saving a document to PCL?  
   **A:** Use the `PclSaveOptions` class to control PCL‑specific settings, such as rasterizing transformed elements, setting the resolution, or specifying whether to embed fonts. Pass an instance of this class to `document.save(stream, pcl_save_options)`.

5. **Q:** Is it possible to change the font size of the entire document while saving?  
   **A:** Font size changes must be applied to the document’s content before calling `save`. You can iterate through all `Run` nodes, modify their `Font.Size` property, and then save the document in the desired format.