Section: Generating PDF from latex content
« Generating an ATOM feed | ^ Responses: generating content | Generating PDF with TCPDF » |
Jelix offers a specific response jResponseLatexToPdf
. It aims to convert a latex document to PDF and send the result. Its alias is "ltx2pdf".
$rep = $this->getResponse("ltx2pdf");
- *Note : jResponseLatexToPdf requires pdflatex program presence on the server!**
If this program can not be found through a system environment variable (PATH under linux or Windows), you should assign its full path to $pdflatexPath
.
$resp->pdflatexPath = '/usr/bin/pdflatex';
jResponseLatexToPdf takes care of the latex header defining title and authors of the document. The latex content should be made available through a template. You should tell jResponseLatexToPdf which template to use by assigning $bodyTpl
property with an appropriated selector. You can pass variable to your template through $body
property.
More specifically, the addCommand()
method can generate some latex commands at the beginning of the document.
Example :
$resp = $this->getResponse("ltx2pdf");
$resp->title = 'document title';
$resp->authors[] = 'Michel Dupont';
$resp->date = '\today'; // default value
$resp->outputFileName = 'myDocument.pdf';
$resp->addCommand('documentclass', 'article', array('a4', '14pt'));
$resp->addCommand('geometry', 'hmargin=1cm, vmargin=2cm');
$resp->bodyTpl = 'myModule~doclatex';
$resp->body->assign('texte', $unTexte);
return $resp;