On 2014-07-08 11:36, deano ferrari wrote:
>
> This too:
>
> http://www.lemonsoftware.eu/goodies/linux:remove_pdf_restrictions
Here it says:
pdftk input.pdf output output.pdf user_pw YOURPASSWORD-HERE
I was trying that a few days back, and failed: pdftk refuses if you
don’t have the owner password, because you don’t have permission to
modify the PDF, only to read/print it.
So what I do is “print” or convert to postscript, supplying the
password, and this postscript I convert back to pdf.
Of course, if the PDF contains indexes or links, they are lost.
I created a script for the task:
#!/bin/bash
… ~/keys/PDFPASSWORD
for FILES in ls ./origs/*pdf
do
NAME=basename $FILES
ENTRADA=./origs/$NAME
SALIDA=./dests/$NAME
if -f out.ps ]; then
rm out.ps
fi
if -f $SALIDA ]; then
echo “$SALIDA exists, skipping”
else
pdftops -upw $RECONTRA $ENTRADA out.ps
ps2pdf14 out.ps $SALIDA
echo
fi
done
I will have to investigate if the tools mentioned in your link could
work better:
pdftk (fails)
qpdf (unknown)
xpdf-utils → ps2pdf (works)
The claim that ghostscript can work without the password, surprises me a
lot:
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
-sOutputFile=unencrypted.pdf -c .setpdfwrite -f encrypted.pdf
And in fact, it fails with my PDFs receipts:
cer@Telcontar:~/tmp> gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite
-sOutputFile=unencrypted.pdf -c .setpdfwrite -f encripted.pdf
**** This file requires a password for access. <============
Error: /invalidfileaccess in pdf_process_Encrypt
Operand stack:
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval--
--nostringval-- 2 %stopped_push --nostringval-- --nostringval--
--nostringval-- false 1 %stopped_push 1900 1 3
%oparray_pop 1899 1 3 %oparray_pop 1883 1 3 %oparray_pop
--nostringval-- --nostringval-- --nostringval-- --nostringval--
false 1 %stopped_push
Dictionary stack:
--dict:1162/1684(ro)(G)-- --dict:1/20(G)-- --dict:82/200(L)--
--dict:82/200(L)-- --dict:109/127(ro)(G)-- --dict:292/300(ro)(G)--
--dict:22/32(L)--
Current allocation mode is local
GPL Ghostscript 9.07: Unrecoverable error, exit code 1
cer@Telcontar:~/tmp>
That would work, I assume, if the PDF has print permission, which would
be unforgivable error in an emailed PDF. Or if there was a bug somewhere.
Another comment suggest to use:
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf
-c .setpdfwrite -f encripted.pdf
which fails with “Error: /invalidfileaccess in pdf_process_Encrypt”.
Another comment (Denilson) duplicates my findings. I have to try ‘qpdf’.
Some one says that nothing would work, except “MuPDF”, with Wine.
Probably AES encryption.
mubusy clean -p YOURPASSWORD-HERE input.pdf
or
mutool clean -p YOUR-PASSWORD input.pdf
I write it here for future reference.
–
Cheers / Saludos,
Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)