I'm recently using the docx4j and i'm trying to set a bookmark on a Word document (it's my template file).
I already see the manual but i don't find the answer :S
I'm using version 2.8.1 and i'm getting a Bookmark based on the code available http://www.docx4java.org/forums/docx-java-f6/bookmarks-and-templates-advice-t681.html.
My code is:
- Code: Select all
 PbookmarkedParagraphInPart = findBookmarkedParagraphInPart(documentPart, "bookmarktest");
 // 3. copy the found paragraph to keep styling correct
 P copy = (P) XmlUtils.deepCopy(bookmarkedParagraphInPart);
 String ptext = "Testing";
 // replace the text elements from the copy
 List<?> texts = getAllElementFromObject(copy, Text.class);
 if (texts.size() > 0) {
 Text textToReplace = (Text) texts.get(0);
 textToReplace.setValue(ptext);
 }
 // add the paragraph to the document
 bookmarkedParagraphInPart.getContent().add(copy);
With this code my ptext is set on bookmark location but not inside of bookmark :/
I also retrieve the CTBookmark but there is no method to set a value here.
Can anybody help, please?
Tks


 News
 News Site map
 Site map SitemapIndex
 SitemapIndex RSS Feed
 RSS Feed