We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Track Individual Changes & Update Content Control in Word Document with HTML & Retain List Numbering using C# .NET

Hi,

My use case is to insert the updated content control html in appropriate rich text content control and enable track changes.

The issue i am getting is that , in the resultant document , list numbers are broken (they are incorrect) and also it says that the entire content is changed by the user , whereas only a part of text is modified.

Attached is the zip of input and output documents.

track_documents.zip (46.2 KB)

and here is my code :

public static void main(String… args) throws Exception {
com.aspose.words.License wordLicense = new com.aspose.words.License();
wordLicense.setLicense("/home/sauravarora/Downloads/aspose-licence");

    Document document = new Document("/home/sauravarora/Downloads/test.docx");
    DocumentBuilder documentBuilder = new DocumentBuilder(document);
    String text = "<div> \n" +
            " <h2 style=\"margin-top:12pt; margin-left:47pt; margin-bottom:3pt; text-indent:-7pt; page-break-after:avoid; font-size:11pt\"> <span style=\"font-family:'Arial Nova'; font-weight:normal\">1.</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\">&nbsp;</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\">&nbsp;</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\">&nbsp;</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\">&nbsp;</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\">&nbsp;</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\">&nbsp;</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\">&nbsp;</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\">&nbsp;</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\">&nbsp;</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\">&nbsp;</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\">&nbsp;</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\">&nbsp;</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\">&nbsp;</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\">&nbsp;</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\">&nbsp;</span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\"> </span><span style=\"font-family:'Arial Nova'\">Clause UI-1.0</span><br><span style=\"font-family:'Arial Nova'\">&nbsp;</span> </h2> \n" +
            " <p style=\"margin-top:0pt; margin-left:47pt; margin-bottom:6pt; font-size:11pt\"> <span style=\"font-family:'Arial Nova'; color:#333333\">This</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">Carrier Service</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"-aw-sdt-tag:'BASIC__101__3738__206__206'; -aw-sdt-title:'Agreement Text new'\"><span style=\"font-family:'Arial Nova'; background-color:#00ffff\">Agreement Text new</span></span><span style=\"font-family:'Arial Nova'; color:#333333\">is entered into </span><span style=\"-aw-sdt-tag:'BASIC__101__3739__206__206'; -aw-sdt-title:'between textarea'\"><span style=\"font-family:'Arial Nova'; background-color:#00ffff\">between textarea</span></span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY A NAME]</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">with its principal place of business</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">A ADDRESS]</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">(\"</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY A]</span><span style=\"font-family:'Arial Nova'; color:#333333\">\") and</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY B NAME]</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">its principal place of business</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY B ADDRESS]</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">(\"</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY B]</span><span style=\"font-family:'Arial Nova'; color:#333333\">\").</span> </p> \n" +
            " <p style=\"margin-top:0pt; margin-left:47pt; margin-bottom:6pt; font-size:11pt\"> <span style=\"font-family:'Arial Nova'; color:#333333\">RECITALS:</span> </p> \n" +
            " <p style=\"margin-top:0pt; margin-left:47pt; margin-bottom:6pt; font-size:11pt\"> <span style=\"font-family:'Arial Nova'; color:#333333\">A.</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY A]</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">provides </span><span style=\"-aw-sdt-tag:'BASIC__101__3733__206__206'; -aw-sdt-title:'telecommunications'\"><span style=\"font-family:'Arial Nova'; background-color:#00ffff\">telecommunications</span></span><span style=\"font-family:'Arial Nova'; color:#333333\"> services and equipment identified on</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[ATTACHMENT]</span><span style=\"font-family:'Arial Nova'; color:#333333\">, attached to this agreement.</span> </p> \n" +
            " <p style=\"margin-top:0pt; margin-left:47pt; margin-bottom:6pt; font-size:11pt\"> <span style=\"font-family:'Arial Nova'; color:#333333\">B.</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY B]</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">desires to purchase, on the terms and conditions of this </span><span style=\"-aw-sdt-tag:'BASIC__101__1170__206__206'; -aw-sdt-title:'agreement Number'\"><span style=\"font-family:'Arial Nova'; background-color:#00ffff\">agreement Number</span></span><span style=\"font-family:'Arial Nova'; color:#333333\">, telecommunications services from</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY A]</span><span style=\"font-family:'Arial Nova'; color:#333333\">.</span> </p> \n" +
            " <p style=\"margin-top:0pt; margin-left:47pt; margin-bottom:6pt; font-size:11pt\"> <span style=\"font-family:'Arial Nova'; font-weight:bold; color:#333333\">Purchase Orders and </span><span style=\"-aw-sdt-tag:'BASIC__101__3740__206__206'; -aw-sdt-title:'Statements Date'\"><span style=\"font-family:'Arial Nova'; font-weight:bold; background-color:#00ffff\">Statements Date</span></span><span style=\"font-family:'Arial Nova'; font-weight:bold; color:#333333\">of Work</span> </p> \n" +
            " <p style=\"margin-top:0pt; margin-left:47pt; margin-bottom:6pt; font-size:11pt\"> <span style=\"font-family:'Arial Nova'; font-weight:bold; color:#333333\">Use of Standard Form</span><span style=\"font-family:'Arial Nova'; color:#333333\">.</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY B]</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">shall</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">submit each</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">order for Equipment or Services</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">on</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY A]</span><span style=\"font-family:'Arial Nova'; color:#333333\">'s</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">standard form, an example of which is attached to this agreement on</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[ATTACHMENT]</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">(each one, a \"Purchase Order\").</span> </p> \n" +
            " <p style=\"margin-top:0pt; margin-left:47pt; margin-bottom:6pt; font-size:11pt\"> <span style=\"font-family:'Arial Nova'; font-weight:bold; color:#333333\">Contents of Purchase Order</span><span style=\"font-family:'Arial Nova'; color:#333333\">.</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY B]</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">shall include in each Purchase Order</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span> </p> \n" +
            " <p style=\"margin-top:0pt; margin-left:47pt; margin-bottom:6pt; font-size:11pt\"> <span style=\"font-family:'Arial Nova'; color:#333333\">each item requested, it's price, and product number,</span> </p> \n" +
            " <p style=\"margin-top:0pt; margin-left:47pt; margin-bottom:6pt; font-size:11pt\"> <span style=\"font-family:'Arial Nova'; color:#333333\">the quantity of each item requested, and</span> </p> \n" +
            " <p style=\"margin-top:0pt; margin-left:47pt; margin-bottom:6pt; font-size:11pt\"> <span style=\"font-family:'Arial Nova'; color:#333333\">the time, date, mode, and location for delivery.</span> </p> \n" +
            " <p style=\"margin-top:0pt; margin-left:47pt; margin-bottom:6pt; font-size:11pt\"> <span style=\"font-family:'Arial Nova'; font-weight:bold; color:#333333\">Acceptance or Rejection of Order</span> </p> \n" +
            " <p style=\"margin-top:0pt; margin-left:47pt; margin-bottom:6pt; font-size:11pt\"> <span style=\"font-family:'Arial Nova'; font-weight:bold; color:#333333\">Written Notice of Decision</span><span style=\"font-family:'Arial Nova'; color:#333333\">.</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">Within</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[five]</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">Business Days of receiving a Purchase Order,</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY A]</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">shall</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">accept or reject that Purchase Order by giving written notice to</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY B]</span><span style=\"font-family:'Arial Nova'; color:#333333\">.</span> </p> \n" +
            " <p style=\"margin-top:0pt; margin-left:47pt; margin-bottom:6pt; font-size:11pt\"> <span style=\"font-family:'Arial Nova'; font-weight:bold; color:#333333\">Contents of Rejection</span><span style=\"font-family:'Arial Nova'; color:#333333\">.</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY A]</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">shall include in its notice of rejection the</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">specific grounds for making the rejection, including any objections to Purchase Order.</span> </p> \n" +
            " <p style=\"margin-top:0pt; margin-left:47pt; margin-bottom:6pt; font-size:11pt\"> <span style=\"font-family:'Arial Nova'; font-weight:bold; color:#333333\">Execution of Statements of Work</span><span style=\"font-family:'Arial Nova'; color:#333333\">. If</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY A]</span><span style=\"font-family:'Arial Nova'; color:#333333\">&nbsp;</span><span style=\"font-family:'Arial Nova'; color:#333333\">accepts a Purchase Order, the parties shall cooperate to execute a binding statement of work, specifically describing the Equipment and Services to be provided, prices owed, and timetable for performance (each one, a \"Statement of Work\").With power comes great responsibility.</span> </p> \n" +
            "</div>";
    for (Object st : document.getChildNodes(NodeType.STRUCTURED_DOCUMENT_TAG, true)) {
        StructuredDocumentTag std = (StructuredDocumentTag) st;
        if (std.getSdtType() == SdtType.RICH_TEXT && std.getTag().equals("BASIC__101__4839__138__138")) {
            std.removeAllChildren();
            document.startTrackRevisions("Saurabh", new Date());
            Paragraph para = new Paragraph(document);
            std.appendChild(para);
            documentBuilder.moveTo(std.getFirstChild());
            documentBuilder.insertHtml(text, true);

            Node lastChild = std.getLastChild();
            if (("\r").equals(lastChild.getText())) {
                std.removeChild(lastChild);
            }
            document.stopTrackRevisions();
        }
    }
    document.save("/home/sauravarora/Downloads/test_track.docx");

}

We will really appreciate your help as we are struck in the problem in production.

Thanks

@saurabh.arora,

We tested the above scenarios and have managed to reproduce the same problems on our end. For the sake of corrections, we have logged the following issues in our issue tracking system.

WORDSNET-19856: Track Changes on Content Control not Working Properly
WORDSNET-19857: List numbers are broken after inserting HTML

We will further look into the details of these issues and will keep you updated on the status of corrections. We apologize for your inconvenience.

Hi Hafeez,

Thanks for the reply. Can you please specify the timeline when these issues will be resolved as we are struck in this problem.

Also if can can specify any other way to achieve the above use cases.

Thanks

@saurabh.arora,

I am afraid, your issues are currently pending for analysis and are in the queue. There are no estimates available at the moment. Once the analysis of these issues will be completed, we may then be able to provide you workaround or share the ETAs of these issues with you. We apologize for your inconvenience.

@saurabh.arora,

Regarding WORDSNET-19856, please tell what version of Aspose.Words and Word client (MS Word, OpenOffice Writer etc) are you using on your end?

Also, please ZIP and attach your expected document showing the desired output here for our reference. You can create it by using MS Word for example. Thanks for your cooperation.

@saurabh.arora,

Regarding WORDSNET-19856, we have completed the work on this issue and concluded to close this issue with “Not a Bug” status because we believe that Aspose.Words’ current behavior is correct and we have not received any further information from your end. In case you may have further inquiries or may need any help in future, please let us know.