How to add page numbers to Postscript/PDF

前端 未结 14 1926
臣服心动
臣服心动 2020-12-07 12:06

If you\'ve got a large document (500 pages+) in Postscript and want to add page numbers, does anyone know how to do this?

14条回答
  •  甜味超标
    2020-12-07 12:15

    I took captaincomic's solution and added support for filenames containing spaces, plus giving some more informations about the progress

    #!/bin/bash
    clear
    echo
    echo This skript adds pagenumbers to a given .pdf file.
    echo 
    echo This skript needs the packages pdftk and enscript
    echo if not installed the script will fail.
    echo use the command sudo apt-get install pdftk enscript
    echo to install.
    echo 
    input="$1"
    output="${1%.pdf}-header.pdf"
    echo input file is $input
    echo output file will be $output
    echo 
    pagenum=$(pdftk "$input" dump_data | grep "NumberOfPages" | cut -d":" -f2)
    enscript -L1 --header='||Page $% of $=' --output - < <(for i in $(seq "$pagenum"); do echo; done) | ps2pdf - | pdftk "$input" multistamp - output "$output"
    echo done.
    

提交回复
热议问题