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

Free Support Forum - aspose.com

How to skip some of the style content bookmarks?

Dear team,

I have extract paragraphs in documents using bookmark options. But i need to skip or does not require for following kind of contents Title, Item-Info, Author Group, Affiliation, Section Headings, References.i have attached input and extracted output.

Input : inp.zip (519.3 KB)

Current_Output : current_output.zip (504.7 KB)

Expected_output : Expexted_output.zip (501.1 KB)

Please kindly solution for this scenario.


Thanks for your inquiry. Please use Paragraph.ParagraphFormat.StyleName property to get the name of the paragraph style applied to paragraph. If the paragraph has style name mentioned in your post, please do not add bookmark for them.

Thanks for your replying.Please add some example for this scenario.


Thanks for your inquiry. Please check the following modified method and let us know if you have any more queries.

private static void bookmark(Document inputdoc)
        DocumentBuilder builder = new DocumentBuilder(inputdoc);
        int i = 0;
        for(Paragraph para : (Iterable<Paragraph>) inputdoc.getChildNodes(NodeType.PARAGRAPH, true))
            if(para.getParagraphFormat().getStyleName() == "Title" ||
                    para.getParagraphFormat().getStyleName() == "Item-Info" ||
                    para.getParagraphFormat().getStyleName() == "Author Group" ||
                    para.getParagraphFormat().getStyleName() == "References" ||
                    para.getParagraphFormat().getStyleName() == "Affiliation")

            if (para.getAncestor(NodeType.TABLE) != null)
            if (para.getChildNodes(NodeType.SHAPE, true).getCount() > 0 )
            if (para.getChildNodes().getCount() == 0 || para.toString(SaveFormat.TEXT).trim().equals(""))
            if (para.getChildNodes(NodeType.OFFICE_MATH, true).getCount() > 0)

            BookmarkStart start = new BookmarkStart(inputdoc, "LEBookMark" + i);
            BookmarkEnd end = new BookmarkEnd(inputdoc, "LEBookMark" + i);
            if (para.hasChildNodes())
                para.insertBefore(start, para.getFirstChild());
        inputdoc.save(MyDir + "out.docx");
        convertText(MyDir + "out.docx");

        System.out.println("Successfully Applyed Bookmark!!!");
    catch (Exception e)

Thank you tahir, Its working fine.

Hi Tahir,

requesting a workaround solution to search for open brace “(” and close brace “)” and add text before and after it a text “” and “” in word document.

Sample Text: (DHNAUR saknfien ios knop)
Required OP: (DHNAUR saknfien ios knop)

Input : inp.zip (10.2 KB)
Expected OP : Exp_out.zip (10.5 KB)


Thanks for your inquiry. Please use the following code example to get the desired output. If you want to highlight the text, please refer to the following article.
How to Find and Highlight Text

Document doc = new Document(MyDir + "inp.docx");
doc.getRange().replace("(", "<skip>(", new FindReplaceOptions());
doc.getRange().replace(")", ")</skip>", new FindReplaceOptions());
doc.save(MyDir + "18.2.docx");

Thank you tahir, Its working fine.

Dear Tahir,

requesting a workaround solution to skip the bookmark for References part in word document .

In document Reference part i need to ignore the bookmark content.

Input : inp.zip (12.0 KB)

Current OP : Cur_Output.zip (12.0 KB)

Expected OP : Expected_Output.zip (12.1 KB)


Thanks for your inquiry. In the bookmark(Document inputdoc) method, you can stop adding bookmark into document when the paragraph has text “References”. Please check the following code snippet.

for(Paragraph para : (Iterable) inputdoc.getChildNodes(NodeType.PARAGRAPH, true))
if (para.toString(SaveFormat.TEXT).trim() == “References”)

//Your code…

Dear tahir,

We need to skip following kind of list in word document (Style based, Schema based documents) processing.

  • Footnotes
  • Queries
  • Cross references

In this kind of list accrued in documents mean we need to insert skip comment

Example : <skip Footnotes </skip

Sample document : JAES_E2111010.zip (271.6 KB)


Thanks for your inquiry. Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.