Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

delete empty pdf page

#!/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 :: warning: LF will be replaced by CRLF in [file_path] 
Shell :: conemu git bash 
Shell :: nginx create alias 
Shell :: letencrpt 
Shell :: fedora simplescreenrecorder start 
Shell :: test gatsby app on mobile 
Shell :: particular screenshot in ubuntu 
Shell :: cat meaning linux 
Shell :: react quill 
Shell :: copy everything vim 
Shell :: know committed files by author 
Shell :: ffmpeg video black and white filter 
Shell :: ubuntu default terminal font family 
Shell :: redis-server specify port 
Shell :: git status 
Shell :: windows command cmd date 
Shell :: how to clear background jobs 
Shell :: how to pull remote changes to local branch 
Shell :: create service without spec 
Shell :: phpinfo cli 
Shell :: symfony Unable to write in the "logs" directory (/var/www/html/var/log). 
Shell :: composer reinstall all packages 
Shell :: how to find the changes in git 
Shell :: xargs parameter 
Shell :: extract tar.gz linux command line 
Shell :: centos helm 
Shell :: extract a tar.xz in linux 
Shell :: git add removed files 
Shell :: what is curl 
Shell :: node git clone 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =