'Linux - Command a2ps For PDF File

it is possible to print a PDF file with the a2ps command? If someone could give me an example set?



Solution 1:[1]

The a2ps and enscript commands are both intended to write PostScript files (which is the meaning of the 'ps' letters in a2ps). If you are happy with the output of a2ps and want to convert it to PDF format, you have to convert the Postscript output itself to PDF with:

ps2pdf output.ps

which will create a file called output.pdf. If you want to focus rather on the idea of directly create PDF documents, there are some more recent alternatives.

I wrote myself a Python program called txt2pdf; you may find it here. Have also a look at tools like pandoc, gimli, rst2pdf or wkhtmltopdf but you may have to change slightly your workflow.

Solution 2:[2]

In certain customized installations, a2ps may offer a -P pdf flag, but this is not standard, e.g. Debian Linux does not come with such a configuration.

Solution 3:[3]

There is also a u2ps utility requiring Perl and GhostScript that may do as well.

Solution 4:[4]

A bit late, but you can generate a PDF in one command using pipes like so.

a2ps some_file.py -o- | ps2pdf - out.pdf

The -o- option tells a2ps to write the result to STDOUT; the - option tells ps2pdf to read from STDIN.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Thomas Baruchel
Solution 2 mao
Solution 3 jarnosz
Solution 4 sebastian