2012年7月19日 星期四

PDF password

先參考這篇文章:HowTo: Linux Remove a PDF File Password Using Command Line Options
http://www.cyberciti.biz/faq/removing-password-from-pdf-on-linux/comment-page-1/#comment-70471


I made some test.

  1.  If the encrypted pdf file set an "file open" password, and you don't know the password. Then neither pdftk, qpdf nor gs can decrypt the pdf.
  2.  If you know either owner or user password, you can decrypt the pdf with qpdf. Though there may have som error message. The idea is that you can open and show the content first.
  3. ghostscript method is great! and I use it on win32, find gs for win32 on http://sourceforge.net/projects/ghostscript/  (gs905w32.exe 2012-7-19), download and install
  4. set path for gs, (computer-> mouse right click-> content-> advanced system setup-> environment-> user variable-> add or edit-> add path "C:\Program Files\gs\gs9.05\bin"

want a batch convert on win32? try this

  1. copy all encrypted pdf files into a working directory, and create a sub directory named conv
  2. in cmd mode, in this directory type(in quote"): "dir *.pdf /b >conv.txt"
  3. create a batch file :conv.bat content as 
    • FOR /F "eol=; usebackq delims==" %%i in (conv.txt) do gswin32c -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=conv/%%i -c .setpdfwrite -f %%i
  4. in cmd mode, in this dir type: "conv"
  5. done! all decrypted files will be sent to sub dir "conv"