View Single Post
Old 04-20-2012, 09:18 AM   #22
slex
Addict
slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.
 
Posts: 294
Karma: 1196776
Join Date: Nov 2008
Location: Bulgaria
Device: Kindle 4 NT, Onyx Boox M92
Quote:
Originally Posted by Randy11 View Post
Hi,
How do you make the conversion PDF->DJVU ?
I'm interested in a solution for Linux, if possible.
Thanks
Variant 1
----------
pdf2djvu filename.pdf -o filename.djvu

This is quick and dirty, but it doesn't produce the best results (more suitable for conversion of text-based pdfs). The output djvu file is comparable in size with the original pdf.

Variant 2
----------
You can get better results if you put the pdf file in a separate directory. Then

pdfimages filename.pdf f

This will produce image files named f-001.pbm (if the pdf is black and white) ... or f-001.ppm (if it has color).

You have several options from then on.

Variant 2A
~~~~~~
Find a copy of the windows program DjVuSolo and install it with Wine. It works without any problems.

Then, if you have PBM files, you can add them directly to DjVuSolo. You choose File->Open->Type of file (pnm file) and select the first page. After the first page is added you go to Edit->Append Pages->Type of file (pnm file) and select all the other files by clicking on the second image file, then press the down arrow while holding shift until you select all the pages (if there are lots of pages, the program might appear to freeze - it doesn't - just give it some time - sometimes more than 5 minutes for a full-sized book of several hundred pages). After all the pages have been added, go to File-> Encode as DjVu -> Bundled -> [give the file a name and write it with the extension .djvu] -> Resolution (leave the default value - the program usually detects it), e.g. 300 and choose Bitonal from the radio button options.

The output file will be much smaller than the original pdf - probably 10 times - without visible loss of quality.

Variant 2B
~~~~~~

Get the program gscan2pdf from the repositories.

You can add pbm files directly into gscan2pdf. Then export as djvu. The file will be smaller than the original pdf - probably 2-3 times - but you are unlikely to achieve the compression in Variant 2A.

Variant 3
----------
Parse the image files through ScanTailor. This will produce the best results, but it is more time consuming. First, convert the files, so that they can be recognized by the program.

mogrify -format png *.pbm

Then add the directory with the png files into ScanTailor. After you process them, you will get files in a subdirectory called "out/". Add the files there into gscan2pdf or DjVuSolo. Export to djvu.
slex is offline   Reply With Quote