I've got some documents in DjVu which I'll like convert to PDF. Is there a way to do this using command line OSS tools?
7 Answers
djvu2pdf should fit the bill, it's a small script that makes use of the djvulibre toolset. If not, there are other methods that require multiple command-line tools.
5The ddjvu program
(which is part of the standard djvulibre package) will do this:
$ ddjvu -format=pdf -quality=85 -verbose a.djvu a.pdfWarning: this produces large files (but PDF files made by Christoph Sieghart's script are of the same size).
I also wrote the following small shell script some years ago.
It does the same automatically. (Save this as djvu2pdf.sh.)
#!/bin/sh
# convert DjVu -> PDF
# usage: djvu2pdf.sh <file.djvu>
i="$1"
echo "------------ converting $i to PDF ----------------";
o="$(basename "$i" .djvu).pdf"
echo "[ writing output to $o ] "
ddjvu -format=pdf -quality=85 -verbose "$i" "$o"The djvu2pdf script by Christoph Sieghart does essentially the same.
What about simply using DJView and export as PDF?
- Goto Synaptic Package Manager (System - Administration - Synaptic Package Manager)
- Install DJview4
- Run DJview (Applications - Graphics - DJView4)
- Open your .djvu document
- Menu - Export As: PDF
Look at
1$ djvups input.djvu | ps2pdf - output.pdfIn my case the output file was 10x smaller than with ddjvu. Both djvups and ps2pdf present in ubuntu repository.
$ sudo apt-get install djvulibre-bin ghostscriptI've found this method in man ddjvu, so always read manuals ;)
3An alternate way to produce PDF file consists in first using djvups(1) and convert the resulting PostScript file to PDF. Which method gives better results depends on the contents of the DJVU file and on the capabilities of the PS to PDF converter.
If you don't care about colors and images you can get much smaller files if you drop the colors and use instead:
ddjvu -format=pdf -mode=blackinput.djvu output.pdf
Texts, codes and formulas looks perfectly, but most of the images are gone
I've changed the @Maxim script a little ...
#!/bin/bash
# convert DjVu -> PDF
# usage: djvu2pdf.sh [-q quality | -b] <infile.djvu> [outfile.pdf]
mode='color'
quality=80
aparse() { while [ $# != 0 ] ; do case "$1" in -q|--quality) quality=${2} shift ;; -b|--black) mode='black' ;; esac shift
done
}
aparse "$@"
i="$1"
o=${2:-$(basename $i .djvu).pdf}
if [ -f "$o" ]; then echo "file $o exists, override [Y/n]?" read ans case "$ans" in n|N) exit 1;; esac
fi
echo "[ converting $i to $o ] "
cmd="ddjvu -format=pdf -quality=$quality -mode=$mode -verbose $i $o "
echo "[ executing $cmd ] "
$cmd For MacOS users you can install djvu2pdf like this:
$brew install djvu2pdf How to use it(works for any Xnix like system):
$djvu2pdf nameBook.djvu nameBookToCreate.pdf