Created
June 7, 2022 13:51
-
-
Save KiaraGrouwstra/1c2ad9fe0f987ae85840bdb3b9e3d9d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# prerequisite: create $censored_pdf from $original_pdf using chrome print pdf -> tick 'print as image' (linux chrome) -> save as pdf | |
# split | |
for page_range in ${original_page_ranges[*]}; do | |
pdftk $original_pdf cat $page_range output $page_range.pdf | |
done | |
for page_range in ${censored_page_ranges[*]}; do | |
pdftk $censored_pdf cat $page_range output $page_range.pdf | |
done | |
# merge | |
both_page_ranges=("${original_page_ranges[@]}" "${censored_page_ranges[@]}") | |
sorted_ranges=`echo ${both_page_ranges[*]}| tr " " "\n" | sort -n` | |
ranges=`for name in ${sorted_ranges[*]}; do echo "$name.pdf"; done` | |
pdfunite $ranges censored.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
original_pdf=uncensored.pdf | |
# prerequisite: create $censored_pdf from $original_pdf using chrome print pdf -> tick 'print as image' (linux chrome) -> save as uncensored-image.pdf | |
censored_pdf=uncensored-image.pdf | |
original_page_ranges=("1-2" "5-6") | |
censored_page_ranges=("3-4" "7-8") | |
source censor-pdf.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment