@tahir.manzoor
I am facing this exception “com.aspose.words.BookmarkStart cannot be cast to com.aspose.words.Run”.
Can u please help me to solve this problem.
PFA
Test3.zip (35.7 KB)
@tahir.manzoor
I am facing this exception “com.aspose.words.BookmarkStart cannot be cast to com.aspose.words.Run”.
Can u please help me to solve this problem.
PFA
Test3.zip (35.7 KB)
Please remove the bookmark “_GoBack” as shown below to fix this issue.
Document doc1;
doc1 = new Document(MyDir + "test123.docx");
DocumentBuilder builder = new DocumentBuilder(doc1);
Document doc = builder.getDocument();
if(doc.getRange().getBookmarks().get("_GoBack") != null)
doc.getRange().getBookmarks().get("_GoBack").remove();
hi @tahir.manzoor
i am facing again the same problem “com.aspose.words.BookmarkStart cannot be cast to com.aspose.words.Run”
PFA
test7.zip (34.0 KB)
There are many bookmarks in your document. We suggest you please use StructuredDocumentTag.getChild method instead of StructuredDocumentTag.getFirstChild. Please check the following code snippet.
if (sdt.getSdtType() == SdtType.RICH_TEXT && sdt.getLevel() == MarkupLevel.INLINE)
{
System.out.println("inline" + sdt.getText());
sdt.getFirstChild().getNodeType();
//Run run = (Run) sdt.getFirstChild().deepClone(true);
Run run = (Run) sdt.getChild(NodeType.RUN, 0, true);
sdt.isShowingPlaceholderText(false);
sdt.removeAllChildren();
run.setText("AUTO999");
sdt.appendChild(run);
}