Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I search a way for lossless, reliable and also compressed conversion of pdf files, which contain black and white text scans, to the djvu format. The tool must be a commandline program so I can atomize the conversion. I found that djvulibre but I was not able to make it work with the required drivers on my ubuntu linux (they seem to be separate because of license issues). pdf2djvu has options to adjust the loss level for image compression, but I am not sure if it will always detect the resolution of the source files correctly so that I am afraid that it may create loss due to resampling of the images. Any hints to other software, the resolution of driver issues with djvulibre or the proper use of pdf2djvu are very welcome.

share|improve this question

migrated from Jun 18 '13 at 23:41

This question came from our site for professional and enthusiast programmers.

up vote 1 down vote accepted

You can use xpdf to extract the scan images from inside your PDF files
Then use imagemagick to convert each image into pbm format:

convert page-000.png page-000.pbm

Then convert your pbm images into djvu pages with djvulibre.

cjb2 -clean page-000.pbm page-000.djvu

Finally adding your new page to the final document

djvm -i page.djvu page-000.djvu

The process is partially explained here: Creating a DjVu file

share|improve this answer
Thanks! Will this procedure preserve the page size and the borders in the documents? I ask because in the PDF files the embedded images will not necessarily extend to the edges of the pages. The pdfimages manpage says that the -j option outputs PBM, so we could possibly omit the second step. – highsciguy Jun 19 '13 at 17:55
I don't think it will preserve them, but cannot think on any better way of preserving the original images and create a lossless process. – yms Jun 19 '13 at 18:03
Ok, then the question arises if the borders can be copied separately from the original pdf to the final djvu. Or at least I would need a way to generate djvu which has a given fixed size, say letter or A4, and to justify the pictures on the pages. – highsciguy Jun 19 '13 at 19:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .