Take the 2-minute tour ×
Software Recommendations Stack Exchange is a question and answer site for people seeking specific software recommendations. It's 100% free, no registration required.

Is there any choice for converting source code to pdf for reading?

I'm using Linux Mint and I'm looking for some command line solutions.

share|improve this question
2  
Have you already seen these questions? On StackOverflow, on Unix & Linux.SE and on Ask Ubuntu. –  ComFreek Jun 29 at 19:04

2 Answers 2

up vote 5 down vote accepted

You can install a virtual printer like cups-pdf and print the code:

sudo apt-get install cups-pdf

If this is the only or the default printer in your system, then printing is as easy as:

lpr <file_with_code>

If you're looking for nice formatted code here are the options:

sudo apt-get install code2html

Use this to convert source code file to html file which you can then print using the above command.

If you want a GUI solution, you can use SciTE editor, which can either print directly, convert to rtf and html which then can be printed/converted to pdf.

share|improve this answer
    
I've tried code2html, it worked perfect. And for converting to PDF I've used LibreOffice feature export to PDF, because I don't know where cups-pdf put PDF files. –  Milos Dolobac Jun 30 at 10:53
    
@MilosDolobac look in the ~/PDF folder. –  Cornelius Jun 30 at 11:10

Enscript is a general command that pretty-prints ASCII text. It can even do syntax highlighting for most common languages with the -E option.

Example usage, to typeset a file with 2-up layout and a fancy header in landscape mode, with C++ syntax highlighting:

enscript -2Gr -Ecpp -o output_file.pdf input_file.cpp
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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