Going round in circles, is this possible?
This works, but is fugly:
convert TEXT:file.txt file.pdf
Going round in circles, is this possible?
This works, but is fugly:
convert TEXT:file.txt file.pdf
I’d look into Pandoc or LaTeX, depending on your needs.
If you have LibreOffice installed on your system, then its command line utility can convert a text
file to a PDF. For example, this command converts file.txt to file.pdf:
soffice --convert-to pdf file.txt
Up until now, I would have done a copy / paste into LibreOffice writer, then exported it out to PDF.
I will be using your CLI comand in the future. It is in my “Brain” book already. Thanks.
Pudge
Never in a million years did I soffice –help (or man soffice) –brilliant to know.
my swiss army pdf tool (pdfunite) does not do .txts
I do have questions, Does LibreOffice preserve the mono font in the .txt file? Does it force the .txt file into a standard Letter (USA 8.5 X 11) or Euro A4? Does it do any formatting at all between txt to pdf?
edit: a redundancy
There are two options that I can suggest, both of them are in AUR.
Both cant be installed as they create a conflict. Select one of them see how it works for you and then try out the other. Finally finalize on one of them.
I typically use LibreOffice for text file conversion to PDF. But it seems that you seek some automation and/or programmatically solution. Let us know what you finalize on and the reasons.
soffice applies the Preformatted Text style from the LibreOffice built-in template for text documents. On a Linux system, the font defined for this style is 10-pt Liberation Mono.
Note that soffice uses this built-in template (and its Preformatted Text style) even if you have set a different default template with the LibreOffice Template Manager (Shift+Ctrl+N). Consequently, soffice always exports raw text to a PDF as 10-pt Liberation Mono. This limitation can be very frustrating.
soffice applies the Default Page style from the LibreOffice built-in template for text documents, which is based on your locale. For North American locales, for example, the generated PDF will always be letter-size with portrait orientation and 0.79-inch margins on all sides. Again, this limitation can be very frustrating.
Unfortunately, no.
pandoc --pdf-engine=pdfroff --output=out.pdf file.md
This works well (I decided markdown was a better option).
thanks for that—what a great tool. love knowing there’s shortcut stuff like this.
/sorry for any hijack
To add to this real quick, markdown is now better when using LibreOffice:
https://alternativeto.net/news/2026/2/libreoffice-26-2-adds-markdown-import-export-better-excel-compatibility-and-speed-boost/
Official source:
I just tested, and the soffice tool included with LibreOffice 26.2 also adds support for markdown. For example, this command converts file.md to file.pdf with appropriate formatting:
soffice --convert-to pdf file.md
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.