Hi All!

My problem is that I want to include a link that refer to an internal
embedded document, so click on it will open the document.

If I set the target to an external source (like web url) it works fine:

String linkId =
xdoc.getPackagePart().addExternalRelationship("http://www.website.hu";,
XWPFRelation.HYPERLINK.getRelation()).getId();
CTHyperlink cLink = myParagraph.getCTP().addNewHyperlink();   
cLink.setId(linkId);

And that is it, it works fine.

Now I want to accomplish the same behaviour, but this time hyperlink should
point to an internal document which resides in the docx under path
word/embeddings/test.docx

//embedded part is the packagepart for the document
String linkId =
xdoc.getPackagePart().addRelationship(embeddedPart.getPartName(),
TargetMode.INTERNAL, XWPFRelation.DOCUMENT.getRelation()).getId();
CTHyperlink cLink = myParagraph.getCTP().addNewHyperlink();   
cLink.setId(linkId);



I want to include a link that refer to an internal embedded document, so
click on it will open the document.

If I set the target to an external source (like web url) it works fine:

String linkId =
xdoc.getPackagePart().addExternalRelationship("http://www.website.hu";,
XWPFRelation.HYPERLINK.getRelation()).getId();
CTHyperlink cLink = myParagraph.getCTP().addNewHyperlink();   
cLink.setId(linkId);

And that is it, it works fine. I just created an externalrelationship with
the target url and relationtype and passed it to the hyperlink.

Now I want to accomplish the same behaviour, but this time hyperlink should
point to an internal document which resides in the docx under path
word/embeddings/test.docx

//embedded part is the packagepart for the document
String linkId =
xdoc.getPackagePart().addRelationship(embeddedPart.getPartName(),
TargetMode.INTERNAL, XWPFRelation.DOCUMENT.getRelation()).getId();
CTHyperlink cLink = myParagraph.getCTP().addNewHyperlink();   
cLink.setId(linkId);

And this is where dead end comes: clicking on the link (the link popup shows
the correct path inside docx) automatically change to path to and external
one which points to my filesystem. So if my working directory is in
c:\myfile the link to my internal file inside docx
'word/embeddings/test.docx' will be changed to
c:/myfile/word/embeddings/test.docx .  So i am unable to force it to resolve
the link as an internal one.

Any Idea? So how should I refer to an internal document via hyperlinks?
Thanks



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to