Setting text attibutes to a bookmark

I have an existing word document for which I try to set the formatting options (font, size, color, borders, aso) of specific parts of text which are identified by bookmarks.
I am using aspose words for java from within php (using javabridge)

I am able to access the bookmarks and customize the text but I have no access to the paragraph objects which would allow me to manipulate the paragraph attributes.

What is the path from bookmarks (or formfields) to parapgraphs ?

I do not wish to use the documentBuilder in order to preserve the main parts of the document whch may be arbitrarily complex.

Any sample of code would be appreciated.

I cannot download the demo which seems to achieve what i am looking for.

This message was posted using Page2Forum from NodeCollection - Aspose.Words for .NET and Java

Hello!
Thank you for your inquiry.
If you have bookmarks in paragraphs then BookmarkStart and BookmarkEnd should be paragraphs’ child nodes. Note that bookmarks in MS Word can be put almost everywhere so it’s better to query the ancestor of proper type to reach the Paragraph object. You can navigate to the parent nodes via getParentNode() and getAncestor(). See documentation on the Node class:
https://reference.aspose.com/words/net/aspose.words/node/
Results of getParentNode() and getAncestor() should be cast to Paragraph. After that having a Paragraph you can query its properties with getParagraphFormat and set whatever you’d like.
Regards,

Hello,
thanks for your answer.
I will try to apply this method.
Do you have any code sample that I can reuse ?

We plan to buy our licence in a couple of weeks but I would like to finalize my prototype before doing so.
Do you provide additional support to your actual customers ?

Hi

  1. You can try using the following code line to get parent paragraph of bookmark.
Paragraph par = (Paragraph)doc.getRange().getBookmarks().get("myBookmark").getBookmarkStart().getParentNode();
  1. Aspose provides unlimited free technical support for all its products. The support is available to all users, including evaluation. Please feel free to ask if you have any question about using Aspose.Words, I will be happy to help you.

Best regards.