Created
November 11, 2019 11:17
-
-
Save pirpyn/c3cb46bd4c338ef355cd135946e008dd to your computer and use it in GitHub Desktop.
PDF page number fix
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
#!/bin/bash -e | |
if [[ $# -ne 2 ]]; then | |
echo pdf2qdf2pdf in.pdf out.pdf; | |
exit 1; | |
fi; | |
qpdf -qdf $1 ${1/.pdf/.qdf}; | |
FIX="/Catalog \n | |
/PageLabels << \n | |
/Nums [ \n | |
0 << /S /r >> \n | |
10 << /S /D >> \n | |
] \n | |
>>" | |
SEDCMD=$( echo "s|/Catalog|${FIX}|" | tr '\n' ' ') | |
sed "${SEDCMD}" ${1/.pdf/.qdf} > tmp.qdf | |
fix-qdf tmp.qdf > tmp.fix; | |
qpdf tmp.fix ${2}; | |
rm tmp.qdf tmp.fix; | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment