We're pleased to announce the release of Spire.Office for Python 11.11.0. In this version, the Spire.Doc for Python adds a new method for comparing objects between two paragraphs. Spire.PDF for Python adds support for multiple PDF annotation types and also adds the new flow-layout content addition module. Spire.XLS for Python supports macro (VBA) functionality. Spire.Presentation for Python supports saving PPTX to video.Moreover, many known issues that occurred when converting, processing and saving Word/ Excel/ PDF/PowerPoint files have been successfully fixed. More details are listed below.
Click the link to download Spire.Office for Python 11.11.0:
Here is a list of changes made in this release
Spire.Doc for Python
| Category | ID | Description |
| New Feature | SPIREDOC-11128 | Added the Paragraph.ReferenceEquals method for comparing objects between two paragraphs. |
| Bug Fix | SPIREDOC-11676 | Fixed the issue where an exception was thrown when adding comments under track revisions mode. |
| Bug Fix | SPIREDOC-11771 | Fixed the issue where the AppendChart method threw an AttributeError exception. |
| Bug Fix | SPIREDOC-11877 | Fixed the issue where the format of reply comments was incorrect. |
| Bug Fix | SPIREDOC-11886 | Fixed the issue where the result of adding ReplyComment was incorrect. |
| Bug Fix | - | Fixed the issue where extra pages were mistakenly deleted when removing pages from Word documents. |
| Bug Fix | - | Fixed the issue where some Symbol font characters went missing during Word-to-PDF conversion. |
Spire.XLS for Python
| Category | ID | Description |
| New Feature | SPIREXLS-6151 | Adds support for macro (VBA) functionality, including adding, getting, and deleting VBA projects.
//1.Add
workbook = Workbook()
# Add VBA project to document
vbaProject = workbook.VbaProject
vbaProject.Name = "SampleVBAMacro"
text = "Code page before modification: " + str(vbaProject.CodePage) + "\n"
vbaProject.CodePage = 936 # Set encoding to support Chinese characters
text += "Code page after modification: " + str(vbaProject.CodePage) + "\n"
File.WriteAllText(outputFile_TXT, text)
vbaModule = vbaProject.Modules.Add("SampleModule", VbaModuleType.Module)
# Does not support Chinese characters
vbaModule.SourceCode = """
Sub ExampleMacro()
' Declare variables
Dim ws As Worksheet
Dim i As Integer
' Set reference to active worksheet
Set ws = ActiveSheet
' Clear worksheet content (optional)
ws.Cells.Clear
' Fill sample data
With ws
' Write header row
.Range("A1: C1").Value = Array("Serial No.", "Project Name", "Amount")
' Loop to fill 10 rows of data
For i = 1 To 10
.Cells(i + 1, 1).Value = i ' Serial number column
.Cells(i + 1, 2).Value = "Project " & i ' Project name column
.Cells(i + 1, 3).Value = i * 100 ' Amount column (sample calculation)
Next i
' Auto-fit column widths
.Columns("A:C").AutoFit
' Format header row
With.Range("A1:C1")
.Font.Bold = True
.Interior.Color = RGB(200, 220, 255) ' Light blue background
End With
' Format amount column
.Range("C2:C11").NumberFormat = "$#,##0.00"
End With
' Show completion message
MsgBox "Data population complete!", vbInformation, "Operation Prompt"
End Sub"""
workbook.SaveToFile(outputFile_Xls, FileFormat.Version97to2003)
workbook.SaveToFile(outputFile_Xlsb, FileFormat.Xlsb2007)
workbook.SaveToFile(outputFile_Xlsm, FileFormat.Xlsm)
workbook.SaveToFile(outputFile_Xltm, FileFormat.XLTM)
workbook.Dispose()
//2.Obtain and modify
workbook = Workbook()
workbook.LoadFromFile(inputFile)
worksheet = workbook.Worksheets[0]
vbaProject = workbook.VbaProject
// Modify worksheet module
mod = vbaProject.Modules.GetWorksheetModule(worksheet)
mod.Name = "IVbaModule"
mod.SourceCode = "Dim lRow As Long"
mod.Type = VbaModuleType.Module
// Save file
workbook.SaveToFile(outputFile)
workbook.Dispose()
//3. Delete
workbook1 = Workbook()
workbook1.LoadFromFile(inputFile_Module)
vbaProject1 = workbook1.VbaProject
vbaProject1.Modules.Remove("SampleModule")
workbook1.SaveToFile(outputFile_1)
workbook1.Dispose()
|
| New Feature | SPIREXLS-6169 | Adds support for configuring PDF encryption when converting Excel to PDF.
workbook = Workbook()
#Load a excel document
workbook.LoadFromFile(inputFile)
#Set permission password and permissions to encrypt converted pdf
workbook.ConverterSetting.PdfSecurity.Encrypt("123", PdfPermissionsFlags.Print)
#Convert excel to pdf
workbook.SaveToFile(outputFile, FileFormat.PDF)
workbook.Dispose()
|
| Bug Fix | SPIREXLS-6199 | Fixes the issue where combining multiple CopyRangeOptions enum values threw an error. |
Spire.Presentation for Python
| Category | ID | Description |
| New Feature | - | Supported saving PPTX to video (.mp4/.wmv).
ppt = Presentation() ppt.LoadFromFile(inputFile) SaveToVideoOption saveOption = new SaveToVideoOption(ffmpegDir) ppt.SaveToVideoOption=saveOption ppt.SaveToFile(outputFile_mp4, FileFormat.MP4) ppt.SaveToFile(outputFile_wmv, FileFormat.WMV) ppt.Dispose() |
| Bug Fix | SPIREPPT-3152 | Fixed the issue where the program hung when converting PowerPoint to image. |
| Bug Fix | SPIREPPT-3176 SPIREPPT-3178 | Fixed the issue where an error was thrown when loading a PowerPoint file. |
Spire.PDF for Python
| Category | ID | Description |
| New Feature | - | Added support for Caret annotations.
rect = RectangleF(100.0, 100.0, 10.0, 15.0) annotation = PdfCaretAnnotation(page, rect) annotation.Title = "CaretTest" annotation.Contents = "A caret annotation with default (None) symbol." annotation.Color = PdfRGBColor(0, 0, 255) annotation.Border.Width = 1 annotation.Intent = "ParaCaret" PdfAnnotationCollection.Create(page).Add(annotation) |
| New Feature | - | Added support for Circle annotations.
annotation = PdfCircleAnnotation(page, rect) annotation.Color = PdfRGBColor(128, 0, 128) annotation.InteriorColor = PdfRGBColor(255, 255, 200) annotation.Border.Width = 2 annotation.Border.Style = PdfBorderStyle.Solid annotation.Border.Effect = PdfBorderEffect.Cloudy annotation.Border.EffectIntensity = 2 PdfAnnotationCollection.Create(page).Add(annotation) |
| New Feature | - | Added support for Square annotations.
annotation = PdfSquareAnnotation(page, rect) annotation.Color = PdfRGBColor(128, 0, 128) annotation.InteriorColor = PdfRGBColor(255, 255, 200) annotation.Border.Width = 2 annotation.Border.Style = PdfBorderStyle.Dashed PdfAnnotationCollection.Create(page).Add(annotation) |
| New Feature | - | Added support for FileAttachment annotations.
fileSpecification = PdfFileSpecification("SalesReportChart.png", data)
annotation = PdfFileAttachmentAnnotation(page, bounds, fileSpecification)
annotation.Icon = PdfFileIcon.Graph
annotation.Color = PdfRGBColor(Color.get_Teal())
PdfAnnotationCollection.Create(page).Add(annotation)
|
| New Feature | - | Added support for Movie annotations.
annotation = PdfMovieAnnotation(page, rect, "sample.wmv") annotation.Title = "My Movie Player" annotation.Movie.Poster = False annotation.Movie.Aspect = SizeF(16.0, 9.0) PdfAnnotationCollection.Create(page).Add(annotation) |
| New Feature | - | Added support for Screen annotations.
annotation = PdfScreenAnnotation(page, rect) annotation.Title = "ScreenWithBorder" annotation.Border.Width = 3.0 annotation.Border.Style = PdfBorderStyle.Dashed PdfAnnotationCollection.Create(page).Add(annotation) |
| New Feature | - | Added support for RichMedia annotations.
annotation = PdfRichMediaAnnotation(page, rect, content) annotation.Content = PdfRichMediaContent() annotation.Color = PdfRGBColor(Color.get_Green()) PdfAnnotationCollection.Create(page).Add(annotation) |
| New Feature | - | Added support for Widget annotations.
doc.LoadFromFile("widget.pdf")
a = PdfAnnotationCollection.Create(page).get_Item(0)
a.Characteristics.BackgroundColor
a.Characteristics.BorderColor
a.Flatten()
|
| New Feature | SPIREPDF-7101 | Added support for drawing Code 128 barcodes through the PdfCode128ABarcode interface.
message = '0123456789' Code128 = PdfCode128ABarcode(message) Code128.BarcodeToTextGapHeight = 1.0 Code128.TextDisplayLocation = TextLocation.Bottom Code128.TextColor = PdfRGBColor(Color.get_Blue()) Code128.Draw(page, PointF(0.0, y)) |
| New Feature | SPIREPDF-8150 | Adds the new flow-layout content addition module, supporting key features including:
from spire.pdf import *
pdf = PdfDocument()
builder = PdfContentBuilder(pdf)
template = PdfPageTemplate()
template.SetHeader("Product Manual", PdfTextAlignment.Center)
template.SetFooter("Page {page} of {totalPages}", PdfTextAlignment.Center)
section = builder.AddSection(template)
section.AddHeading1("1. Introduction")
section.AddParagraph("Content flows across pages automatically.")
section.AddBulletList(["Fast", "Stable", "Easy to use"])
builder.Build()
pdf.SaveToFile("output.pdf")
pdf.Close()
|
| Bug Fix | SPIREPDF-7291 | Fixed an issue where attachments failed to open after being added to a PDF. |
| Bug Fix | SPIREPDF-7923 | Fixed an issue where text replacement failed. |
| Bug Fix | SPIREPDF-7939 | Fixed an issue where extra spaces appeared in extracted text. |
| Bug Fix | SPIREPDF-8119 | Fixed an issue where the position was incorrect after drawing text using the PdfTextWidget interface. |
| Bug Fix | SPIREPDF-7549 | Optimizes and improves the conversion speed from PDF to Word. |