<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Joli aman</title>
    <description>The latest articles on DEV Community by Joli aman (@joli_aman_6859baff11d7105).</description>
    <link>https://dev.to/joli_aman_6859baff11d7105</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4195284%2Fc92aacc1-69f0-4a19-a145-1a334ea1dff7.png</url>
      <title>DEV Community: Joli aman</title>
      <link>https://dev.to/joli_aman_6859baff11d7105</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joli_aman_6859baff11d7105"/>
    <language>en</language>
    <item>
      <title>TXT to PDF: 4 ways developers actually do it (CLI, Python, and no-install)</title>
      <dc:creator>Joli aman</dc:creator>
      <pubDate>Tue, 20 Oct 2026 04:54:27 +0000</pubDate>
      <link>https://dev.to/joli_aman_6859baff11d7105/txt-to-pdf-4-ways-developers-actually-do-it-cli-python-and-no-install-2ln0</link>
      <guid>https://dev.to/joli_aman_6859baff11d7105/txt-to-pdf-4-ways-developers-actually-do-it-cli-python-and-no-install-2ln0</guid>
      <description>&lt;p&gt;Need a plain &lt;code&gt;.txt&lt;/code&gt; 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Pandoc: the fastest CLI option
&lt;/h2&gt;

&lt;p&gt;If you live on the command line, Pandoc is the go-to document converter. Install it with your package manager (e.g. &lt;code&gt;sudo apt install pandoc&lt;/code&gt; or &lt;code&gt;brew install pandoc&lt;/code&gt;), then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pandoc notes.txt &lt;span class="nt"&gt;-o&lt;/span&gt; notes.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pandoc notes.txt &lt;span class="nt"&gt;-o&lt;/span&gt; notes.pdf &lt;span class="nt"&gt;--pdf-engine&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;xelatex &lt;span class="nt"&gt;-V&lt;/span&gt; geometry:margin&lt;span class="o"&gt;=&lt;/span&gt;1in
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Great for: one-off conversions, Makefiles, and quick CLI work.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Python + fpdf2: scripted and batch conversion
&lt;/h2&gt;

&lt;p&gt;When you need to convert files in a pipeline, a tiny Python script wins. Install fpdf2 once:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;fpdf2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fpdf&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FPDF&lt;/span&gt;

&lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FPDF&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_page&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set_font&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Helvetica&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;notes.txt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;multi_cell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rstrip&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;output&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;notes.pdf&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Loop it over a directory and you get batch conversion, with page numbers, headers, or footers thrown in for free.&lt;/p&gt;

&lt;p&gt;Great for: automation, CI pipelines, and custom formatting.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. LibreOffice headless: no new tools needed
&lt;/h2&gt;

&lt;p&gt;If LibreOffice is already on the machine, its headless mode converts files without opening a window:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;soffice &lt;span class="nt"&gt;--headless&lt;/span&gt; &lt;span class="nt"&gt;--convert-to&lt;/span&gt; pdf notes.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Great for: servers and machines that already have an office suite.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. No install at all: convert in the browser
&lt;/h2&gt;

&lt;p&gt;Sometimes you just need one file converted right now and do not want to install anything. Open a browser-based converter, upload your &lt;code&gt;.txt&lt;/code&gt;, and download the resulting PDF. To &lt;a href="https://txttopdfconverter.com" rel="noopener noreferrer"&gt;turn a text file into a PDF&lt;/a&gt;, just drag the file in, wait a few seconds, and grab the download -- nothing to install, nothing to configure.&lt;/p&gt;

&lt;p&gt;Great for: quick one-offs on a machine you do not control.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

</description>
      <category>pdf</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
