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

Free Support Forum - aspose.com

Problem with italic

Hi,


After running the code below the second Run in the saved document has italic set to true even though it was set to false in the original document. Can you please check this out?


Thanks,
Zeljko

Code that reproduces the issue:

public void asposeTest() throws Exception {
Document doc = new Document(“Test1.doc”);
Run run = (Run) doc.getChild(NodeType.RUN, 0, true);
Run run1 = (Run) doc.getChild(NodeType.RUN, 1, true);
DocumentBuilder db = new DocumentBuilder(doc);
db.insertNode(run);
db.insertParagraph();
db.insertNode(run1);
doc = db.getDocument();
doc.save(“Test2.doc”);
}

Hi Zeljko,


Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. If you copy the text of first paragraph without paragraph break using MS Word and insert it at the end of document, you will get the same output.

Following code example inserts Run nodes at the end of document.

Document doc = new Document(MyDir + “Test1.doc”); <o:p></o:p>

Run run = (Run) doc.getChild(NodeType.RUN, 0, true);

Run run1 = (Run) doc.getChild(NodeType.RUN, 1, true);

DocumentBuilder db = new DocumentBuilder(doc);

db.moveToDocumentEnd();

db.getFont().clearFormatting();

db.getParagraphFormat().clearFormatting();

db.insertParagraph();

db.insertNode(run.deepClone(true));

db.insertParagraph();

db.insertNode(run1.deepClone(true));

doc.save(MyDir + "Out.doc");

Hi,


I tried the code you have sent me but my output file is still different from the input file, please see the screenshot. Disregard the fact that the content of the file is now doubled, can you please tell me why is Italic set to true for “CISP RESIDENCES” Run? It is the same problem as it was with the code I have sent you. In the input file this Run has Italic set to false, but after running the code I have sent you, or the one you have sent me, it is set to true in the output file. Can you please check this?

Thanks,
Zeljko

Hi Zeljko,


Thanks for your inquiry. Please open the input document in MS Word and move the cursor to the end of document and click “Clear All” formatting. The text “CISP RESIDENCES” become italic. See the attached image for detail.

Could you please share some detail about your requirements along with expected output Word document? We will then provide you more information about your query along with code.

Hi Tahir,


Thank you for the explanation.


Best regards,
Zeljko