- h.getAnchor()
h.getTooltip()
h.getDocLocation()
h.getTgtFrame()
There's any way to get/set the Hyperlink's address?
String relId = hyperlink.getId();
Relationship rel = docxPkg.getMainDocumentPart().getRelationshipsPart().getRelationshipByID(relId);
WordprocessingMLPackage template1 = WordprocessingMLPackage.load(new File(templateFilePath));
Tbl finishedTable2 = (Tbl) XmlUtils.unwrap(template1.getMainDocumentPart().getJaxbElement().getBody().getContent().get(0));
Tr finishedTableRow2 = (Tr) finishedTable2.getContent().get(2); // взять вторую строку
//--------
Tc finishedTableRowCell2 = (Tc) XmlUtils.unwrap(finishedTableRow2.getContent().get(1)); // взять вторую ячейку
P finishedTableRowCellParagraph = (P)finishedTableRowCell2.getContent().get(0);
P.Hyperlink hyperLink = (P.Hyperlink) XmlUtils.unwrap(finishedTableRowCellParagraph.getContent().get(0));
R r = (R) hyperLink.getContent().get(0);
Text t = (Text) XmlUtils.unwrap(r.getContent().get(0));
System.out.println(t.getValue());
org.docx4j.relationships.ObjectFactory factory = new org.docx4j.relationships.ObjectFactory();
org.docx4j.relationships.Relationship rel = factory.createRelationship();
rel.setType( Namespaces.HYPERLINK );
rel.setTarget("http://MYLINK");
rel.setTargetMode("External");
template1.getMainDocumentPart().getRelationshipsPart().addRelationship(rel);
String relId = rel.getId();
hyperLink.setId(relId);
Users browsing this forum: Bing [Bot], Google [Bot] and 86 guests