Spire.Doc for Python 13.4.6 supports matching and finding all keywords within paragraphs

Spire.Doc for Python 13.4.6 supports matching and finding all keywords within paragraphs

2025-04-30 06:01:51

We are excited to announce the release of Spire.Doc for Python 13.4.6. The latest version supports matching and finding all keywords within paragraphs. Besides, some known bugs are fixed in this update, such as the issue that the text was garbled when converting Word to TXT. More details are listed below.

Here is a list of changes made in this release

Category ID Description
New feature SPIREDOC-10348 SPIREDOC-11127
Supports matching and finding all keywords within paragraphs.
#Create word document
document = Document()

#Load the document from disk.
document.LoadFromFile(inputFile)

#Insert the paragraphs of document
for i in range(document.Sections.Count):
    section = document.Sections.get_Item(i)
    for j in range(section.Paragraphs.Count):
        paragraph = section.Paragraphs.get_Item(j)
        textSelections = paragraph.FindAllString("The", False, True)
        for selection in textSelections:
            #highlight
            selection.GetAsOneRange().CharacterFormat.HighlightColor = Color.get_Yellow()

#Save doc file.
document.SaveToFile(outputFile, FileFormat.Docx)
New feature SPIREDOC-10659 Supports creating charts in Word.
def AppendCharts(section, chartType, width, heigh):
section.AddParagraph().AppendText("{0:s} chart.".format(chartType))
newPara = section.AddParagraph()
# Support adding the BarChart/LineChart/ColumnChart/Surface3DChart/BubbleChart/PieChart/ScatterChart type
shape = newPara.AppendChart(chartType, float(width), float(heigh))
chart = shape.Chart
chart.Series.Clear()
chart.Series.Add("E-iceblue Test Series 1", ["Word", "PDF", "Excel", "GoogleDocs", "Office"], [
                 float(1900000), float(850000), float(2100000), float(600000), float(1500000)])
chart.Series.Add("E-iceblue Test Series 2", ["Word", "PDF", "Excel", "GoogleDocs", "Office"], [
                 float(900000), float(50000), float(1100000), float(400000), float(2500000)])
chart.Series.Add("E-iceblue Test Series 3", ["Word", "PDF", "Excel", "GoogleDocs", "Office"], [
                 float(500000), float(820000), float(1500000), float(400000), float(100000)])

#Create word document
document = Document()

#Add section
section = document.AddSection()

AppendCharts(section, ChartType.Bar, 500, 300)
#Save
document.SaveToFile("AppendCharts.docx", FileFormat.Docx)
New feature SPIREDOC-10963 Supports obtaining the line index position where the found content is located.
document = Document()
document.LoadFromFile(inputFile)
textSelections = document.FindAllString("Ceshi", True, True)
sb = []
ranges = []
for selection in textSelections:
  tr = selection.GetAsOneRange()
  ranges.append(tr)
   layoutDoc = FixedLayoutDocument(document)
   for tr in ranges:
    spans = layoutDoc.GetLayoutEntitiesOfNode(tr)
    for i in range(spans.Count):
      tempSpan = spans[i]
      fs = FixedLayoutSpan(tempSpan)
         tempfl = fs.Parent
      line = FixedLayoutLine(tempfl)
         if line.Parent.Type == LayoutElementType.Column:
        lines = line.Parent.Lines
        index = lines.IndexOf(line)
        # print(index)
        sb.append("position:" + str(index))

File.AppendAllText(outputFile, sb)
New feature SPIREDOC-11001 Supports enabling and disabling revision tracking mode.
document = Document()
#Load the file from disk.
document.LoadFromFile(inputFile)
document.TrackChanges = True
document.StartTrackRevisions("user")
range = document.LastParagraph.AppendText("Revise4")
range.InsertRevision.Author = "test01"
document.LastParagraph.Text = "remove"
range.DeleteRevision.Author = "test01"
document.StopTrackRevisions()
document.SaveToFile(outputFile)
New feature SPIREDOC-11015 Supports setting "Document.LayoutOptions.UseHarfBuzzTextShaper" when converting Word to PDF.
Document doc = new Document();
doc.LoadFromFile("input.docx");
doc.LayoutOptions.UseHarfBuzzTextShaper = true;
doc.SaveToFile("result.pdf", Spire.Doc.FileFormat.PDF);
New feature SPIREDOC-11114 Supports detecting whether a document is encrypted.
value1 = Document.IsEncrypted(inputFile_1)
New feature SPIREDOC-11157 Supports converting OfficeMath to MathMLCode.
doc = Document()
section=doc.AddSection()
officeMath = OfficeMath(doc)
officeMath.FromLatexMathCode("x^{2}+\\sqrt{{x^{2}+1}}+1")
officeMath.ToMathMLCode()
Bug SPIREDOC-10502 Fixes the issue where adding and extracting formulas would throw an "Arg_InvalidCastException" exception.
Bug SPIREDOC-10646 Fixes the issue that the text was garbled when converting Word to TXT.
Bug SPIREDOC-10860 Fixes the issue where using FixedLayoutRow.Table would throw an "Arg_NullReferenceException" exception.
Bug SPIREDOC-10886 Fixes the issue that the return value of Document.IsContainMacro was incorrect.
Bug SPIREDOC-10924 Fixes the issue that "Cannot remove because there is no parent" exception occurred when converting HTML to Word.
Bug SPIREDOC-10996 Fixes the issue that "System.ArgumentNullException" occurred when converting Word to HTML.
Bug SPIREDOC-11014 Fixes the issue where PreserveFormFields=True did not take effect.
Bug SPIREDOC-11077 SPIREDOC-11101 Fixes the issue that list numbering was incorrect when converting Word to PDF.
Bug SPIREDOC-11166 Fixes the issue that the "'Document' is not defined" error occurred when using Span.ParentNode.
Bug SPIREDOC-11168 Fixes the issue that formulas were blurry when converting Word to HTML.
Click the link to download Spire.Doc for Python 13.4.6: