How to remove a .pdf's document restrictions? [duplicate]

You have two options:

  • with ghostscript:

    gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=%stdout% -c .setpdfwrite -f locked.pdf > unlocked.pdf
    
  • with pdf2ps and ps2pdf (slower):

    pdf2ps locked.pdf - | ps2pdf - unlocked.pdf
    

    If the unlocked PDF contains error, try to decompose the commands (ps2pdf have sometimes problems with a streamed input):

    pdf2ps locked.pdf unlocked.ps
    ps2pdf unlocked.ps unlocked.pdf