Need a plain .txt file as a PDF -- a README, some logs, meeting notes, a report? Here are four ways developers actually do it, from the terminal to zero installs. Real solutions first.
1. Pandoc: the fastest CLI option
If you live on the command line, Pandoc is the go-to document converter. Install it with your package manager (e.g. sudo apt install pandoc or brew install pandoc), then:
pandoc notes.txt -o notes.pdf That is the whole command. Pandoc reads the text and renders a clean PDF. Want nicer margins or a different font? Add a couple of flags:
pandoc notes.txt -o notes.pdf --pdf-engine=xelatex -V geometry:margin=1in Great for: one-off conversions, Makefiles, and quick CLI work.
2. Python + fpdf2: scripted and batch conversion
When you need to convert files in a pipeline, a tiny Python script wins. Install fpdf2 once:
pip install fpdf2 Then:
from fpdf import FPDF pdf = FPDF() pdf.add_page() pdf.set_font("Helvetica", size=11) with open("notes.txt") as f: for line in f: pdf.multi_cell(0, 5, line.rstrip()) pdf.output("notes.pdf") Loop it over a directory and you get batch conversion, with page numbers, headers, or footers thrown in for free.
Great for: automation, CI pipelines, and custom formatting.
3. LibreOffice headless: no new tools needed
If LibreOffice is already on the machine, its headless mode converts files without opening a window:
soffice --headless --convert-to pdf notes.txt The PDF lands in the current directory. It works on Linux, macOS, and Windows, which makes it a reliable fallback in scripts where installing new packages is a hassle.
Great for: servers and machines that already have an office suite.
4. No install at all: convert in the browser
Sometimes you just need one file converted right now and do not want to install anything. Open a browser-based converter, upload your .txt, and download the resulting PDF. To turn a text file into a PDF, just drag the file in, wait a few seconds, and grab the download -- nothing to install, nothing to configure.
Great for: quick one-offs on a machine you do not control.
Wrapping up
For speed, reach for Pandoc; for automation, script it with Python; for machines with an office suite already installed, go headless with LibreOffice; and for the occasional one-off, the browser has you covered. Pick the option that matches where you are, and turning TXT into PDF stops being a chore.
