Re: [SMARTY] Latex and Smarty

From: Date: Tue, 21 Jan 2003 07:34:06 +0000
Subject: Re: [SMARTY] Latex and Smarty
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7284@lists.php.net to get a copy of this message
Hi,
So I would be very interested in hearing more about it - if I could make our help files printable (PDF or otherwise) it would probably save us a ton of work in the future...
it's some time ago that I worked with hlp-files but I think it should be possible to convert hlp-files to LaTex. Ok, here's how it worked for me with Smarty and LaTeX and MySQL: The data (entries from several web based questionaires) is stored in a Mysql database. I wrote a LaTex-File with several Smarty-tags to put the dynamic elements in the document. For example some pages had to be duplicated depending on the number of elements in an array in the database, the manager's name had to be printed on top of the report etc. As LaTex uses {} as delimiter I had to redefine right_delimiter and left_delimiter for Smarty. I set it to {{ and }}, which was not so very very clever, because it's more difficult to differ between smarty and latex-tags. To produce a PDF the following worksteps where made: a) init smarty, redefine right and left delimiter b) read the data from the database (php) c) assign the data from the database to Smarty d) display the LaTex-File while using output-buffering
    (now we have a complete LaTex-File), write the output into a file
e) Compile the Tex-File with pdflatex (you can use pngs, jpgs, pdfs as images) or latex and dvipdf (you can use eps as images) f) check if the latex compiler was successfull (error in the template?) g) remove temporary files created while compiling h) send the pdf to the browser, store it somewhere or do something else with the file One problem was that Latex has some special characters like _ & % that have to be masqueraded in normal text. Otherwise the LateX-Compiler will fail. Unfortunately I could not use a Smarty output filter bedause _ & % in LaTex-Commands (== in the template) may not be replaced. So we had to write a find/replace-Function for smarty variables assigned to smarty (going through the known arrays...). I would prefer something more general that keeps the template like it is and does the replacement only for assigned variables (redefining smarty::display?). If someone is interested in code I could prepare a little example in the next few days. CU Dorthe

« previous php.smarty.general (#7284) next »