DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Looking for freeware command line text to PDF  (Read 22,159 times)

AzureToad

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 101
Looking for freeware command line text to PDF
« on: August 02, 2019, 06:54 PM »
I found TXT2PDF referenced in a couple places, including this DonationCoder post, and I tried pulling a copy from VeryPDF.com, but was blocked (unsafe?).

Does anyone have experience with a freeware CLI text-to-PDF converter that can be run from a Windows batch script? And a URL to a "safe" download would be fab!

Lintalist

  • Participant
  • Joined in 2015
  • *
  • Posts: 122
Re: Looking for freeware command line text to PDF
« Reply #1 on: August 02, 2019, 09:33 PM »

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,565
Re: Looking for freeware command line text to PDF
« Reply #2 on: August 02, 2019, 10:54 PM »
^ Pandoc needs 3'rd party application, before it can create pdf.

AzureToad

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 101
Re: Looking for freeware command line text to PDF
« Reply #3 on: August 02, 2019, 10:57 PM »
^ Pandoc needs 3'rd party application, before it can create pdf.
Yeah, I'm running the Tex Live Installer now, even as we speak.  Holy smoke, about 1/3 of the way through install and it's only been...  let's see... an hour and 5 minutes!  :huh: 
I don't think I've EVER seen an install take this long!

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,954
Re: Looking for freeware command line text to PDF
« Reply #4 on: August 03, 2019, 12:23 AM »
Pandoc can be quite daunting to get the conversion right. Lots of features and options to choose from. MikTex is another software piece to try with Pandoc. Was a 200MByte download at the time, but worked well enough for what I needed it to do.

At least it wasn't an online installer, which can be affected by anything and waste a lot of time.
The easy path is usually downhill...

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
Re: Looking for freeware command line text to PDF
« Reply #5 on: August 03, 2019, 01:05 PM »
As long as your text is formatted beforehand, (it will truncate lines that don't fit your chosen output dimensions), then txt2pdf, (just another of many), is lightweight and fast.

Quote
TXT2PDF
TXT2PDF is a command-line tool for encoding ASCII as PDF. See the "ReadMe" file included with the zip for options and usage.

Example of calling TXT2PDF:

txt2pdf -i"C:\temp\my ASCII file.txt" -o"C:\temp\pdfout.pdf" -w17 -h11
In this example, txt2pdf reads a file ("my ASCII file.txt") and writes it to a pdf ("pdfout.pdf"). The "-w" switch defines the page width as 17 inches; the "-h" switch defines the page height as 11 inches. Note that there are no spaces bewteen the flags and the associated parameters. See the ReadMe file for details.
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 11,205
    • Participated in NANY Challenge Fourteen Times
    • Coding Snacks
    • Writer
    • Hardware Hacker
Re: Looking for freeware command line text to PDF
« Reply #6 on: August 03, 2019, 02:25 PM »
As long as your text is formatted beforehand, (it will truncate lines that don't fit your chosen output dimensions), then txt2pdf, (just another of many), is lightweight and fast.

Quote
TXT2PDF
TXT2PDF is a command-line tool for encoding ASCII as PDF. See the "ReadMe" file included with the zip for options and usage.

Example of calling TXT2PDF:

txt2pdf -i"C:\temp\my ASCII file.txt" -o"C:\temp\pdfout.pdf" -w17 -h11
In this example, txt2pdf reads a file ("my ASCII file.txt") and writes it to a pdf ("pdfout.pdf"). The "-w" switch defines the page width as 17 inches; the "-h" switch defines the page height as 11 inches. Note that there are no spaces bewteen the flags and the associated parameters. See the ReadMe file for details.

That's the same name as the utility quoted in the original post.  Is it the same utility?  Or just another by the same name?

x16wda

  • what am I doing in this handbasket?
  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
    • Participated in NANY Challenge Once
Re: Looking for freeware command line text to PDF
« Reply #7 on: August 03, 2019, 02:55 PM »
Two completely different products:

08/03/2019  09:10 AM            25,130 txt2pdf.zip
08/03/2019  10:52 AM          852,893 verypdf-free-txt2pdf.exe

Neither is blocked for me, and VirusTotal does not complain about either.
vi vi vi - editor of the beast

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
Re: Looking for freeware command line text to PDF
« Reply #8 on: August 03, 2019, 08:13 PM »
That's the same name as the utility quoted in the original post.  Is it the same utility?  Or just another by the same name?

The OP references a post by me which includes a quote by jity2 which mentions "txttopdf.exe" - different name, (txt2pdf not mentioned in that whole thread - typo or mis-link?).

There are multiple versions of executables called txt2pdf including this one from Sourceforge but it puts up a requester when it finishes which makes it unsuitable for CLI batch use.

The one I linked is just a search result, (that I tested against a few files), that lets you also specify a few output options that should cover the majority of cases for simple text conversion.  As a bonus its website tested clean against VirusTotal.

In theory, you could do it all using PowerShell, for example, this code from TechNet, but I could only get it to produce blank PDFs and after staring at it for 30 minutes and not being able to work out what the hell was happening, decided it was easier to use the results of the Google search :-\ ... why reinvent the wheel?
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903

Original address: https://www.donationcoder.com/forum/index.php?topic=48304.0