

NOTE:- on the second line I use gswin64 C.exe and with -o there is no need for batch or nopause and I retain your -dNOSAFER since I trust your. Gswin64c.exe -dNOSAFER -sDEVICE=pdfwrite -o "c:\path\test.pdf" "c:\path\test.ps" So in answer to the original question How to use Ghostscript to convert TXT to PDF? IF you installed the Hi Resolution 4000dpi Ghostscript Print driver you can use in just two lines:- "%ProgramFiles%\Windows NT\Accessories\WORDPAD.EXE" /pt "c:\path\test.txt" "Ghostscript PS" "Ghostscript PS" "c:\path\test.ps" However, only files that can be viewed well in WordPad can print a reasonable PDF with styled text and images. You will normally be asked to provide the folder and filename and it is possible to set your own copy of the MS PDF driver to save to a fixed filename, so as to avoid the port output prompting.īUT with WordPad we can more easily specify the output filename:- "%ProgramFiles%\Windows NT\Accessories\WORDPAD.EXE" /pt "c:\path\test.txt" "Microsoft Print to PDF" "Microsoft Print to PDF" "c:\path\test.pdf" It should then flash through notepad as the default text handler.Īt this point most windows users say but I want it automated with xyz formatting! Well Windows users have two inbuilt text handlers and WordPad is the more powerful one that allows for RichTextFormatting (RTF).Ĭ:\Windows\NOTEPAD.EXE /pt test.txt "Microsoft Print to PDF"

Thus the simplest way of all in Windows, using either the Ghostscript based print driver OR even more simply if the "Microsoft Print to PDF" driver, is default Right Click a TXT file and select Print. The above methods are akin to simple printing a text file into a file.pdf. We could also build a specific Polyglot of the text with a PostScript programable header to process through Ghostscript e.g. However, there are many ways to feed text to Ghostscript since it is part of a larger package called GhostPDL which includes print drivers that can output to different formats, and we can use PDL printing to build multiformat converters.Īn alternative method is to use a PostScript program to process the text file and there is an example described in How to modify this plaintext-to-PDF-converting PostScript from 1992 to actually specify a page size? not filename.txt Thus the very short answer to your question would be NO! Thus we see it is designed to accept filename.ps or filename.pdf i.e. Input formats: PostScript PostScriptLevel1 PostScriptLevel2 "Ghostscript is an interpreter for PostScript® and Portable Document When you run one of the executable commands GS -h (= help)
