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\"> </span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\"> </span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\"> </span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\"> </span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\"> </span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\"> </span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\"> </span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\"> </span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\"> </span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\"> </span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\"> </span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\"> </span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\"> </span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\"> </span><span style=\"font-family:'Times New Roman'; font-size:7pt; font-weight:normal\"> </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'\"> </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\"> </span><span style=\"font-family:'Arial Nova'; color:#333333\">Carrier Service</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </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\"> </span><span style=\"font-family:'Arial Nova'; color:#333333\">with its principal place of business</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </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\"> </span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">A ADDRESS]</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </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\"> </span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY B NAME]</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </span><span style=\"font-family:'Arial Nova'; color:#333333\">its principal place of business</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY B ADDRESS]</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </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\"> </span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY A]</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </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\"> </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\"> </span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY B]</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </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\"> </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\"> </span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY B]</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </span><span style=\"font-family:'Arial Nova'; color:#333333\">shall</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </span><span style=\"font-family:'Arial Nova'; color:#333333\">submit each</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </span><span style=\"font-family:'Arial Nova'; color:#333333\">order for Equipment or Services</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </span><span style=\"font-family:'Arial Nova'; color:#333333\">on</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\">'s</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </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\"> </span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[ATTACHMENT]</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </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\"> </span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY B]</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </span><span style=\"font-family:'Arial Nova'; color:#333333\">shall include in each Purchase Order</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\">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\"> </span><span style=\"font-family:'Arial Nova'; color:#333333\">Within</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[five]</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </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\"> </span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY A]</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </span><span style=\"font-family:'Arial Nova'; color:#333333\">shall</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </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\"> </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\"> </span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY A]</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </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\"> </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\"> </span><span style=\"font-family:'Arial Nova'; color:#333333; background-color:#e3eaf0\">[PARTY A]</span><span style=\"font-family:'Arial Nova'; color:#333333\"> </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