Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Jan 15, 2025 1:15 pm

We are using spire-doc to read a document, and we are updating document by strikeout some words/lines in paragraph through

deleted_text.CharacterFormat.IsStrikeout = True

And we also need track changes using comparison function, it is reverting all other changes, but Strikeout is not reverting .

firstdoc.Compare(second_doc)

Sanket98
 
Posts: 3
Joined: Wed Jan 15, 2025 1:08 pm

Thu Jan 16, 2025 3:42 am

Hello,

Thank you for your letter. In your code, "firstdoc" is the original document that was not modified at the beginning, and "second.doc" is the document that has been modified with Strikeout? If so, I simulated the attached documents, when testing the following code, I did find that the Strikeout effect was not compared correctly. I logged this issue into our tracking system with SPIREDOC-11070. Our Dev team will further investigate and fix it.

Code: Select all
from spire.doc.common import *
from spire.doc import *

doc1 = Document()
doc1.LoadFromFile("firstdoc.docx")

doc2 = Document()
doc2.LoadFromFile("second_doc.docx")

# Set CompareOptions
compareOptions = CompareOptions()
compareOptions.IgnoreFormatting = False

# Compare the contents of the two documents
doc1.Compare(doc2, "E-iceblue", DateTime.get_Now(), compareOptions)

# Specify the output file name for the compared result
result = "result12.docx"

# Save the compared result to the specified file path in Docx2013 format
doc1.SaveToFile(result, FileFormat.Docx2013)

However, when testing below code, the effect is correct. Please confirm if this is consistent with your test results. If there are any differences, please provide a detailed information and your testing documents for further verification.
Code: Select all
from spire.doc.common import *
from spire.doc import *

doc1 = Document()
doc1.LoadFromFile("firstdoc.docx")

doc2 = Document()
doc2.LoadFromFile("second_doc.docx")

# Set CompareOptions
compareOptions = CompareOptions()
compareOptions.IgnoreFormatting = False

# Compare the contents of the two documents
doc2.Compare(doc1, "E-iceblue", DateTime.get_Now(), compareOptions)

# Specify the output file name for the compared result
result = "result21.docx"

# Save the compared result to the specified file path in Docx2013 format
doc2.SaveToFile(result, FileFormat.Docx2013)

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1510
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Doc