Is it possible to insert a cross-reference (via the addCrossReference method, or anything more suitable if needed) to a specific place in my template? Same as I would do with insertWordFragment + referenceNode.
Thanks,
Is it possible to insert a cross-reference (via the addCrossReference method, or anything more suitable if needed) to a specific place in my template? Same as I would do with insertWordFragment + referenceNode.
Thanks,
I tried setting up a wordML with the following:
$wordML = '<w:r><w:fldChar w:fldCharType="begin"/></w:r>'; $wordML .= '<w:r><w:instrText xml:space="preserve">' . 'REF ' . $crossRefName . '</w:instrText></w:r>'; $wordML .= '<w:r><w:fldChar w:fldCharType="separate"/></w:r>'; $wordML .= '<w:r><w:t>' . $crossRefText . '</w:t></w:r>'; $wordML .= '<w:r><w:fldChar w:fldCharType="end"/></w:r>'; $bookmarkId = rand(9999999, 999999999); $wordML .= '<w:bookmarkStart w:id="' . $bookmarkId . '" w:name="_GoBack"/>'; $wordML .= '<w:bookmarkEnd w:id="' . $bookmarkId . '"/>';
And then:
$docx->replaceVariableByWordML(['myVar' => $wordML]);
But when opening the generated document I get the following error:
The Open XML file 'test.docx' cannot be opened because there are problems with the content or the file name might contain invalid characters. Unspecified error | Location: 2.
Where do you think the definition of my wordML is wrong?
Hello,
Yes, you can use addCrossReference using a bookmark as any other content to generate a WordFragment and then use DOCXPath. Please check the included examples in the DOCXPath folder of your package to view similar samples.
If you open a ticket on https://www.phpdocx.com/support, the dev team will generate a custom script to illustrate how to do it.
Regards.