The latest Aspose.Words for Python via .NET release (version 24.5.0, macOS M1) empowers developers with an array of innovative features to organize document processing within their Python applications.
Empty Document Pages Removal
Seamlessly manage document size and more by utilizing the new remove_blank_pages
method in the most recent Python word-processing API release. It lets you remove blank pages from your documents with ease.
Insert Combo Charts into Your Documents
Add attractive combo charts to your documents using version 24.5.0 of the Aspose.Words for Python via .NET API. This feature allows you to combine several chart types into a single series group and manage gap width, overlap, and bubble scale properties for a refined experience. The following code examples showcase a combo chart created with the secondary Y axis and removing the secondary axis, respectively.
Combo chart with secondary Y axis:
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
shape = builder.insert_chart(chart_type=aw.drawing.charts.ChartType.LINE, width=450, height=250)
chart = shape.chart
series = chart.series
# Delete default generated series.
series.clear()
categories = ['Category 1', 'Category 2', 'Category 3']
series.add(series_name='Series 1 of primary series group', categories=categories, values=[2, 3, 4])
series.add(series_name='Series 2 of primary series group', categories=categories, values=[5, 2, 3])
# Create an additional series group, also of the line type.
new_series_group = chart.series_groups.add(aw.drawing.charts.ChartSeriesType.LINE)
# Specify the use of secondary axes for the new series group.
new_series_group.axis_group = aw.drawing.charts.AxisGroup.SECONDARY
# Hide the secondary X axis.
new_series_group.axis_x.hidden = True
# Define title of the secondary Y axis.
new_series_group.axis_y.title.show = True
new_series_group.axis_y.title.text = 'Secondary Y axis'
# Add a series to the new series group.
series3 = new_series_group.series.add(series_name='Series of secondary series group', categories=categories, values=[13, 11, 16])
series3.format.stroke.weight = 3.5
doc.save(file_name=ARTIFACTS_DIR + 'Charts.SecondaryAxis.docx')
Source*
Removing secondary axis:
doc = aw.Document(file_name=MY_DIR + 'Combo chart.docx')
shape = doc.get_child(aw.NodeType.SHAPE, 0, True).as_shape()
chart = shape.chart
series_groups = chart.series_groups
# Find secondary axis and remove from the collection.
i = 0
while i < series_groups.count:
if series_groups[i].axis_group == aw.drawing.charts.AxisGroup.SECONDARY:
series_groups.remove_at(i)
i += 1
Source*
Control SoftEdge
Effect in Python
Enhance the aesthetics of your shapes using the newly introduced SoftEdge
property in this Python Word document manipulation API release. Apply elegant effects by editing the radius of the soft edges. Here is how to use this feature in your Python applications running on macOS (Big Sur).
builder = aw.DocumentBuilder()
shape = builder.insert_shape(shape_type=aw.drawing.ShapeType.RECTANGLE, width=200, height=200)
# Apply soft edge to the shape.
shape.soft_edge.radius = 30
builder.document.save(file_name=ARTIFACTS_DIR + 'Shape.SoftEdge.docx')
# Load document with rectangle shape with soft edge.
doc = aw.Document(file_name=ARTIFACTS_DIR + 'Shape.SoftEdge.docx')
shape = doc.get_child(aw.NodeType.SHAPE, 0, True).as_shape()
# Check soft edge radius.
self.assertEqual(30, shape.soft_edge.radius)
# Remove soft edge from the shape.
shape.soft_edge.remove()
# Check radius of the removed soft edge.
self.assertEqual(0, shape.soft_edge.radius)
Source*
Top Notch SVG Exports
Export SVGs with high resolution using the new max_image_resolution
property in SvgSaveOptions
. Set the preferred resolution in pixels per inch for high-quality results. Check out the code snippet given below to learn about the feature usage.
doc = aw.Document(file_name=MY_DIR + 'Rendering.docx')
save_options = aw.saving.SvgSaveOptions()
save_options.max_image_resolution = 72
doc.save(file_name=ARTIFACTS_DIR + 'SvgSaveOptions.MaxImageResolution.svg', save_options=save_options)
Source*
Add Adjustments to The Shape Values
With the AdjustmentCollection
and Adjustment
classes added to this release, you can experience more control over shape adjustments, and access/edit raw adjustment values programmatically. This code sample highlights feature usage.
doc = aw.Document(file_name=MY_DIR + 'Rounded rectangle shape.docx')
shape = doc.get_child(aw.NodeType.SHAPE, 0, True).as_shape()
adjustments = shape.adjustments
self.assertEqual(1, adjustments.count)
adjustment = adjustments[0]
self.assertEqual('adj', adjustment.name)
self.assertEqual(16667, adjustment.value)
adjustment.value = 30000
doc.save(file_name=ARTIFACTS_DIR + 'Shape.Adjustments.docx')
Source*
Effortless Macro Detection
Use the new has_macros
property in FileFormatInfo
on macOS M1-powered systems to boost your document processing workflows. This functionality allows identifying the VBA macro’s presence without loading the document completely, as shown in this Python code snippet.
file_format_info = aw.FileFormatUtil.detect_file_format(file_name=MY_DIR + 'Macro.docm')
self.assertTrue(file_format_info.has_macros)
Source*
You can view the list of all new features, enhancements, and bug fixes introduced in this release by visiting Aspose.Words for Python via .NET 24.5.0 Release Notes.