https://github.com/adridevelopsthings/latex-template-server
Host LaTeX templates and fill them out by using an api
https://github.com/adridevelopsthings/latex-template-server
Last synced: about 1 year ago
JSON representation
Host LaTeX templates and fill them out by using an api
- Host: GitHub
- URL: https://github.com/adridevelopsthings/latex-template-server
- Owner: AdriDevelopsThings
- License: agpl-3.0
- Created: 2022-10-17T13:35:10.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-25T09:34:49.000Z (about 1 year ago)
- Last Synced: 2025-03-25T10:28:49.022Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 53.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# latex-template-server
Host LaTeX templates and fill them out by using an api
## Set up
### Docker
**(recommended)**
Just use the docker image (`ghcr.io/adridevelopsthings/latex-template-server:main`) and set up the volumes `/dist/configuration.yml` and `/dist/templates` or just use the [`docker-compose.yml`](docker-compose.yml) in this repository and modify it to your needs.
### From source
Build the server with go: ``go build .``. You also need `pdflatex`.
## Structure of configuration.yml
configuration.yml
```yaml
server:
listen:
host: 0.0.0.0
port: 80
template_path: "templates" # directory which hosts all LaTeX templates, "templates" = default value
tmp_directory: "tmp" # "tmp" = default value
```
## Create a LaTeX template
Just create a file with the name `YOUR_TEMPLATE_NAME.tex` in the template directory configured in the `config.yml` file. Here is an example for a LaTeX file that needs two parameters: `firstname` and `lastname`:
```
\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage{datatool}
% you don't have to generate this csv file, the csv file is generated for any api request
\DTLloaddb{data}{data.csv}
\begin{document}
\DTLforeach{data}{
\Firstname=firstname,
\Lastname=lastname}{
Your name is \Firstname \Lastname
}
\end{document}
```
## Making api requests
You can generate a PDF file from a LaTeX template:
```
POST /template/YOUR_TEMPLATE_NAME HTTP/1.1
Content-Type: application/json
{
"arguments": [{
"firstname": "Robert",
"lastname": "Smith"
}]
}
```
A response does look like this:
```
HTTP/1.1 200 OK
Content-Type: application/pdf
...
```