Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

remove empty page pdf

#!/bin/sh
IN="$1"
filename=$(basename "${IN}")
filename="${filename%.*}"
PAGES=$(pdfinfo "$IN" | grep ^Pages: | tr -dc '0-9')
  
non_blank() {
    for i in $(seq 1 $PAGES)
    do
        PERCENT=$(gs -o -  -dFirstPage=${i} -dLastPage=${i} -sDEVICE=inkcov "$IN" | grep CMYK | nawk 'BEGIN { sum=0; } {sum += $1 + $2 + $3 + $4;} END { printf "%.5f
", sum } ')
        if [ $(echo "$PERCENT > 0.001" | bc) -eq 1 ]
        then
            echo $i
            #echo $i 1>&2
        fi
        echo -n . 1>&2
    done | tee "${DIR}/$filename.tmp"
    echo 1>&2
}
  
set +x
pdftk "${IN}" cat $(non_blank) output "${filename}_copy.pdf"
Comment

PREVIOUS NEXT
Code Example
Shell :: docker command to login with user name and pass word 
Shell :: create ssh key 
Shell :: chmod recursive group read 
Shell :: list des group linux 
Shell :: debian EXPKEYSIG 
Shell :: linux stress test 
Shell :: stack navigator 
Shell :: install wordpress ubuntu 
Shell :: how to check open vpn on ubuntu 
Shell :: k8s roll back to previous deployment 
Shell :: git to know committed files by author 
Shell :: Abort a Conflicting Merge in git command 
Shell :: powershell display environment variables 
Shell :: cherry pick 
Shell :: linux list users 
Shell :: am i ~/.zshrc or ~/.bashrc 
Shell :: uninstall flake 8 in vs 
Shell :: scp linux 
Shell :: default gatsby typescript started 
Shell :: command to create an react app 
Shell :: change user terminal 
Shell :: run index.js 
Shell :: pip info package location 
Shell :: git bad object 
Shell :: change shell script to executable 
Shell :: enter 1 digit max number field 
Shell :: boucle bash 
Shell :: check all background process in linux 
Shell :: difference between rebase and merge in git 
Shell :: pushing image to docker hub 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =