Browse our Products

Aspose.Words for Python via .NET 24.1 Release Notes

Major Features

There are 93 improvements and fixes in this regular monthly release. The most notable are:

  • Introduced the capability to modify the text of the TextBox OLE control.
  • Included new public properties to manage stroke colors.
  • Implemented the Bibliography Sources public API.

Full List of Issues Covering all Changes in this Release

Public API and Backward Incompatible Changes

This section lists public API changes that were introduced in Aspose.Words for Python via .NET 24.1. It includes not only new and obsoleted public methods, but also a description of any changes in the behavior behind the scenes in Aspose.Words for Python via .NET which may affect existing code. Any behavior introduced that could be seen as regression and modifies the existing behavior is especially important and is documented here.

Added an ability to change text of TextBox OLE control

Implemented new public class:

class TextBoxControl:
    """The TextBox control displays text from an organized set of data or user input."""

A new public property text has been added to the class TextBoxControl:

@property
def text(self) -> str:
    """Gets or sets a text of the control."""
    ...

@text.setter
def text(self, value: str):
    ...

from aspose.words import Document, NodeType

doc = Document("Textbox control.docm")

shape = doc.get_child(NodeType.SHAPE, 0, True).as_shape()

textBoxControl = shape.ole_format.ole_control.as_forms2_ole_control().as_text_box_control()
self.assertEqual("Aspose.Words test", textBoxControl.text)

textBoxControl.text = "Updated text"
self.assertEqual("Updated text", textBoxControl.text)

Added new public properties for working with stroke colors

A new public properties fore_theme_color and back_theme_color has been added to the class Stroke:

@property
def fore_theme_color(self) -> aspose.words.themes.ThemeColor:
    """Gets or sets a ThemeColor object that represents the stroke foreground color."""
    ...

@fore_theme_color.setter
def fore_theme_color(self, value: aspose.words.themes.ThemeColor):
    ...

@property
def back_theme_color(self) -> aspose.words.themes.ThemeColor:
    """Gets or sets a ThemeColor object that represents the stroke background color."""
    ...

@back_theme_color.setter
def back_theme_color(self, value: aspose.words.themes.ThemeColor):
    ...

A new public properties fore_tint_and_shade and back_tint_and_shade has been added to the class Stroke:

@property
def fore_tint_and_shade(self) -> float:
    """Gets or sets a double value that lightens or darkens the stroke foreground color.
    
    The allowed values are within the range from -1 (the darkest) to 1 (the lightest) for this property.
    Zero (0) is neutral. Attempting to set this property to a value less than -1 or more than 1
    results in System.ArgumentOutOfRangeException."""
    ...

@fore_tint_and_shade.setter
def fore_tint_and_shade(self, value: float):
    ...

@property
def back_tint_and_shade(self) -> float:
    """Gets or sets a double value that lightens or darkens the stroke background color.
    
    The allowed values are within the range from -1 (the darkest) to 1 (the lightest) for this property.
    Zero (0) is neutral. Attempting to set this property to a value less than -1 or more than 1
    results in System.ArgumentOutOfRangeException."""
    ...

@back_tint_and_shade.setter
def back_tint_and_shade(self, value: float):
    ...

from aspose.words import Document, DocumentBuilder
from aspose.words.drawing import ShapeType
from aspose.words.themes import ThemeColor

doc = Document()
builder = DocumentBuilder(doc)
shape = builder.insert_shape(ShapeType.TEXT_BOX, 100, 40)
stroke = shape.stroke
stroke.fore_theme_color = ThemeColor.DARK1
stroke.fore_tint_and_shade = 0.5

doc.save("Shape.StrokeForeThemeColors.docx")
from aspose.words import Document
from aspose.words.themes import ThemeColor

doc = Document("Stroke gradient outline.docx")

shape = doc.get_child(NodeType.SHAPE, 0, True).as_shape()
stroke = shape.stroke
stroke.back_theme_color = ThemeColor.DARK2
stroke.back_tint_and_shade = 0.2

doc.save("Shape.StrokeBackThemeColors.docx")

Behavior of HtmlSaveOptions.ExportListLabels save option is changed

Previously, when ExportListLabels.BY_HTML_TAGS value was specified for HtmlSaveOptions.export_list_labels save option, some lists could nevertheless be exported as inline text using ‘p’ tags.

Now, when ExportListLabels.BY_HTML_TAGS value is specified for HtmlSaveOptions.export_list_labels save option, all lists are exported as HTML native elements using ‘ul’, ‘ol’ and ’li’ tags.

Some moments worth mentioning regarding new behavior when ExportListLabels.BY_HTML_TAGS value is specified for HtmlSaveOptions.export_list_labels save option:

Previously lists with Heading styles were exported as inline text using ‘h1’, ‘h2’, ‘h3’, ‘h4’, ‘h5’ and ‘h6’ tags. Now they are exported as HTML native elements using ‘ul’, ‘ol’ and ’li’ tags and their styles won’t be preserved after DOCX->HTML->DOCX round-trip.

Previously lists with delete revision were exported as inline text using ‘p’ tags. Now they are exported as HTML native elements using ‘ul’, ‘ol’ and ’li’ tags and some decrease in the quality of such lists is possible.

When a document is exported to MHTML, strikethrough and underline formatting is no longer applied to list markers. If these changes in behavior are critical, you can use ExportListLabels.AUTO value instead of ExportListLabels.BY_HTML_TAGS value for HtmlSaveOptions.export_list_labels save option, because previously their behavior was quite the same.

Implemented Bibliography Sources public API

New public bibliography property has been added to the Document class:

class Document

    @property
    def bibliography(self) -> aspose.words.bibliography.Bibliography:
        """Gets the :attr:`Document.bibliography` object that represents the list of sources available in the document."""
        ...

New public Bibliography, Source, ContributorCollection, Contributor, Corporate, PersonCollection and Person classes and SourceType enumeration have been introduced:

class Bibliography:
    """Represents the list of bibliography sources available in the document."""
    
    @property
    def bibliography_style(self) -> str:
        """Gets a string that represents the name of the active style to use for a bibliography."""
        ...
    
    @property
    def sources(self) -> List[aspose.words.bibliography.Source]:
        """Gets a collection that represents all the sources contained in a bibliography."""
        ...
    
    ...

For more information , please refer to API reference.

from aspose.words import Document

document = Document("Bibliography sources.docx")

bibliography = document.bibliography
self.assertEqual(12, len(bibliography.sources))

source = bibliography.sources[0]
self.assertEqual("Book 0 (No LCID)", source.title)

authors = source.contributors.author.as_person_collection()
self.assertEqual(2, authors.count)

person = authors[0]
self.assertEqual("Roxanne", person.first)
self.assertEqual("Brielle", person.middle)
self.assertEqual("Tejeda", person.last)

Implemented new public property MarkdownSaveOptions.ExportUnderlineFormatting

A new public property export_underline_formatting has been added to class MarkdownSaveOptions:

@property
def export_underline_formatting(self) -> bool:
    """Gets or sets a boolean value indicating either to export underline
    text formatting as sequence of two plus characters "++".
    The default value is ``False``."""
    ...

@export_underline_formatting.setter
def export_underline_formatting(self, value: bool):
    ...

from aspose.words import Document, DocumentBuilder, Underline
from aspose.words.saving import MarkdownSaveOptions

doc = Document()
builder = DocumentBuilder(doc)

builder.underline = Underline.SINGLE
builder.write("Lorem ipsum. Dolor sit amet.")

save_options = MarkdownSaveOptions()
save_options.export_underline_formatting = True
doc.save("MarkdownSaveOptions.ExportUnderlineFormatting.md", save_options)