{"id":15956380,"url":"https://github.com/openadministration/php-latex-renderer","last_synced_at":"2025-10-20T01:52:24.371Z","repository":{"id":44177286,"uuid":"427162457","full_name":"OpenAdministration/php-latex-renderer","owner":"OpenAdministration","description":"Wraps LaTeX PDF rendering with twig templates ","archived":false,"fork":false,"pushed_at":"2025-02-14T15:39:55.000Z","size":235,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-19T05:51:56.067Z","etag":null,"topics":["latex","php","twig","twig-templates"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenAdministration.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-11T22:35:07.000Z","updated_at":"2025-02-14T15:39:58.000Z","dependencies_parsed_at":"2024-10-29T23:09:29.918Z","dependency_job_id":null,"html_url":"https://github.com/OpenAdministration/php-latex-renderer","commit_stats":{"total_commits":41,"total_committers":3,"mean_commits":"13.666666666666666","dds":0.09756097560975607,"last_synced_commit":"f216aff3d2b12ab0938f6736309a259a2496ba38"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenAdministration%2Fphp-latex-renderer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenAdministration%2Fphp-latex-renderer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenAdministration%2Fphp-latex-renderer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenAdministration%2Fphp-latex-renderer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenAdministration","download_url":"https://codeload.github.com/OpenAdministration/php-latex-renderer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245611740,"owners_count":20643887,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["latex","php","twig","twig-templates"],"created_at":"2024-10-07T13:32:07.509Z","updated_at":"2025-10-20T01:52:24.367Z","avatar_url":"https://github.com/OpenAdministration.png","language":"PHP","readme":"# php-latex-renderer\nwraps latex rendering and generating with twig templates. This library does\n  * using twig for latex templating\n  * inserting user data into latex templates \n  * escaping user data, so no (new) latex commands can be introduced by userdata \n  * renders latex file and returns pdf \n  * has compact latex error logs \n# Installation\nInstallation via composer is suggested  \n```\ncomposer require open-administration/php-latex-renderer\n```\n# Usage\n\n```php\nrequire './vendor/autoload.php';\n\n$tex = new LatexRenderer('./templates/'); // \u003c- dir where to search the templates\n$tex-\u003esetTmpDir('./runtime/'); // \u003c- where to build the latex files\n$pdf = $tex-\u003erenderPdf('simple-report', [ // \u003c- which template to use (file ending .tex.twig)\n    'title' =\u003e 'My Custom Title', // \u003c- variables to set \n    'author' =\u003e 'Me!',\n]);\n// output / save the pdf with\nfile_put_contents('main.pdf', $pdf);\n// or echo with fitting header \nheader(\"Content-type:application/pdf\");\necho $pdf;\n```\n### Twig options\nThe following symbols are used for twig templating \n```php\n$options = [\n    'tag_block' =\u003e ['(%', '%)'],\n    'tag_comment' =\u003e ['(!', '!)'],\n    'tag_variable' =\u003e ['((', '))'],\n];\n```\ndue to `{{`, `{#` and `{%` are too common in regular latex code. Be carefull with `((` it is easy to use it in calculations as well. You can use \n```php \n$tex-\u003esetTwigLexer($options)\n```\nfor custom variants. \n### Meta Twig Context \nThere is a new introduced global variable `_tex`, which can be used everywhere and is defined like: \n```php \n$this-\u003etwig-\u003eaddGlobal('_tex', [\n    'files' =\u003e $fileNames, // with name.pdf =\u003e files/name.pdf (local path in dir) \n    'dir' =\u003e $tmpDir . \"tex/$templateName/$uid/\",\n    'template' =\u003e $twigTemplateName,\n]);\n```\nExample: `_tex.dir` \n### Try the sample \n```\nphp -f samples/simple-report.php\n```\n\n# Examples \n\nYou can find some real world examples in the `samples` Folder\n\n# Contribute \nPlease run \n```\ncomposer cs-fix \n```\nand commit the changes in an extra commit before doing a pull request\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenadministration%2Fphp-latex-renderer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenadministration%2Fphp-latex-renderer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenadministration%2Fphp-latex-renderer/lists"}