Free Support Forum - aspose.com

Displaying Deleted text

I have a doc file which has track changes on. Now I delete a paragraph from this. But on parsing paragraph.getText() giving me deleted text also. What can be the reason for this.

//This is the method I am using for parsing and attached the doc which is to be parsed

private String getClausePlainText(Paragraph paraStart) throws Exception{

StringBuffer plainText = new StringBuffer();

Paragraph tempPara = (Paragraph)paraStart.getNextSibling();

while(tempPara != null){

plainText.append(tempPara.getText().substring(0,tempPara.getText().length()-1));

plainText.append("\n");

tempPara = (Paragraph)tempPara.getNextSibling();

if(tempPara != null && tempPara.getListFormat() != null && tempPara.getListFormat().isListItem() && tempPara.getListFormat().getListLevelNumber() <= 1)

break;

}

return plainText.toString();

}

Thanks

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Please try using the following code:

Document doc = new Document("C:\\Temp\\TestCheck2.doc");

doc.acceptAllRevisions();

NodeCollection nodeColl = doc.getChildNodes(NodeType.PARAGRAPH, true);

for(int i = 0; i < nodeColl.getCount(); i++){

System.out.print(getClausePlainText((Paragraph)nodeColl.get(i)));

}

Best regards,

Thanks for your response.

I am using

Document doc = new Document("C:\\doc\\TestCheck2.doc");

doc.appendDocument(doc1, ImportFormatMode.KEEP_SOURCE_FORMATTING);

doc.acceptAllRevisions();

still giving same problem

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I cannot reproduce the problem on my side using the latest version of Aspose.Words for Java 4.0.2.

Document doc = new Document("C:\\Temp\\TestCheck2.doc");

Document doc1 = new Document("C:\\Temp\\Test.doc");

doc.appendDocument(doc1, ImportFormatMode.KEEP_SOURCE_FORMATTING);

doc.acceptAllRevisions();

NodeCollection nodeColl = doc.getChildNodes(NodeType.PARAGRAPH, true);

for(int i = 0; i < nodeColl.getCount(); i++){

System.out.print(getClausePlainText((Paragraph)nodeColl.get(i)));

}

doc.save("C:\\Temp\\out.doc");

Best regards,

Problem has been solved by using doc1.acceptAllRevisions();

instead of

doc.acceptAllRevisions();

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

It is perfect, that you already resolved the problem. If you need more assistance, I will be glad to help you.

Best regards,