• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How to print Man pages in colors ?

Nicola Mingotti

Active Member

Thanks: 95
Messages: 199

#1
Hi,

I like to read man pages one the web in colors as in:
https://www.freebsd.org/cgi/man.cgi

I would like to have some of them in pdf, in colors
as well. Is it possible?

I tried to export them to pdf via browser but they don't come well formatted.
I saw the option of exporting to "pdf" in freebsd.org, there
they come very well formatted but not in colors.

Bye
Nicola
 

mrclksr

Active Member

Thanks: 92
Messages: 125

#2
I would like to have some of them in pdf, in colors
as well. Is it possible?
Hi Nicola Mingotti ,

Code:
#!/bin/sh

mandoc -T ps | awk 'BEGIN {
   link = "0.72 0.07 0.03";
   bold = "0.6 0.4 0";
   italic = "0.0 0.5 0.07";
   normal = "0 0 0";
}
{
   if ($0 ~ /\/Times-Bold/) {
       print bold " " "setrgbcolor";
   } else if ($0 ~ /\/Times-Roman/) {
       print normal " " "setrgbcolor";
   } else if ($0 ~ /\/Times-Italic/) {
       print italic " " "setrgbcolor";
   }
   print $0;
}' | ps2pdf -
Example
Code:
% zcat /usr/share/man/man1/mandoc.1.gz | ./colorman > mandoc.pdf
 
Top