Ubuntu ships with this functionality. Try opening gedit
(source: ubuntu.com) orgedit or another GUI text editor and clicking the print button:
When the Print dialog appears, select the "Print to File" printer and select a location for the PDF. After clicking Print, you should end up with a PDF file in that location containing an identical copy of what would have printed on a sheet of paper.