We are excited to announce the release of Spire.Office for Python 11.5.0. This version introduces several powerful enhancements: Spire.Doc can now convert Word documents to Excel, Spire.PDF allows specifying text color when replacing content, Spire.XLS enables seamless conversion between Markdown and Excel, and Spire.OCR integrates with AI models to improve accuracy and enhance text recognition in images. In addition, all core components (except Spire.OCR) now offer universal support for macOS ARM.
Alongside these new features, numerous known issues related to converting, processing, and saving Word, Excel, PDF, and PowerPoint files have been resolved, delivering a more stable and reliable experience. More details are provided below.
Here is a list of changes made in this release
Spire.Doc for Python
| Category | ID | Description |
| Optimization | - | Chart namespace updated:
// Old import (deprecated): from spire.doc.charts import ChartType // New import (use this): from spire.doc.charts.ChartType import ChartType |
| New Feature | - | The Bookmark class now includes FirstColumn and LastColumn properties to retrieve the starting and ending column indices of a bookmark within a table.
doc = Document() doc.LoadFromFile(inputFile) firstColumn = doc.Bookmarks["t_insert"].FirstColumn lastColumn = doc.Bookmarks["t_insert"].LastColumn |
| New Feature | - | The TableFormat class now supports Style, StyleOptions, and StyleName properties for managing table styles.
doc = Document()
tableStyle = doc.Styles.Add(StyleType.TableStyle, "TestTableStyle3")
tableStyle.LeftIndent = 55
tableStyle.Borders.Color = Color.get_Green()
tableStyle.HorizontalAlignment = RowAlignment.Right
tableStyle.Borders.BorderType = BorderStyle.Single
section = doc.AddSection()
table = section.AddTable()
table.ResetCells(3, 3)
table.Rows[0].Cells[0].AddParagraph().AppendText("Aligned according to left indent")
table.PreferredWidth = PreferredWidth.FromPoints(300)
table.Format.StyleName = "TestTableStyle3"
style = doc.Styles.FindByName("TestTableStyle3")
if (style is not None) and isinstance(style, TableStyle):
tableStyle = style
tableStyle.Borders.Color = Color.get_Black()
tableStyle.Borders.BorderType = BorderStyle.Double
tableStyle.RowStripe = 3
tableStyle.ConditionalStyles[TableConditionalStyleType.OddRowStripe].Shading.BackgroundPatternColor = Color.get_LightBlue()
tableStyle.ConditionalStyles[TableConditionalStyleType.EvenRowStripe].Shading.BackgroundPatternColor = Color.get_LightCyan()
tableStyle.ColumnStripe = 1
tableStyle.ConditionalStyles[TableConditionalStyleType.EvenColumnStripe].Shading.BackgroundPatternColor = Color.get_LightPink()
table.ApplyStyle(tableStyle)
table.Format.StyleOptions = table.Format.StyleOptions | TableStyleOptions.ColumnStripe
doc.SaveToFile(outputFile, FileFormat.Docx)
|
| New Feature | - | The Style class now includes a RemoveSelf method to remove the style from the document.
style = doc.Styles.FindByName("TestTableStyle3")
style.RemoveSelf()
|
| New Feature | - | Enhanced the Document class with features including page extraction (ExtractPages), first-section access (FirstSection), and support for hyphenation dictionary registration/unregistration (RegisterHyphenationDictionary, UnregisterHyphenationDictionary, IsHyphenationDictionaryRegistered). |
| New Feature | SPIREDOC-10777 | Added support for macOS on ARM architecture. |
| New Feature | SPIREDOC-10770 | Added support for converting MHTML to PDF.
document = Document() document.LoadFromFile(“input.mhtml”) document.SaveToFile(“output.pdf”, FileFormat.PDF) document.Close() |
| New Feature | SPIREDOC-11793 | Added support for exporting Word mathematical formulas as standard MathML to ensure correct rendering in HTML.
HtmlExportOptions options = doc.HtmlExportOptions; options.OfficeMathOutputMode = HtmlOfficeMathOutputMode.MathML; |
| New Feature | SPIREDOC-11872 | Added support for converting Word to Excel.
document = Document() document.LoadFromFile(“input.docx”) document.SaveToFile(“output.xlsx”, FileFormat.XLSX) document.Close() |
| Bug Fix | SPIREDOC-11668 | Fixed an issue where enabling track changes and replacing text produced incorrect results. |
| Bug Fix | SPIREDOC-11594 | Fixed an issue where retrieving document properties in a Python v3.14 environment caused a “NotImplementedError” exception. |
| Bug Fix | SPIREDOC-11602 | Fixed an issue where setting CharacterFormat.FontSize on macOS caused a “RuntimeError: ffi_prep_cif_var failed” exception. |
| Bug Fix | SPIREDOC-11701 | Fixed an issue where the program threw an exception when adding a series to a chart. |
| Bug Fix | SPIREDOC-11832 | Fixed an issue where adding a digital signature failed when converting Word to PDF. |
Spire.XLS for Python
| Category | ID | Description |
| New feature | SPIREXLS-5183 | Added support for macOS on ARM architecture. |
| New Feature | SPIREXLS-6094 | Supports hiding the Pivot Table Field List.
workbook.HidePivotFieldList = true; |
| New Feature | SPIREXLS-6097 | Supports converting Excel to Markdown.
workbook = Workbook() workbook.LoadFromFile(inputFile) markdownOptions = MarkdownOptions() markdownOptions.SavePicInRelativePath = False markdownOptions.SaveHyperlinkAsRef = False workbook.SaveToMarkdown(outputFile, markdownOptions) workbook.Dispose() |
| New Feature | SPIREXLS-6098 | Supports converting Markdown to Excel.
workbook = Workbook()
workbook.LoadFromFile(inputFile)
wb.SaveToFile("out.xlsx", ExcelVersion.Version2010);
|
| Bug Fix | SPIREXLS-5970 | Fixes the issue where copied OLE objects displayed incorrectly in WPS. |
| Bug Fix | SPIREXLS-6011 | Fixes the issue where deleting macros did not work correctly. |
| Bug Fix | SPIREXLS-6012 | Fixes the issue where no error message was shown for the incorrect setting workbook.ConverterSetting.Xdpi (should be XDpi). |
| Bug Fix | SPIREXLS-6026 | Fixes the issue where converting text-formatted values to number format failed. |
| Bug Fix | SPIREXLS-6032 | Fixes the issue where saving an Excel document to EMF threw an exception. |
| Bug Fix | SPIREXLS-5986 | Fixed an issue where setting the Value2 property of a cell caused an exception. |
| Bug Fix | SPIREXLS-6089 | Fixed an issue where running the package on Python 3.14.2 threw a `NotImplementedError: There is currently no support for "str |
| Bug Fix | SPIREXLS-6091 | Fixed an issue where setting the ShowValuesRow property of a Pivot Table to False did not take effect. |
| Bug Fix | SPIREXLS-6116 | Fixed an issue where specifying a large data source range when creating a Pivot Table caused an exception. |
| Bug Fix | SPIREXLS-6095 | Fixed the issue where wrapping text in a Pivot table cell didn’t work. |
| Bug Fix | SPIREXLS-6127 | Corrected the enumeration class name from SortComparsionType to SortComparisonType. |
Spire.Presentation for Python
| Category | ID | Description |
| New feature | SPIREPPT-3037 | Added support for macOS on ARM architecture. |
| Bug Fix | SPIREPPT-2859 SPIREPPT-3052 |
Fixed the issue where "ffi_prep_cif_var failed" error was thrown when using Python V12+ on macOS. |
| Bug Fix | SPIREPPT-3028 | Fixed the issue where incorrect SVG effects occurred when importing using AddFromSVGAsShapes. |
| Bug Fix | SPIREPPT-3046 SPIREPPT-3053 |
Fixed the issue where inconsistent chart content was found when converting PPTX to PDF. |
| Bug Fix | SPIREPPT-3054 | Fixed the issue where charts were missing when converting PPTX to PDF. |
| Bug Fix | SPIREPPT-3037 | Fixed the issue of content loss when converting PPT to images. |
| Bug Fix | SPIREPPT-3080 | Fixed an issue where the program would hang when converting PowerPoint documents to images. |
Spire.PDF for Python
| Category | ID | Description |
| New feature | SPIREPDF-7000 SPIREPDF-7698 | Added support for customizing signature appearance via the PdfCustomAppearance class.
class MyPdfCustomAppearance(IPdfSignatureAppearance):
def __init__(self):
pass
def Generate(self, g: PdfCanvas):
x = 0.0
y = 0.0
fontSize = 10.0
font = PdfTrueTypeFont("SimSun", fontSize, PdfFontStyle.Regular, True)
lineHeight = fontSize
image = PdfImage.FromFile(inputImage)
g.DrawImage(image, x, y)
x = float(image.Width)
g.DrawString("Signer: Gary", font, PdfBrushes.get_Red(), PointF(x, y))
y += lineHeight + 5
g.DrawString("Phone: +86 12345678", font, PdfBrushes.get_Black(), PointF(x, y))
y += lineHeight + 5
g.DrawString("Address: Sichuan Province, China", font, PdfBrushes.get_Black(), PointF(x, y))
doc = PdfDocument()
doc.LoadFromFile(inputFile)
signatureMaker = PdfOrdinarySignatureMaker(doc, inputFile_pfx, "e-iceblue")
my_appearance = MyPdfCustomAppearance()
customAppearance = PdfCustomAppearance(my_appearance)
signatureMaker.MakeSignature("Signer", doc.Pages.get_Item(0), 90.0, 550.0, 270.0, 640.0, customAppearance)
doc.SaveToFile(outputFile)
|
| New feature | SPIREPDF-7053 | Added support for retrieving font style information of extracted text.
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(inputFile);
// Define a rectangle
RectangleF rctg = new RectangleF(0, 0, 200, 300);
var page = doc.Pages[0];
PdfTextFinder finder = new PdfTextFinder(page);
finder.Options.Parameter = TextFindParameter.None;
finder.Options.Area = rctg;
// Find text within the rectangle
List<PdfTextFragment> findouts = finder.FindAllText();
StringBuilder sb = new StringBuilder();
foreach (PdfTextFragment find in findouts)
{
sb.AppendLine(find.Text);
sb.AppendLine(find.TextStates[0].FontName);
sb.AppendLine(find.TextStates[0].FontSize.ToString("F2"));
}
File.WriteAllText(outputFile, sb.ToString());
|
| New Feature | SPIREPDF-7558 | Completed compatibility support for Mac M-series chips (ARM64 architecture) |
| New Feature | SPIREPDF-7907 | Added a color parameter overload to the ReplaceText interface.
textReplacer.ReplaceText("Text", "Replace", Color.get_Blue())
|
| Bug Fix | SPIREPDF-6659 | Fixed an issue where text replacement produced incorrect results. |
| Bug Fix | SPIREPDF-7483 | Fixed an issue that the “ffi_prep_cif_var failed” error occurred when running certain Python features on macOS. |
| Bug Fix | SPIREPDF-7819 SPIREPDF-7821 SPIREPDF-7822 | Fixed an issue where content copied from a PDF/A-2B compliant document (converted from PDF) was incorrect. |
| Bug Fix | SPIREPDF-7864 | Fixed an issue where setting a color during text replacement did not take effect as expected. |
Spire.Barcode for Python
| Category | ID | Description |
| New feature | - | Added support for macOS on ARM architecture. |
Spire.OCR for Python
| Category | ID | Description |
| New Feature | - | Added support for integration of AI models into Spire.OCR. (Note: Users need to obtain an API Key from the AI platform on their own.)
def _run_ai_test(self):
filename = "1.png"
output_file = "scan.txt"
file_path = r"F:\3.3.0AI\AI\ocr.xml"
model = "AIModel"
api_key = "ApiKey"
api_url = "ApiUrl"
self._update_ocr_config(file_path, model, api_key, api_url)
self._scan_img(filename, output_file)
def _scan_img(self, filename, output_file):
scanner = OcrScanner()
configure_options = ConfigureOptions()
configure_options.ModelPath = r"F:\3.3.0AI\AI"
configure_options.Language = "Japanese"
scanner.ConfigureDependencies(configure_options)
scanner.Scan(filename)
text = scanner.Text.ToString()
with open(output_file, "w", encoding="utf-8") as f:
f.write(text)
def _update_ocr_config(self, file_path, model, api_key, api_url):
tree = ET.parse(file_path)
root = tree.getroot()
model_node = root.find('./configs/model')
api_key_node = root.find('./configs/apiKey')
api_url_node = root.find('./configs/apiUrl')
if model_node is not None:
model_node.text = model
if api_key_node is not None:
api_key_node.text = api_key
if api_url_node is not None:
api_url_node.text = api_url
tree.write(file_path, encoding='utf-8', xml_declaration=True)
print("XML updated successfully!")
|