Specify Layout Options

Aspose.Words enables you to create output documents with various layouts, depending on the parameters specified in properties of the LayoutOptions class. Some of these properties resemble some of the Microsoft Word user interface menu options – they will be described in this article.

For a complete list of parameters such as continuous_section_page_numbering_restart to calculate page numbers in a continuous section that restarts page numbering, or ignore_printer_metrics to ignore the “Use printer metrics to lay out document” compatibility option, see the LayoutOptions class page.

Formatting Marks

Aspose.Words allows to manage formatting marks using the following properties:

  • show_hidden_text – a Boolean value, which specifies whether the hidden text is rendered.
  • show_paragraph_marks – a Boolean value, which specifies whether paragraph mark characters are rendered.

The page depicted in the example below contains three paragraphs. The second one is hidden. A user can change the show_hidden_text option to display this hidden text on the page. Also, each paragraph has a paragraph mark at the end. The paragraph mark usually is not visible unless the show_paragraph_marks property is set to render it.

specify-layout-options_1

In Microsoft Word, these parameters are set using the “File → Options → Display” dialog box as follows:

specify-layout-options_2

Comments and Revisions

With Aspose.Words, you can render document comments that will look the same as in Microsoft Word. To specify whether comments are rendered, use the comment_display_mode property.

In Microsoft Word, this parameter is set using the “Track Changes Options” dialog box, as shown below:

specify-layout-options_3

Also, Aspose.Words allows you to display revisions in a document. Use the revision_options property of the LayoutOptions class to define whether the document revisions are displayed. To control their appearance (revision highlighting color, revision bar color, etc.), use the RevisionOptions class.

You can also have revisions displayed as comments to the content. For this purpose, use the comment_display_mode property and SHOW_IN_BALLOONS value.

The following code example shows how to customize revisions display:

The image below shows how Aspose.Words renders comments and the Delete revisions:

comments_and_revisions_example_aspose_words_net

FAQ

  1. Q: How can I show hidden text in the rendered document?
    A: Set the show_hidden_text property of the document’s LayoutOptions to True. Example:

    import aspose.words as aw
    
    doc = aw.Document("input.docx")
    doc.layout_options.show_hidden_text = True
    doc.save("output.pdf")
    
  2. Q: How do I display paragraph marks (¶) when rendering a document?
    A: Enable the show_paragraph_marks property on LayoutOptions. Example:

    import aspose.words as aw
    
    doc = aw.Document("input.docx")
    doc.layout_options.show_paragraph_marks = True
    doc.save("output.pdf")
    
  3. Q: Which setting controls whether comments are rendered in the output?
    A: Use the comment_display_mode property. Set it to CommentDisplayMode.SHOW_IN_BALLOONS to display comments as balloons, or to CommentDisplayMode.HIDE to hide them. Example:

    import aspose.words as aw
    
    doc = aw.Document("input.docx")
    doc.layout_options.comment_display_mode = aw.CommentDisplayMode.SHOW_IN_BALLOONS
    doc.save("output.pdf")
    
  4. Q: How can I show revisions (track changes) in the generated document?
    A: Enable revision_options.show and optionally configure colors via RevisionOptions. Example:

    import aspose.words as aw
    
    doc = aw.Document("input.docx")
    doc.layout_options.revision_options.show = True
    # Set custom colors if needed
    doc.layout_options.revision_options.insertion_color = aw.Color.red
    doc.layout_options.revision_options.deletion_color = aw.Color.blue
    doc.save("output.pdf")
    
  5. Q: What does the ignore_printer_metrics option do?
    A: When set to True, Aspose.Words ignores the printer’s DPI and other metrics, laying out the document using screen metrics only. This can produce consistent layout across different printers. Example:

    import aspose.words as aw
    
    doc = aw.Document("input.docx")
    doc.layout_options.ignore_printer_metrics = True
    doc.save("output.pdf")