4 ms·
Luckily I haven't had the need to create pdfs yet now that I'm using Go. However, if I would, I would generate LaTeX instead of PDFs directly. I did the same in
by JelteF 9y ago
Luckily I haven't had the need to create pdfs yet now that I'm using Go. However, if I would, I would generate LaTeX instead of PDFs directly. I did the same in Python a and it has turned out great: https://github.com/JelteF/PyLaTeX https://github.com/JelteF/PyLaTeX
The API can be made much more high level, because of all functionality and packages LaTeX has. The most important thing is to have a good escape function that is used by default for all text, otherwise it's very easy to execute arbitrary shell commands for an attacker. If anyone wants to create a Go package similar to mine, feel free to contact me if you want any more advice (email in github profile).
- nine_k 9y agoThat "no dependencies" thing is important sometimes. Latex is a large dependency.
- JelteF 9y agoI agree that sometimes not having dependencies is important and that's definitely a big feature of this library. However, in my experience it is more desirable in many cases to have clear code. You basically get this for free when by using LaTeX, because you create documents at a higher level than writing raw pdfs. Another big advantage ia that you can make use of its vast package ecosystem, which allows you to for instance create beautiful tables that span multiple pages with ease. It definitely is a large, and more importantly external, dependency though. However, if you control the installation environment of your software this isn't really a problem. For all use cases where I had to generate pdfs this was the case (webapps and local one off scripts).
- simooooo 9y agoI agree. No dependencies is nice, but you step into a myre of dealing with low level pdf faffery. I'd rather let a very robust external tool with proven reliability
- kibibu 9y agoThat is a large understatement. TexLive is like 4GB
- JorgeGT 9y agoThis. We used a similar approach in my lab (but in MATLAB) to build reports of a certain experiment. The experiment generated a large amount of data daily; MATLAB was used to ingest and process the data, producing the necessary vector figures and tables and then called a pdfLaTeX template that produced the final, beautiful PDF report. Finally, the script sent the report by mail to our inboxes.