Skip to content

Commit

Permalink
replacing call to outdated smpdf executable
Browse files Browse the repository at this point in the history
  • Loading branch information
tvercaut committed Dec 4, 2024
1 parent 8fbe571 commit 57b38d4
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions tools/compresspdf2ebookpdf
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ echo "PDF lossy compression using:"
echo $PDF2PDFFLAGS -sOutputFile="$F-compressed.pdf" "$1" $pdfmarks
gs $PDF2PDFFLAGS -sOutputFile="$F-compressed.pdf" "$1" $pdfmarks

# pdftk is not maintained anymore and does not work on my mac...
#echo pdftk $1 dump_data output /tmp/pdftk-report.txt
#pdftk $1 dump_data output /tmp/pdftk-report.txt
#echo pdftk /tmp/compressed.pdf update_info /tmp/pdftk-report.txt output $F-compressed.pdf
#pdftk /tmp/compressed.pdf update_info /tmp/pdftk-report.txt output $F-compressed.pdf

# Chrome has issues if exiftool is run last. Make sure smpdf comes afterwards
# Chrome has issues if exiftool is run last. Make sure cpdf comes afterwards
if ! [ -x "$(command -v exiftool)" ]; then
echo "Could not find exiftool - Some tags might have been lost"
else
Expand All @@ -41,21 +35,16 @@ else
exiftool -overwrite_original -TagsFromFile "$1" "$F-compressed.pdf"
fi

if ! [ -x "$(command -v smpdf)" ]; then
echo "Could not find smpdf - Skipping additional lossless compression"
echo See https://www.coherentpdf.com/compression.html
if ! [ -x "$(command -v cpdf)" ]; then
echo "Could not find cpdf - Skipping additional lossless compression and annotation copying"
echo "See https://github.com/johnwhitington/cpdf-source"
else
# Use smpdf to further compress the file in a lossless fashion
echo "PDF lossless compression using:"
echo smpdf "$F-compressed.pdf" -o "$F-compressed2.pdf"
smpdf "$F-compressed.pdf" -o "$F-compressed2.pdf"
echo cpdf -squeeze "$F-compressed.pdf" -o "$F-compressed2.pdf"
cpdf -squeeze "$F-compressed.pdf" -o "$F-compressed2.pdf"
mv "$F-compressed2.pdf" "$F-compressed.pdf"
fi

if ! [ -x "$(command -v cpdf)" ]; then
echo "Could not find cpdf - Skipping additional annotation copying"
echo See https://www.coherentpdf.com/compression.html
else

# Use cpdf to copy information over
echo "PDF ID copy using:"
echo cpdf -copy-id-from "$1" "$F-compressed.pdf" -o "$F-compressed2.pdf"
Expand Down

0 comments on commit 57b38d4

Please sign in to comment.