Move from pdftk to qpdf
Remove dependency on java
This commit is contained in:
+14
-14
@@ -378,7 +378,7 @@ List of useful programs:
|
|||||||
- =inkscape=
|
- =inkscape=
|
||||||
- =gs=
|
- =gs=
|
||||||
- =pdfcrop=
|
- =pdfcrop=
|
||||||
- =pdftk=
|
- =qpdf=
|
||||||
|
|
||||||
*** PDF to PNG
|
*** PDF to PNG
|
||||||
#+begin_src bash
|
#+begin_src bash
|
||||||
@@ -439,7 +439,7 @@ pdftrim_function() { \
|
|||||||
*** PDF Extract Pages
|
*** PDF Extract Pages
|
||||||
#+begin_src bash
|
#+begin_src bash
|
||||||
pdfextract_function() { \
|
pdfextract_function() { \
|
||||||
if command -v pdftk &> /dev/null; then
|
if command -v qpdf &> /dev/null; then
|
||||||
pages=$(echo -e "get first\ndelete first\nextract i-j" | rofi -i -dmenu -p "Extract pages")
|
pages=$(echo -e "get first\ndelete first\nextract i-j" | rofi -i -dmenu -p "Extract pages")
|
||||||
|
|
||||||
if [ -z "$pages" ]; then
|
if [ -z "$pages" ]; then
|
||||||
@@ -448,21 +448,21 @@ pdfextract_function() { \
|
|||||||
|
|
||||||
case "$pages" in
|
case "$pages" in
|
||||||
"get first")
|
"get first")
|
||||||
if command -v pdftk &> /dev/null; then
|
if command -v qpdf &> /dev/null; then
|
||||||
pdftk "$filename_with_extension" cat 1-1 output "$filename_without_extension.first.pdf"
|
qpdf --pages "$filename_with_extension" 1 -- "$filename_with_extension" "$filename_without_extension.first.pdf"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"delete first")
|
"delete first")
|
||||||
if command -v pdftk &> /dev/null; then
|
if command -v qpdf &> /dev/null; then
|
||||||
pdftk "$filename_with_extension" cat 2-end output "$filename_with_extension"
|
qpdf --pages "$filename_with_extension" 2-z -- "$filename_with_extension" "$filename_with_extension"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"extract i-j")
|
"extract i-j")
|
||||||
# TODO
|
# TODO
|
||||||
page_i=$(rofi -dmenu -p "From")
|
page_i=$(rofi -dmenu -p "From")
|
||||||
page_j=$(rofi -dmenu -p "To")
|
page_j=$(rofi -dmenu -p "To")
|
||||||
if command -v pdftk &> /dev/null; then
|
if command -v qpdf &> /dev/null; then
|
||||||
pdftk "$filename_with_extension" cat "$page_i-$page_j" output "$filename_with_extension.slice.pdf"
|
qpdf --pages "$filename_with_extension" "$page_i-$page_j" -- "$filename_with_extension" "$filename_with_extension.slice.pdf"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -474,9 +474,9 @@ pdfextract_function() { \
|
|||||||
#+begin_src bash
|
#+begin_src bash
|
||||||
pdf_delete_first_page_function() { \
|
pdf_delete_first_page_function() { \
|
||||||
if command -v stapler &> /dev/null; then
|
if command -v stapler &> /dev/null; then
|
||||||
stapler del "$filename_with_extension" 1 /tmp/pdftk_out.pdf && mv /tmp/pdftk_out.pdf "$filename_with_extension"
|
stapler del "$filename_with_extension" 1 /tmp/qpdf_out.pdf && mv /tmp/qpdf_out.pdf "$filename_with_extension"
|
||||||
elif command -v pdftk &> /dev/null; then
|
elif command -v qpdf &> /dev/null; then
|
||||||
pdftk "$filename_with_extension" cat 2-end output /tmp/pdftk_out.pdf && mv /tmp/pdftk_out.pdf "$filename_with_extension"
|
qpdf --pages "$filename_with_extension" 2-z -- "$filename_with_extension" /tmp/qpdf_out.pdf && mv /tmp/qpdf_out.pdf "$filename_with_extension"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
@@ -484,10 +484,10 @@ pdf_delete_first_page_function() { \
|
|||||||
*** Remove Annotations
|
*** Remove Annotations
|
||||||
#+begin_src bash
|
#+begin_src bash
|
||||||
pdf_remove_annotations_function() { \
|
pdf_remove_annotations_function() { \
|
||||||
if command -v pdftk &> /dev/null; then
|
if command -v qpdf &> /dev/null; then
|
||||||
pdftk "$filename_with_extension" output /tmp/uncompressed.pdf uncompress
|
qpdf --qdf "$filename_with_extension" /tmp/uncompressed.pdf
|
||||||
LANG=C sed -n '/^\/Annots/!p' /tmp/uncompressed.pdf > /tmp/stripped.pdf
|
LANG=C sed -n '/^\/Annots/!p' /tmp/uncompressed.pdf > /tmp/stripped.pdf
|
||||||
pdftk /tmp/stripped.pdf output "$filename_with_extension" compress
|
qpdf /tmp/stripped.pdf "$filename_with_extension"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ Function that opens current pdf page as an SVG file with Inkscape.
|
|||||||
(setq filename (read-string "Enter file name:" (car (split-string (file-name-base buffer-file-name) "_"))))
|
(setq filename (read-string "Enter file name:" (car (split-string (file-name-base buffer-file-name) "_"))))
|
||||||
(setq filename (read-string "Enter file name:")))
|
(setq filename (read-string "Enter file name:")))
|
||||||
(setq filepath (concat "/tmp/" filename ".svg"))
|
(setq filepath (concat "/tmp/" filename ".svg"))
|
||||||
(shell-command (concat "pdftk " buffer-file-name " cat " (number-to-string (pdf-view-current-page)) " output /tmp/pdf_page.pdf"))
|
(shell-command (concat "qpdf --pages " buffer-file-name " " (number-to-string (pdf-view-current-page)) " -- " buffer-file-name " /tmp/pdf_page.pdf"))
|
||||||
(shell-command (concat "pdf2svg /tmp/pdf_page.pdf " filepath))
|
(shell-command (concat "pdf2svg /tmp/pdf_page.pdf " filepath))
|
||||||
(start-process "" nil "inkscape" filepath))
|
(start-process "" nil "inkscape" filepath))
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -286,7 +286,7 @@ systemctl --user enable --now wireplumber.service
|
|||||||
#+begin_src bash
|
#+begin_src bash
|
||||||
echo "==> PDF and Image Utilities"
|
echo "==> PDF and Image Utilities"
|
||||||
paru -S --needed \
|
paru -S --needed \
|
||||||
pdf2svg pdftk pdfarranger \
|
pdf2svg qpdf pdfarranger \
|
||||||
imagemagick \
|
imagemagick \
|
||||||
maim flameshot \
|
maim flameshot \
|
||||||
unclutter \
|
unclutter \
|
||||||
@@ -336,8 +336,6 @@ systemctl --user enable --now syncthing
|
|||||||
echo "==> GTK Theme"
|
echo "==> GTK Theme"
|
||||||
paru -S --needed \
|
paru -S --needed \
|
||||||
lxappearance \
|
lxappearance \
|
||||||
arc-gtk-theme \
|
|
||||||
xcursor-breeze \
|
|
||||||
gtk2fontsel
|
gtk2fontsel
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ paru -S --needed \
|
|||||||
|
|
||||||
echo "==> PDF and Image Utilities"
|
echo "==> PDF and Image Utilities"
|
||||||
paru -S --needed \
|
paru -S --needed \
|
||||||
pdf2svg pdftk pdfarranger \
|
pdf2svg qpdf pdfarranger \
|
||||||
imagemagick \
|
imagemagick \
|
||||||
maim flameshot \
|
maim flameshot \
|
||||||
unclutter \
|
unclutter \
|
||||||
|
|||||||
+1
-1
@@ -99,7 +99,7 @@ tmpfile=/tmp/pdf_page.pdf
|
|||||||
# Ideally would get the page from Zathura...
|
# Ideally would get the page from Zathura...
|
||||||
# pagenum=$(rofi -dmenu -p "Page Number")
|
# pagenum=$(rofi -dmenu -p "Page Number")
|
||||||
|
|
||||||
pdftk "$1" cat $2 output "$tmpfile.pdf" && \
|
qpdf --pages "$1" "$2" -- "$1" "$tmpfile.pdf" && \
|
||||||
pdf2svg "$tmpfile.pdf" "$tmpfile.svg" && \
|
pdf2svg "$tmpfile.pdf" "$tmpfile.svg" && \
|
||||||
inkscape "$tmpfile.svg"
|
inkscape "$tmpfile.svg"
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|||||||
Reference in New Issue
Block a user