Forum


Replies: 4   Views: 3809
Dynamically create template with html
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 fpa.777  · 19-08-2014 - 19:21

Hello, Let me explain the situation: I have a series of HTML pages, some of these containing equations written in MathML. The objective is to create DOCX and PDF files from these HTML pages and still preserve the equations. I believe there's no way to use HTML+MathML directly, so I had to think of a way to use the addMathEquation method. The idea was to dynamically create a template and embed the HTML, but replacing the MathML with template variables. Then, I'd just have to use the replaceVariableByWordFragment method to put the equations in the document again. So, my main question is... is this possible? If so, is the idea ok, or am I missing any important point? And finally, which package suits best for such purpose? Thank you.

Posted by fpa.777  · 19-08-2014 - 19:57

I was going to create another topic for this question, but I suppose its still related to this one. Is there any risk of bad formatting when converting DOCX to PDF considering that there will be equations in the middle of the document? Thanks again.

Posted by admin  · 20-08-2014 - 06:36

Hello, Your approach is good. You create the document with placeholders and then replace them. About transforming a DOCX with eqs to PDF there shouldn't be any problem. You need a Corporate license to use phpdocx on a domain (and its subdomains) or an Enterprise license to use phpdocx on an IP. Regards.

Posted by fpa.777  · 20-08-2014 - 17:14

Thanks for the quick reply! Ok, but now I'm not sure you got my question. Is it possible to create a template (not a document from a existing template) using PHPDocx? I searched for something like this at the documentation but couldn't find a "createTemplate" method or anything similar. Thanks again.

Posted by admin  · 21-08-2014 - 06:21

Hello, All documents are templates in phpdocx. So you can create a new document, and then open it as a template. There's the class CreateDocxFromTemplate to do this; the signature of this method is: /** * Construct * @param string $docxTemplatePath path to the template we wish to use * @param array $options * The available keys and values are: * 'preprocessed' (boolean) if true the variables will not be 'repaired'. Default value is false * @access public */ public function __construct($docxTemplatePath, $options = array()) { Regards.