---
title: "Specify Save Options in Python"
---

```

*Purpose Summary. What is this page about?*

This page demonstrates how to use Aspose.Words SaveOptions classes in Python via .NET to control various aspects of document saving, such as format‑specific options, encryption, timestamps, and image pixel format, with code examples.

```

When saving a document, you can set some advanced properties. Aspose.Words provides you with the [SaveOptions](https://reference.aspose.com/words/python-net/aspose.words.saving/saveoptions/) class, which allows more precise control of the save process. There are overloads of the [save](https://reference.aspose.com/words/python-net/aspose.words/document/save/) method that accept a [SaveOptions](https://reference.aspose.com/words/python-net/aspose.words.saving/saveoptions/) object - it should be an object of a class derived from the [SaveOptions](https://reference.aspose.com/words/python-net/aspose.words.saving/saveoptions/) class. Each save format has a corresponding class that holds save options for this save format, for example, there is [PdfSaveOptions](https://reference.aspose.com/words/python-net/aspose.words.saving/pdfsaveoptions/) for saving to PDF format or [ImageSaveOptions](https://reference.aspose.com/words/python-net/aspose.words.saving/imagesaveoptions/) for saving to an image. This article provides examples of working with some options classes derived from [SaveOptions](https://reference.aspose.com/words/python-net/aspose.words.saving/saveoptions/).

The following code example shows how to set the save options before saving the document into HTML:

{{< gist "aspose-words-gists" "e9d8f984dac599756ccb4a64b8c79768" "Examples-DocsExamples-DocsExamples-File Formats and Conversions-Save Options-working_with_html_save_options-ExportRoundtripInformation.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/Rendering.docx).

```

The article describes a few properties you can control when saving a document.

## Encrypt a Document With a Password

Use the **password** property to get or set a password for an encrypted document. Use the **password** property of the corresponding class to work with the selected document format.

For example, when saving a document to DOC or DOT format, use the [password](https://reference.aspose.com/words/python-net/aspose.words.saving/docsaveoptions/password/) property of the [DocSaveOptions](https://reference.aspose.com/words/python-net/aspose.words.saving/docsaveoptions/) class.

The following code example shows how to set a password to encrypt a document using the RC4 encryption method:

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

When saving a document to Docx format, use the [password](https://reference.aspose.com/words/python-net/aspose.words.saving/ooxmlsaveoptions/password/) property of the [OoxmlSaveOptions](https://reference.aspose.com/words/python-net/aspose.words.saving/ooxmlsaveoptions/) class.

The following code example shows how to load and save Docx encrypted with a password:

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

Not all formats support encryption and the use of **password** property.

## Update the Document Creation Time

Aspose.Words provides an ability to use the [created_time](https://reference.aspose.com/words/python-net/aspose.words.properties/builtindocumentproperties/created_time/) property to get or set the document creation date in UTC. You can also update this value before saving using the [update_created_time_property](https://reference.aspose.com/words/python-net/aspose.words.saving/saveoptions/update_created_time_property/) option.

The following code example shows how to update the document creation time:

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

## Update Last Saved Property

Aspose.Words provides an ability to use the [update_last_saved_time_property](https://reference.aspose.com/words/python-net/aspose.words.saving/saveoptions/update_last_saved_time_property/) property to get or set a value determining whether the [last_saved_time](https://reference.aspose.com/words/python-net/aspose.words.properties/builtindocumentproperties/last_saved_time/) property is updated before saving.

The following code example shows how to set this property and save the document:

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

## Save Black and White Image with One Bit Per Pixel Format

To control image saving options, the [ImageSaveOptions](https://reference.aspose.com/words/python-net/aspose.words.saving/imagesaveoptions/) class is used. For example, you can use the [pixel_format](https://reference.aspose.com/words/python-net/aspose.words.saving/imagesaveoptions/pixel_format/) property to set the pixel format for the generated images. Please note that the pixel format of the output image may differ from the set value because of the work of skia.

The following code example shows how to save a black and white image with one bit per pixel format:

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

------

## FAQ

1. **Q:** How can I set a password to encrypt a document when saving?
   **A:** Use the SaveOptions class that corresponds to the target format (e.g., `DocSaveOptions` for DOC/DOT, `OoxmlSaveOptions` for DOCX) and assign the desired password to its `password` property. Then pass this options object to `Document.save`.

   ```python
   import aspose.words as aw

   doc = aw.Document("input.docx")
   options = aw.saving.DocSaveOptions()
   options.password = "Secret123"
   doc.save("output.doc", options)
   ```

2. **Q:** How do I update the document creation time before saving?
   **A:** Set the `created_time` property of the document’s built‑in properties, or enable `update_created_time_property` on the SaveOptions object. The updated time will be written to the file when you call `save`.

   ```python
   import aspose.words as aw
   from datetime import datetime, timezone

   doc = aw.Document("input.docx")
   doc.built_in_document_properties.created_time = datetime(2023, 5, 1, tzinfo=timezone.utc)

   options = aw.saving.PdfSaveOptions()
   options.update_created_time_property = True
   doc.save("output.pdf", options)
   ```

3. **Q:** How can I prevent the **LastSavedTime** property from being changed on save?
   **A:** Set the `update_last_saved_time_property` of the appropriate SaveOptions object to `False` before calling `save`. This tells Aspose.Words to leave the existing value untouched.

   ```python
   import aspose.words as aw

   doc = aw.Document("input.docx")
   options = aw.saving.OoxmlSaveOptions()
   options.update_last_saved_time_property = False
   doc.save("output.docx", options)
   ```

4. **Q:** How do I control the pixel format of images generated during saving?
   **A:** Use `ImageSaveOptions.pixel_format` and assign a value from the `ImagePixelFormat` enumeration (e.g., `ImagePixelFormat.FORMAT_32BPP_ARGB` for a black‑and‑white image). The option is applied when saving to an image format.

   ```python
   import aspose.words as aw
   from aspose.words.saving import ImagePixelFormat

   doc = aw.Document("input.docx")
   options = aw.saving.ImageSaveOptions()
   options.pixel_format = ImagePixelFormat.FORMAT_32BPP_ARGB
   doc.save("output.png", options)
   ```

5. **Q:** Which SaveOptions class should I use for a specific output format?
   **A:** Each output format has its own derived SaveOptions class: `PdfSaveOptions` for PDF, `HtmlSaveOptions` for HTML, `DocSaveOptions` for DOC/DOT, `OoxmlSaveOptions` for DOCX/DOCM, `ImageSaveOptions` for PNG/JPEG/BMP, `MhtmlSaveOptions` for MHTML, etc. Instantiate the class that matches the desired format and configure its properties before saving.