Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

remove 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 :: copy file from ssh server to local 
Shell :: ubuntu nvm 
Shell :: how to compare percentage value in shell script 
Shell :: docker NoRouteToHostException: No route to host (Host unreachable) 
Shell :: create new repository in git bash 
Shell :: wget a file from bitbucket 
Shell :: react navigation stack 
Shell :: ssh kali linux command 
Shell :: set remote git 
Shell :: Everything up-to-date git push origin main 
Shell :: Malformed entry 2 in list file /etc/apt/sources.list.d/docker.list ([option] not assignment) 
Shell :: ubuntu 22.04 server list services 
Shell :: how to add this package include: package:flutter_lints/flutter.yaml 
Shell :: docker change timezone 
Shell :: chocolatey 
Shell :: git first time 
Shell :: rename files sequentially linux 
Shell :: linux scp 
Shell :: crictl image prune 
Shell :: how to trigger new heorku build without diting git 
Shell :: screenshot in ubuntu 
Shell :: rsync as sudo 
Shell :: batch call another batch with parameters 
Shell :: how to install velero on ubuntu 
Shell :: how to check maximum ram memory capacity support size in linux 
Shell :: modify file modified time linux 
Shell :: concatenate multiple zip files linux 
Shell :: create new git branch from existing branch 
Shell :: how to commit to main branch in git 
Shell :: How to squash the last n commits together 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =