3

I have a djvu file of multiple pages. I wonder how to extract a new djvu file that consists of only a subset of multiple pages?

For example, a djvu file has 10 pages, and I would like to extract a new djvu file consisting of pages 3-6 of the original djvu file. Can it be done with some commands of djvulibre, such as djvused, djvm, ...? I am using Ubuntu Linux.

Consider two different cases: extract without removal of pages from the original djvu file, and extract without removal.

Thanks!

4

I would just use: DjVuLibre DjView 4.5 Viewer for DjVu documents. Its GUI has a Save as function under File menu and there one can save a given range of pages into djvu file.

  • How is djview possible to extract multiple pages from a djvu file? – Tim Jan 16 '12 at 17:34
  • it has a feature to only consider a page range in both "export" and "save as" File menu items, as specified; wonder why you didn't accept a perfectly good answer – Michael Shigorin Oct 6 '17 at 17:59
3

I didn't see any way to explicitly save a range of pages, so I opted to delete the rest.

# Extract and save each page in its own file
pages=$(djvused -e 'n' "$if")
for ((i=1; i<=$pages; i++)) ;do
    of="${if%.*}.$(printf "%03d" $i).djvu"
    djvused -e "select $i; save-page-with \"$of\"" "$if"
done

# Remove one page from an existing djvu file
djvm -delete "$if" 2 # remove page 2

# Save pages 3-6 to a new file, by removing 
#   all other pages from a copy of the original
from=3; to=6
of="${if%.*}.$from-$to.djvu"
cp "$if" "$of"  
pages=$(djvused -e 'n' "$of")
for ((i=$pages; i>$to; i--)) ;do  djvm -delete "$of" $i ;done
for ((i=1;    i<$from; i++)) ;do  djvm -delete "$of" 1  ;done
1

A simpler series of shell statements to achieve bundled DjVU splitting:

mkdir -- 'mydoc/' &&
djvmcvt -i 'mydoc.djvu' 'mydoc/' 'new-mydoc-index.djvu'

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.