This is a djvu version of the questions I asked before for pdf files. I have tried a similar idea as fred has given to the previous question. But I am now stuck at how to get the number of pages of a djvu file, because I don't know which command can be used for that purpose.

For the sake of completion, I now just rephrase the question here:

I was wondering if there are some ways to extract title and pagenum of each page in a djvu file? Either by some applications, or by programming in some programming language with some djvu libraries?

The title of each page is supposed to be the first line of the page, for example, in slides/presentation files.

The output is supposed to be a text file, with following format:

title_of_first_page pagenum_of_first_page
title_of_second_page pagenum_of_second_page

Thanks and regards!

  • evince --page-label=1 (where '1' is page number 1) displays the page, but I don't have any .djvu files which contain text, do I can't test it any further... – Peter.O Sep 13 '11 at 2:12
  • @fred: Thanks! An example with text download1336.mediafire.com/cy2gv2hc7qkg/5860xlbkw3asvk1/… – Tim Sep 13 '11 at 2:22
  • I mis-judged page-label. It opens a djvu document for preview at the specified page... (I'm still looking at the issue with the document you provided) – Peter.O Sep 13 '11 at 2:34
  • @fred: I am mostly using djview to view djvu files. I suspect the program I am looking for may be based on djvulibre, such as djvused, djvm, etc. But I cannot find the right one. – Tim Sep 13 '11 at 3:18

Similar to the .pdf example, the following script will print the first line of text found on a given page (via head -n 1). You can see the available commands by typing djvused --help in the terminal.

djvused is in the package djvulibre-bin

if="$HOME/Downloads/The Geometry of Exponential Families.djvu"
pages=$(djvused -e 'n' "$if")
for ((i=1; i<=$pages; i++)) ;do
    printf "%s %d\n" "$(djvused -e 'select '$i'; print-pure-txt' "$if" | head -n 1)" $i
  • Thanks! I wonder if djvused -e 'select pagenum; print-pure-txt' djvufile can only convert a single page into text, i.e. can djvused convert several pages by one call to the command? – Tim Sep 13 '11 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.