7

I can convert man output to PDF. First, man -t grep >grep.ps (grep is just an example; I am not looking for mobile version of grep man page). Then Adobe Distiller converts PostScript to PDF. However, PDF looks terrible on the tablet (can't re-size, etc). I see several programs that convert to mobi and epub formats, but none of them take Postscript as input. Some take PDF as input, but output is usually very difficult to read – even worse than original PDF.

So, how can I convert man output to mobile format (epub, mobi, or fb2)?

  • Change man / groff output to produce something that mobile generators like;

or

  • Convert PS to mobile format; or
  • Some other way that I can't think of...
Anthon
  • 78,313
  • 42
  • 165
  • 222
Felix
  • 245
  • 1
  • 8
  • `man -Tpdf grep > grep.pdf` would do for PDF... at least my Kindle reads PDF fine (and reformatting a man page for page margins _will_ give a mess) – vonbrand Apr 15 '13 at 17:06

1 Answers1

6

You could use the open source software Calibre (http://calibre-ebook.com).

It is available for OSX, Windows, and Linux.

Input Formats: CBZ, CBR, CBC, CHM, DJVU, EPUB, FB2, HTML, HTMLZ, LIT, LRF, MOBI, ODT, PDF, PRC, PDB, PML, RB, RTF, SNB, TCR, TXT, TXTZ

Output Formats: AZW3, EPUB, FB2, OEB, LIT, LRF, MOBI, HTMLZ, PDB, PML, RB, PDF, RTF, SNB, TCR, TXT, TXTZ

I think for the best results you just output the man page to html using a manpage-to-html converter: http://dcssrv1.oit.uci.edu/indiv/ehood/man2html.html.

Vincent
  • 2,778
  • 6
  • 23
  • 28
  • I looked at Calibre; love it! then the question becomes, how do I create man output in RTF, instead of PS? – Felix Apr 15 '13 at 02:55
  • I was a bit to fast. I think if you want to keep the formatting, you could export the man file to html (before the conversion to ePub): http://linux.die.net/man/1/man2html Would that be an option? – Vincent Apr 15 '13 at 02:58
  • yes, I was not aware of such utility! – Felix Apr 15 '13 at 03:02
  • 1
    There are two different `man`s used on linux. One of them has a `man -H` option that will render the page in $BROWSER as html, which you can then save. – goldilocks Apr 15 '13 at 09:04
  • That is a very helpful! – Vincent Apr 15 '13 at 13:56
  • @goldilocks - could you expand? `man -H` doesn't by itself produce HTML, it just overrides htmlpager variable. In any event the simple way `man grep | man2html > grep.html` didn't work. Fortunately, [somebody else](http://benbiddington.wordpress.com/tag/bash/) figured it out: `gzip -dc $(man -w grep) | man2html >grep.html` works fine – Felix Apr 16 '13 at 16:44
  • @Felix : Okay, that's the older `man` then; with the newer one (tends to be the default on .rpm derived systems; it maybe an alternative elsewhere and the package is probably *mandb*), `man -H` pipes through groff with html as the output device, creates a tmp file, passes the tmp file name to $BROWSER and then deletes the tmp file when the browser command returns. Net effect: you get a nice html page pop up in your browser. All the css stuff is in the header, so you can save that page from the browser and use it, I've done this for online docs before. – goldilocks Apr 16 '13 at 17:29
  • Here's the (outdated) homepage(?) for man-db, lol: http://man-db.nongnu.org/ which does not mention the -H switch and for some weird reason calls it "the online manual database". It's not online for normal systems, and if you have a current version installed the -H is documented. As mentioned pretty sure most distros offer this at least *as an option* -- ie, it's a drop in replacement with better functionality. – goldilocks Apr 16 '13 at 17:34
  • Maybe a better page: http://linuxappfinder.com/package/man-db I think the package name will actually be `man-db`, not mandb. – goldilocks Apr 16 '13 at 17:40
  • Calibre allow you to convert to html (`htmlz`) (The second link is dead.) – GAD3R Jul 07 '18 at 12:51