Process PDF protected by password fails.
Posted: 2017-03-08T03:59:07-07:00
I have a problem managing pdf with password.
The command convert with -authenticate <password> seems doesn't work.
I am using a computer with the following configuration:
SO:Windows 10 home edition 64 bit
Imagemagick Version:
ImageMagick 7.0.5-1 Q16 x64 2017-03-04 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
I tried to create jpeg and gif from a protected pdf.
I tried to use the following comand:
convert -authenticate 5f9bd2f2f465b3535b48c664e6c68d7b 1_8d0b4fd2f4.pdf test.jpg
and I received the following error message
convert: PDFDelegateFailed `[ghostscript library 9.20] -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pamcmyk32" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -dUseCIEColor "-sOutputFile=C:/Users/SQUATT~1/AppData/Local/Temp/magick-4928zJv9DtYHVMAg%d" "-fC:/Users/SQUATT~1/AppData/Local/Temp/magick-4928DDtDU4qsbyzU" "-fC:/Users/SQUATT~1/AppData/Local/Temp/magick-4928gE2ciUCx7dDo"': **** 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 1983 1 3 %oparray_pop 1982 1 3 %oparray_pop 1966 1 3 %oparray_pop --nostringval-- --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push
Dictionary stack:
--dict:1205/1684(ro)(G)-- --dict:1/20(G)-- --dict:83/200(L)-- --dict:83/200(L)-- --dict:135/256(ro)(G)-- --dict:291/300(ro)(G)-- --dict:28/32(L)--
Current allocation mode is local
GPL Ghostscript 9.20: Unrecoverable error, exit code 1
@ error/pdf.c/InvokePDFDelegate/274.
convert: no images defined `test.jpg' @ error/convert.c/ConvertImageCommand/3254.
To verify it it is a Ghostscript problem I tried to create a jpeg file using the following command:
gs -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -sOutputFile=test.jpg -sPDFPassword=5f9bd2f2f465b3535b48c664e6c68d7b 1_8d0b4fd2f4.pdf
Ghostscript created the image without any error.
Investigating more, it seems that imagemagick doesn't set the password parameter when invoking the delegate during the conversion.
I verified it, I tried to change temporarily the file delegate.xml inside my imagemagick folder installation D:\Program Files\ImageMagick-7.0.5-Q16 adding the password parameter with the password of pdf I need to create the jpeg:
<delegate decode="ps:cmyk" stealth="True" command=""@PSDelegate@" -q -dQUIET -sPDFPassword=5f9bd2f2f465b3535b48c664e6c68d7b -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pamcmyk32" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>
and than to execute the command
convert -authenticate 5f9bd2f2f465b3535b48c664e6c68d7b 1_8d0b4fd2f4.pdf test.jpg
again and it works.
I already used the -authenticate option with many versions of linux (Debian, Centos) and windows (Windows 7, 8, 8.1) but this is the first time I have this kind of problem.
Thanks in advance.
The command convert with -authenticate <password> seems doesn't work.
I am using a computer with the following configuration:
SO:Windows 10 home edition 64 bit
Imagemagick Version:
ImageMagick 7.0.5-1 Q16 x64 2017-03-04 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
I tried to create jpeg and gif from a protected pdf.
I tried to use the following comand:
convert -authenticate 5f9bd2f2f465b3535b48c664e6c68d7b 1_8d0b4fd2f4.pdf test.jpg
and I received the following error message
convert: PDFDelegateFailed `[ghostscript library 9.20] -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pamcmyk32" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -dUseCIEColor "-sOutputFile=C:/Users/SQUATT~1/AppData/Local/Temp/magick-4928zJv9DtYHVMAg%d" "-fC:/Users/SQUATT~1/AppData/Local/Temp/magick-4928DDtDU4qsbyzU" "-fC:/Users/SQUATT~1/AppData/Local/Temp/magick-4928gE2ciUCx7dDo"': **** 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 1983 1 3 %oparray_pop 1982 1 3 %oparray_pop 1966 1 3 %oparray_pop --nostringval-- --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push
Dictionary stack:
--dict:1205/1684(ro)(G)-- --dict:1/20(G)-- --dict:83/200(L)-- --dict:83/200(L)-- --dict:135/256(ro)(G)-- --dict:291/300(ro)(G)-- --dict:28/32(L)--
Current allocation mode is local
GPL Ghostscript 9.20: Unrecoverable error, exit code 1
@ error/pdf.c/InvokePDFDelegate/274.
convert: no images defined `test.jpg' @ error/convert.c/ConvertImageCommand/3254.
To verify it it is a Ghostscript problem I tried to create a jpeg file using the following command:
gs -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -sOutputFile=test.jpg -sPDFPassword=5f9bd2f2f465b3535b48c664e6c68d7b 1_8d0b4fd2f4.pdf
Ghostscript created the image without any error.
Investigating more, it seems that imagemagick doesn't set the password parameter when invoking the delegate during the conversion.
I verified it, I tried to change temporarily the file delegate.xml inside my imagemagick folder installation D:\Program Files\ImageMagick-7.0.5-Q16 adding the password parameter with the password of pdf I need to create the jpeg:
<delegate decode="ps:cmyk" stealth="True" command=""@PSDelegate@" -q -dQUIET -sPDFPassword=5f9bd2f2f465b3535b48c664e6c68d7b -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pamcmyk32" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>
and than to execute the command
convert -authenticate 5f9bd2f2f465b3535b48c664e6c68d7b 1_8d0b4fd2f4.pdf test.jpg
again and it works.
I already used the -authenticate option with many versions of linux (Debian, Centos) and windows (Windows 7, 8, 8.1) but this is the first time I have this kind of problem.
Thanks in advance.