-
-
Save kevcjones-archived/4483127 to your computer and use it in GitHub Desktop.
required - install ghost script - e.g brew install ghostscript (takes a few minutes) | |
update this line as needed and run in terminal | |
-- New and updated thanks to comments -- | |
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -SPDFPassword=THE_PASSWORD -sOutputFile=unencrypted.pdf -c .setpdfwrite -f 2017-06-13-11-55-56-188_14972345156188_XXXPT6345X_ITRV.pdf | |
-- Original -- | |
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f encrypted.pdf |
I tried to experiment it fails
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f 2017-06-13-11-55-56-188_14972345156188_XXXPT6345X_ITRV.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 1951 1 3 %oparray_pop 1950 1 3 %oparray_pop 1934 1 3 %oparray_pop --nostringval-- --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push
Dictionary stack:
--dict:1178/1684(ro)(G)-- --dict:1/20(G)-- --dict:82/200(L)-- --dict:82/200(L)-- --dict:116/127(ro)(G)-- --dict:280/300(ro)(G)-- --dict:22/32(L)--
Current allocation mode is local
GPL Ghostscript 9.15: Unrecoverable error, exit code 1
Hi... I know this discussion has more than 2 years...
@gkArvindr you must provide the PDF password using the -SPDFPassword parameter.
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -SPDFPassword=THE_PASSWORD -sOutputFile=unencrypted.pdf -c .setpdfwrite -f 2017-06-13-11-55-56-188_14972345156188_XXXPT6345X_ITRV.pdf
@denysvega Thank you so much for your comment. It's the only one that works
Exactly what @mustaqimM said. Thanks, @denysvega! Worked for me too.
I've updated the original gist now - cheers @denysvega
For Windows
gswin64 -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sFONTPATH=%windir%/fonts;xfonts;. -sPDFPassword= -dPDFSETTINGS=/prepress -dPassThroughJPEGImages=true -sOutputFile=E:outputfile.pdf E:sourcefile.pdf
Notes
edited from source