---
title: "Converting a Word document to PDF while preserving comments"
canonical_url: "https://www.nutrient.io/guides/python/conversion/word-document-to-pdf-including-comments/"
md_url: "https://www.nutrient.io/guides/python/conversion/word-document-to-pdf-including-comments.md"
last_updated: "2026-06-09T10:32:42.848Z"
description: "Learn how to convert Word documents to PDF while preserving all comments and annotations using Nutrient Python SDK with just a few lines of code."
---

# Converting a Word document to PDF while preserving comments

Converting Word documents to PDF with comments preserved — whether for contracts, technical specifications, or regulatory documents — ensures that all stakeholder input remains accessible in the final format.

[Download sample](https://www.nutrient.io/downloads/samples/python/word-document-to-pdf-including-comments.zip)

## How Nutrient helps you achieve this

Nutrient Python SDK handles DOCX-to-PDF conversion with comment preservation. With the SDK, you don’t need to worry about:

- Parsing Word document structures

- Managing comment extraction and placement

- Handling markup mode configuration

- Complex annotation conversion logic

Instead, Nutrient provides an API that handles all the complexity behind the scenes, letting you focus on your business logic.

## Complete implementation

Below is a complete working example that demonstrates DOCX-to-PDF conversion with comments preserved. These lines set up the Python application. The import statements bring in all necessary classes from the Nutrient SDK:

```python

from nutrient_sdk import Document
from nutrient_sdk import DocumentMarkupMode
from nutrient_sdk import NutrientException

```

This line opens the Word document containing comments. The [context manager](https://docs.python.org/3/reference/datamodel.html#context-managers) syntax ensures the document is automatically closed when you're done, preventing resource leaks:

```python

def main():
    try:
        with Document.open("input_with_comments.docx") as document:

```

This line configures the markup mode. Four modes are available:

- `ALL_MARKUP` — Show all markups in different colors, underlined/struck through. Comments are converted to annotations. This is the default behavior.

- `SIMPLE_MARKUP` — Show the document as if all changes were accepted. Comments are converted to annotations.

- `NO_MARKUP` — Show the document as if all changes were accepted. Comments aren't converted to annotations.

- `ORIGINAL` — Show the document as if none of the changes were made (as if all changes were rejected). Comments aren't converted to annotations:

```python

            document.settings.word_settings.markup_mode = DocumentMarkupMode.ALL_MARKUP

```

This block exports the document to PDF with all comments preserved as annotations. The try-except block handles potential errors using `NutrientException`:

```python

            document.export_as_pdf("output.pdf")
            print("Successfully converted with comments preserved")
    except NutrientException as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    main()

```

## Conclusion

The conversion logic consists of three steps:

1. Open the document.

2. Configure the markup mode.

3. Export as PDF.

Nutrient handles Word document parsing and comment conversion so you don't need to understand document internals or manage annotation placement manually.

You can download [this ready-to-use sample package](https://www.nutrient.io/downloads/samples/python/word-document-to-pdf-including-comments.zip) that's fully configured to help you get started with the Python SDK.
---

## Related pages

- [Converting CAD files (DWG/DXF) to PDF format](/guides/python/conversion/cad-to-pdf.md)
- [Converting a document from XLSX to PDF format](/guides/python/conversion/excel-document-to-pdf.md)
- [Converting HTML to PDF](/guides/python/conversion/html-to-pdf.md)
- [Converting email files (MSG/EML) to PDF format](/guides/python/conversion/email-to-pdf.md)
- [Nutrient Python SDK conversion guides](/guides/python/conversion.md)
- [Converting PDF pages to images](/guides/python/conversion/pdf-pages-to-images.md)
- [Converting PDF documents to Excel format for data analysis](/guides/python/conversion/pdf-to-excel-document.md)
- [Converting a document from Markdown to PDF format](/guides/python/conversion/markdown-to-pdf.md)
- [Converting PDF documents to HTML format for web publishing](/guides/python/conversion/pdf-to-html.md)
- [Converting PDF documents to image format](/guides/python/conversion/pdf-to-image.md)
- [Converting PDF documents to PowerPoint presentations](/guides/python/conversion/pdf-to-powerpoint-document.md)
- [Converting PDF documents to PDF/A format](/guides/python/conversion/pdf-to-pdf-a.md)
- [Converting a document from PDF to DOCX format](/guides/python/conversion/pdf-to-word-document.md)
- [Converting PDF documents to PDF/UA format](/guides/python/conversion/pdf-to-pdf-ua.md)
- [Converting a document from PPTX to PDF format](/guides/python/conversion/powerpoint-document-to-pdf.md)
- [Converting a document from DOCX to PDF/UA format](/guides/python/conversion/word-document-to-pdf-ua.md)
- [Converting a document from DOCX to PDF format](/guides/python/conversion/word-document-to-pdf.md)
- [Converting PDF documents to Markdown format](/guides/python/conversion/pdf-to-markdown.md)

