Does somebody know any other method other then using FPDF lib while trying to convert notepad to pdf format? I have some problems with it, so I am trying to find alternative.
-
What do you mean by *Convert notepad to pdf format*? And what kind of problems do you have? – Berend Jan 18 '22 at 15:57
-
@Berend I want to convert notepad (.text file) to pdf file (.pdf format) and do it without using FPDF lib, I thing it is quite simple question.. so not really sure what you dont understand? – SomeGuy Jan 18 '22 at 16:01
-
Maybe because 'Notepad' is not the same as 'A text file'? – Berend Jan 18 '22 at 16:02
-
so what it is then? Dragon? – SomeGuy Jan 18 '22 at 16:03
-
Not sure what you mean by Dragon. Notepad usually refers to the Notepad application (on Windows). So if you want to 'Convert notepad' it is not clear –to me at least– what you want to accomplish. – Berend Jan 18 '22 at 16:05
-
I have notepad (windows application) with text... I want to change it to pdf file. And I dont want to use FPDF library which is used on every thread on this topic, so I am asking, if somebody know another way, that I cant find. In short convert notepad to pdf. – SomeGuy Jan 18 '22 at 16:14
-
In that case, install a pdf printer and print the textfile from Notepad. – Berend Jan 18 '22 at 16:15
-
-_- I not that stupid, that I would try to build script for few txt files, I need to do that with thousands of files.. daily. – SomeGuy Jan 18 '22 at 16:19
-
https://stackoverflow.com/questions/44619926/windows-10-print-to-pdf-from-command-line – Berend Jan 18 '22 at 16:21
1 Answers
It can be done as a one line python shell command using NotePad (and improved by poking registry values for fonts etc) you can see a discussion here https://stackoverflow.com/a/67696473/10802527 In Windows 7 there are two prime exes to chose from (8 in total !!)
c:\Windows\notepad.exe
c:\Windows\System32\notepad.exe
basically using an OS call
notepad /pt "file from loop.txt" "PDF printer" "PDF Driver" "filename to save.pdf"
Currently on a machine without the PDF driver so here is the out.xps
You will need to write your code to loop through files names and use the exact printer and driver name (see below) However it is much easier to configure WordPads default settings and use it along these lines, Input could be %1 with %2 for Output.
There are 2 WordPad.exe's to try :-) This is a default American English one:-
%comspec% "C:\Windows\System32\wordpad.exe" /pt "%Input%" "Microsoft Print to PDF" "Microsoft Print to PDF" "%Output%"
OR my Locale British English one, which I target !
"%ProgramFiles%\Windows NT\Accessories\WORDPAD.EXE" /pt %1 "Microsoft Print to PDF" "Microsoft Print to PDF" %2
For a drag and drop wrapper see:-
Doc2PDF.cmd - Convert .Doc(x), .ODT, .RTF or .Txt to PDF & open them in SumatraPDF

- 8,045
- 3
- 14
- 36