I've looked through a previous thread and the example for adding Hyperlinks and have made some progress in adding the comments, but I'm failing at connecting them to the text within the document.
Is there a sample, similar to HyperlinkTest.java or CreateWordprocessingMLDocument.java, that covers Comments?
Also, from looking at the Hyperlink example, which I assume will be quite similar to Comments, it seems like the only way to add a link is by using XmlUtils.unmarshalString. Is that correct? Is it the same for Comments? Or is there an alternate way to add the links and comments using a syntax similar to "addParagraphOfText", or the more verbose example in CreateWordprocessingMLDocument.java of adding bold text?
Is it possible, for example, to create a link or comment in the middle of a paragraph by combining multiple paragraphs? Something along the lines of:
Using java Syntax Highlighting
org.docx4j.wml.P p1 = generateParagraph("This is a ");
org.docx4j.wml.P.Hyperlink link = generateLink("hyperlink", "http://example.com");
org.docx4j.wml.P p2 = generateParagraph(" within a paragraph.");
org.docx4j.wml.P paragraph = p1.append(link).append(p2);
org.docx4j.wml.Body documentBody = factory.createBody();
documentBody.getEGBlockLevelElts().add(paragraph);
org.docx4j.wml.P.Hyperlink link = generateLink("hyperlink", "http://example.com");
org.docx4j.wml.P p2 = generateParagraph(" within a paragraph.");
org.docx4j.wml.P paragraph = p1.append(link).append(p2);
org.docx4j.wml.Body documentBody = factory.createBody();
documentBody.getEGBlockLevelElts().add(paragraph);
Parsed in 0.016 seconds, using GeSHi 1.0.8.4