0

Ever since I first learned about PDF in the early 2000s, I've been searching on and off for software to automate the conversion of various documents formats to such a .pdf file. I've tried numerous "solutions" which have been complete garbage.

Not many years ago, I went through every single obscure library/program in existence and they were all broken beyond belief. Since then, I have entirely given up on the idea to ever be able to convert a HTML+CSS document to a PDF, because if such a thing exists at all, it definitely costs money, and I cannot pay money.

Everything sucks when you don't have money.

So now, my demands are extremely low: all I want is to turn a .txt with a proportional font (monospace/Courier New) and fixed column width to be turned into a PDF, so that it can be printed or shared as a PDF.

It must be automatic, but doesn't need to be using PHP at all. PHP is just what I use to script it. I'm perfectly fine with it using a command-line EXE of some kind, and in fact, I expect it.

I doubt that Windows 10 has something like this built in, but if such is the case, it would of course be very nice to not have to install anything. The only other thing I have installed which might be relevant is Pale Moon.

I want to do something like this in cmd.exe:

txt_to_pdf.exe -i "input.txt" -o "output.pdf"

Is there such a thing? I mean, the year is 2020... and I'm literally not expecting one bit of "styling" except to be able to set/recommend a font and font size. The text file has 80-char columns with blank spaces wherever there is no actual text content.

1

I think you are looking for pandoc - the universal document converter.

I just tried this command, and it created a PDF from the txt.

pandoc -i my-upgrade-notes.txt -o my-upgrade-notes.pdf

0

A convenient option on Windows is to install a free PDF printer driver. Then fire up Word or any other application that will open up a document and choose Print from the File menu or press Ctrl-p. Choose PDF as the printer and the location where the PDF will save to. It is difficult recommend any particular one since it's been a long time.

These days, it has been a pleasure to use a version of Linux that has PDF printing built-in (It comes with the installed "cups" printing package).

0

Check out pfftk. It is command line and works well. You can also look into pdf creator, a free pdf printer that allows you to create pdf files from any input including html+css.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.