Q: I am trying to use pdf2image command line tool (http://
www.pdftron.com/pdf2image/index.html) in my application, but I can’t
seem to get password protected files to convert. The examples on the
web site clearly show how to provide a password to a password
protected file, but I don’t see any way to cancel converting password
protected files. There is a batch script sample using error codes to
handle password cases, but that doesn’t seem to work for me. At the
moment, I would have to run the program in a thread with a timeout and
just let the conversion timeout if it tried to convert a password
protected file.
@echo %time% >> log.txt
pdf2image -p secret <mypath>
if errorlevel 1 goto passwd
if errorlevel 2 goto inputerr
if errorlevel 3 goto othererror
if errorlevel 0 goto exit
echo end %time% >> log.txt
:passwd
@echo Document is password protected. >> log.txt
goto exit
:inputerr
@echo No input files specified. >> log.txt
goto exit
:othererror
@echo An error encountered during processing. >> log.txt
goto exit
:exit
@echo exit %time% >> log.txt
---------------------
A: Did you try to use ‘--noprompt’ option? You can use this option to
disable user feedback to collect the password. If you know the
password in advance you can supply it using '-p' option.
As an alternative to PDF2Image Command-Line utility you may want to
use PDFNet SDK (
http://www.pdftron.com/pdfnet) which offers full
programmability with all options available in PDF2Image. As a starting
point you may want to take a look at PDFDraw sample (http://
www.pdftron.com/pdfnet/samplecode.html#PDFDraw).