Browse our Products

Aspose.Words for Python via .NET 23.12 Release Notes

Major Features

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

  • Added an ability to specify the page layout to be used when the document is opened in a PDF reader.
  • Implemented the way to control how ZIP64 format extensions will be used for OOXML documents.
  • Introduced support for WebP images.

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 23.12. 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 a public property and enumeration to set the initial view page layout that will be used when opening a document in a PDF reader

New public page_layout property has been added to the PdfSaveOptions class:

class PdfSaveOptions
 @property
    def page_layout(self) -> aspose.words.saving.PdfPageLayout:
        """Specifies the page layout to be used when the document is opened in a PDF reader.
        
        The default value is :attr:`PdfPageLayout.SINGLE_PAGE`."""
        ...
    
    @page_layout.setter
    def page_layout(self, value: aspose.words.saving.PdfPageLayout):
        ...

New public PdfPageLayout enumeration has been introduced:

class PdfPageLayout(Enum):
    """Specifies the page layout to be used when the document is opened in a PDF reader."""
    
    """Display one page at a time."""
    SINGLE_PAGE: int
    
    """Display the pages in one column."""
    ONE_COLUMN: int
    
    """Display the pages in two columns, with odd-numbered pages on the left."""
    TWO_COLUMN_LEFT: int
    
    """Display the pages in two columns, with odd-numbered pages on the right."""
    TWO_COLUMN_RIGHT: int
    
    """Display the pages two at a time, with odd-numbered pages on the left."""
    TWO_PAGE_LEFT: int
    
    """Display the pages two at a time, with odd-numbered pages on the right."""
    TWO_PAGE_RIGHT: int
    

from aspose.words import Document
from aspose.words.saving import PdfPageLayout, PdfSaveOptions
doc = Document("Big document.docx")

# Display the pages two at a time, with odd - numbered pages on the left.
save_options = PdfSaveOptions()
save_options.page_layout = PdfPageLayout.TWO_PAGE_LEFT

doc.save("PdfSaveOptions.PageLayout.pdf", save_options)

Added Merger.merge_docs method overload with array of Document objects as an input

A new public method merge_docs has been added to class Merger:

@staticmethod
    def merge_docs(input_documents: List[aspose.words.Document], merge_format_mode: aspose.words.lowcode.MergeFormatMode) -> aspose.words.Document:
        """Merges the given input documents into a single document and returns :class:`aspose.words.Document` instance of the final document.
        
        :param input_documents: The input documents.
        :param merge_format_mode: Specifies how to merge formatting that clashes."""
        ...

from aspose.words import DocumentBuilder
from aspose.pydrawing import Color
from aspose.words.lowcode import Merger, MergeFormatMode

first_doc = DocumentBuilder()
first_doc.font.size = 16
first_doc.font.color = Color.blue
first_doc.write("Hello first word!")

second_doc = DocumentBuilder()
second_doc.write("Hello second word!")

merged_doc = Merger.merge_docs([first_doc.document, second_doc.document], MergeFormatMode.KEEP_SOURCE_LAYOUT)

self.assertEqual("Hello first word!\fHello second word!\f", merged_doc.get_text())

Added public property OoxmlSaveOptions.zip_64_mode and enum type Zip64Mode

New public zip_64_mode property has been added to the OoxmlSaveOptions class:

class OoxmlSaveOptions
 @property
    def zip_64_mode(self) -> aspose.words.saving.Zip64Mode:
        """Specifies whether or not to use ZIP64 format extensions for the output document.
        The default value is :attr:`Zip64Mode.NEVER`."""
        ...
    
    @zip_64_mode.setter
    def zip_64_mode(self, value: aspose.words.saving.Zip64Mode):
        ...

New public Zip64Mode enumeration has been introduced:

class Zip64Mode(Enum):
    """Specifies when to use ZIP64 format extensions for OOXML files.
    
    OOXML file is a ZIP-archive that has a 4 GB (2^32 bytes) limit on uncompressed size of a file,
    compressed size of a file, and total size of the archive, as well as a limit of 65,535 (2^16-1) files in archive.
    ZIP64 format extensions increase the limits to 2^64."""
    
    """Do not use ZIP64 format extensions."""
    NEVER: int
    
    """If necessary use ZIP64 format extensions."""
    IF_NECESSARY: int
    
    """Always use ZIP64 format extensions."""
    ALWAYS: int

import io
import random
from aspose.words import DocumentBuilder
from aspose.pydrawing import Color, Graphics, Bitmap
from aspose.pydrawing.imaging import ImageFormat
from aspose.words.saving import OoxmlSaveOptions, Zip64Mode

builder = DocumentBuilder()
for i in range(0, 10000):
    bmp = Bitmap(5, 5)
    g = Graphics.from_image(bmp)
    g.clear(Color.from_argb(random.randint(0, 254), random.randint(0, 254), random.randint(0, 254)))
    data = io.BytesIO()
    bmp.save(data, ImageFormat.bmp)
    builder.insert_image(data)
    data.close()

options = OoxmlSaveOptions()
options.zip_64_mode = Zip64Mode.ALWAYS
builder.document.save("OoxmlSaveOptions.Zip64ModeOption.docx")

Introduced support for WebP images.

Added support for reading WebP image format. Added the ability to both read WebP images from documents and insert them via DocumentBuilder.

from aspose.words import Document, DocumentBuilder
doc = Document()
builder = DocumentBuilder(doc)

builder.insert_image("WebP image.webp")
doc.save("Image.InsertWebpImage.docx")
from aspose.words import Document, NodeType
from aspose.words.drawing import ImageType

doc = Document("Document with WebP image.docx")
shape = doc.get_child(NodeType.SHAPE, 0, True).as_shape()

self.assertEqual(ImageType.WEB_P, shape.image_data.image_type)