Hello,
Thanks for your feedback.
I tested the following java code with our latest
Spire.Doc for Java Version:10.5.10, but I didn't encounter your issue. Here I also attached my testing files for your reference. If you were using an old version, I suggest you upgrade to the latest one and try again, if your issue still exists after trying, please share your input file with us for further testing. You also can send it to us via email(
support@e-iceblue.com).
- Code: Select all
Document doc = new Document();
doc.loadFromFile("in.docx");
Pattern regex=Pattern.compile("\\#[^\\#]+\\#");
TextSelection[] textSelections = doc.findAllPattern(regex, true);
for (TextSelection selection : textSelections)
{
TextRange range = selection.getAsOneRange();
Paragraph paragraph = range.getOwnerParagraph();
Body body = paragraph.ownerTextBody();
body.getChildObjects().remove(paragraph);
}
doc.saveToFile("final.docx", FileFormat.Docx_2013);
Sincerely,
Lisa
E-iceblue support team
Login to view the files attached to this post.