Tutorial: bulk pdf to djvu conversion

Here is where you can post tips and tricks to share with other users of MX. Do not ask for help in this Forum.
Post Reply
Message
Author
User avatar
manyroads
Posts: 2622
Joined: Sat Jun 30, 2018 6:33 pm

Tutorial: bulk pdf to djvu conversion

#1 Post by manyroads »

Should you wish to perform bulk conversion of pdf files to djvu, the following 3 step process will accomplish the task:

First, install pdf2djvu.

Code: Select all

 apt-get install pdf2djvu
Second run this command from a termial session started in the directory containing your pdf files.

Code: Select all

  for file in *.pdf; do pdf2djvu -o "${file%.pdf}.djvu" "$file"  --no-page-titles; done

Edit: (per @fehlix's recommendation) step 2 & 3 are now combined into a single step!


References:
https://askubuntu.com/questions/270289/ ... n-a-folder
https://github.com/jwilk/pdf2djvu/issues/113
Last edited by manyroads on Sun Jan 27, 2019 8:03 pm, edited 1 time in total.
Pax vobiscum,
Mark Rabideau - ManyRoads Genealogy -or- eirenicon llc. (geeky stuff)
i3wm, bspwm, hlwm, dwm, spectrwm ~ Linux #449130
"For every complex problem there is an answer that is clear, simple, and wrong." -- H. L. Mencken

User avatar
fehlix
Developer
Posts: 10366
Joined: Wed Apr 11, 2018 5:09 pm

Re: Tutorial: bulk pdf to djvu conversion

#2 Post by fehlix »

manyroads wrote: Sun Jan 27, 2019 4:31 pm

Code: Select all

 for file in *.pdf; do pdf2djvu -o "$file.djvu" "$file"  --no-page-titles; done
... can't resist ... :snail:
to avoid the 3rd rename step
adjust conversion step 2 as such:

Code: Select all

 for file in *.pdf; do pdf2djvu -o "${file%.pdf}.djvu" "$file"  --no-page-titles; done
:puppy:
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

User avatar
Jerry3904
Administrator
Posts: 21932
Joined: Wed Jul 19, 2006 6:13 am

Re: Tutorial: bulk pdf to djvu conversion

#3 Post by Jerry3904 »

@many: thanks!
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox and Windows 10
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

bled
Posts: 58
Joined: Mon Mar 07, 2016 1:06 pm

Re: Tutorial: bulk pdf to djvu conversion

#4 Post by bled »

gentlemans!!!
in debiandog we have single click converter
(as thunar custom action and gui app)


http://murga-linux.com/puppy/viewtopic. ... start=1365

User avatar
fehlix
Developer
Posts: 10366
Joined: Wed Apr 11, 2018 5:09 pm

Re: Tutorial: bulk pdf to djvu conversion

#5 Post by fehlix »

bled wrote: Sun Jan 27, 2019 7:19 pm gentlemans!!!
in debiandog we have single click converter
(as thunar custom action and gui app)


http://murga-linux.com/puppy/viewtopic. ... start=1365
Thanks, the script provided in that link in Thunar custom actions looks nice:
pdf-to-djvu

Code: Select all

#!/bin/bash

OLDIFS="$IFS"
IFS=$'\n'

for PDF in "$@"; do
FILE="${PDF%.*}"
echo "Which pages ? e.g. type: 1-6, for all pages, press ENTER"
read pages
if [ -n "$pages" ]; then
pdf2djvu -o "$FILE".djvu "$PDF" --pages=$pages
else
pdf2djvu -o "$FILE".djvu "$PDF"
fi
done

IFS="$OLDIFS"
read -s -n 1 -p "Press any key to close . . ."
I would probaly add a double check, to have it apply only on pdf files.
As currently this script would try to take any file to convert,
so the script will not have only rely onto Thunar-custom action file-rules.
(e.g. just in case you start it from the command line or make the custom action rules wrongly. )
Just change the line add the beginnin of the for loop like
and add a line before this line

Code: Select all

FILE="${PDF%.*}"
to check and do nothing on that file of not a .pdf file:

Code: Select all

[ "${PDF%.pdf}" = "${PDF}" ] && continue
:puppy:
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

User avatar
manyroads
Posts: 2622
Joined: Sat Jun 30, 2018 6:33 pm

Re: Tutorial: bulk pdf to djvu conversion

#6 Post by manyroads »

fehlix wrote: Sun Jan 27, 2019 6:43 pm
manyroads wrote: Sun Jan 27, 2019 4:31 pm

Code: Select all

 for file in *.pdf; do pdf2djvu -o "$file.djvu" "$file"  --no-page-titles; done
... can't resist ... :snail:
to avoid the 3rd rename step
adjust conversion step 2 as such:

Code: Select all

 for file in *.pdf; do pdf2djvu -o "${file%.pdf}.djvu" "$file"  --no-page-titles; done
:puppy:
Fixed. Thank you!
Pax vobiscum,
Mark Rabideau - ManyRoads Genealogy -or- eirenicon llc. (geeky stuff)
i3wm, bspwm, hlwm, dwm, spectrwm ~ Linux #449130
"For every complex problem there is an answer that is clear, simple, and wrong." -- H. L. Mencken

User avatar
manyroads
Posts: 2622
Joined: Sat Jun 30, 2018 6:33 pm

Re: Tutorial: bulk pdf to djvu conversion

#7 Post by manyroads »

manyroads wrote: Sun Jan 27, 2019 8:03 pm
fehlix wrote: Sun Jan 27, 2019 6:43 pm adjust conversion step 2 as such:

Code: Select all

 for file in *.pdf; do pdf2djvu -o "${file%.pdf}.djvu" "$file"  --no-page-titles; done
:puppy:
Fixed. Thank you!
@fehlix This works wonderfully! Vielen dank!!!
Pax vobiscum,
Mark Rabideau - ManyRoads Genealogy -or- eirenicon llc. (geeky stuff)
i3wm, bspwm, hlwm, dwm, spectrwm ~ Linux #449130
"For every complex problem there is an answer that is clear, simple, and wrong." -- H. L. Mencken

User avatar
manyroads
Posts: 2622
Joined: Sat Jun 30, 2018 6:33 pm

Re: Tutorial: bulk pdf to djvu conversion

#8 Post by manyroads »

bled wrote: Sun Jan 27, 2019 7:19 pm gentlemans!!!
in debiandog we have single click converter
(as thunar custom action and gui app)
http://murga-linux.com/puppy/viewtopic. ... start=1365
Thank you very much @bled. This works splendidly! :number1:

I have attached both the script and an image of the installation instructions.
pdf-to-djvu.png
Note: remove the gz extension before moving the script to usr/local/bin
pdf-to-djvu.gz
You do not have the required permissions to view the files attached to this post.
Pax vobiscum,
Mark Rabideau - ManyRoads Genealogy -or- eirenicon llc. (geeky stuff)
i3wm, bspwm, hlwm, dwm, spectrwm ~ Linux #449130
"For every complex problem there is an answer that is clear, simple, and wrong." -- H. L. Mencken

User avatar
manyroads
Posts: 2622
Joined: Sat Jun 30, 2018 6:33 pm

Re: Tutorial: bulk pdf to djvu conversion

#9 Post by manyroads »

In a similar vein, I have added a Thunar Custom Action to magically fix pdfs that are not searchable... and make them searchable. To make this function work, you need to install pdfsandwich (I did that from MXPI stable). Make certain you also have xterm installed, if not then install it fro MXPI stable, as well.

Once you have those guys installed edit your Thunar Custom Actions to look like the following images.
Image1.png
Image2.png
Once those tasks are complete, restart Thunar (open & close it) and you are ready to make your unsearchable pdf files searchable (using Thunar).
You do not have the required permissions to view the files attached to this post.
Pax vobiscum,
Mark Rabideau - ManyRoads Genealogy -or- eirenicon llc. (geeky stuff)
i3wm, bspwm, hlwm, dwm, spectrwm ~ Linux #449130
"For every complex problem there is an answer that is clear, simple, and wrong." -- H. L. Mencken

Post Reply

Return to “Tips & Tricks by users”