Forum


Replies: 1   Views: 2766
Chunk from replacevariablebyexternalfile is not converted to pdf
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 patrickmathern  · 06-03-2017 - 23:38

i'm constructing a docx file from a set of smaller templates and the .docx file looks fine.  however when i convert it to a pdf or html those sections brought in by replaceVariableByExternalFile are missing from the converted document.  if i open the .docx file in ms word and save as a new .docx file the conversion will work correctly.  has anyone else overcome this with wordfragments or merge or another mechanism?

--code snippet--

   private function replacePartial($var,$docx)    {
        $tempDir = sys_get_temp_dir();
        $tmpFile = $tempDir."/".uniqid().".docx";
        $docx->createDocx($tmpFile);
        $this->templateProcessor->replaceVariableByExternalFile([$var=> $tmpFile]);
        unlink($tmpFile);
    }

template snippet (@summary@, @analysis@ and @attachments@ are all using replacePartial above)

@summary@
@analysis@
@attachments@
body of main template @name@

--results--

the .docx file has everything included cleanly.  the .pdf file from the conversion only has the 'body of main template Joe User' portion.  if i save the .docx file using MS Word and convert again, all is perfect.