Forum


Replies: 1   Views: 3547
Bookmarking between words (with templates)
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by jake  · 17-06-2015 - 10:30

Hi everyone, I have been looking over the api documentation but didn't find a way to create bookmarks and link them between Word documents. We are creating a report by parts using different templates: 1 - A start template 2 - A mid template, which is used to create x Word documents 3 - A final template, which is also used to create x Word documents At the end of the processing, we do merge [Start Word; x Mid Words; x Final Words] into one single report. The issue that we are confronting here is that we would need to bookmark from Mid x1 Word to Final x1 Word, for all the Mid and Final Words (as they are related), while also bookmarking from the Start Word to all the Mid Words. So as fas as we understand, there are two ways of bookmark linking, using the addBookmark() funcion or the addLink() function; but from the documentation we understand that both functions only work if you are designing the word in real time, not being able to select a part from the already created word and assigning the bookmark. Is there any way to create this relation in a template? Also, as we would need to use this bookmark assigning over the different words, is there a possible way to do it? If it can't be done with the current way of creating the report, how could we do it?

Posted by admin  · 17-06-2015 - 13:57

Hello, We recommend you to use addBookmark and addLink methods together, one to refer the other, but getting their WordFragment. Then replace existing placeholders in your documents by these WordFragments. The method replaceVariableByWordFragment (http://www.phpdocx.com/api-documentation/templates/replace-variable-word-fragment-Word-document) allows to replace placeholders by WordFragments. Regards.