Workaround: KPDF asks for password on some PDFs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all!

This Workaround is for all that are plaged by kpdf not able to open encrypted PDFs.
- It decrypts PDFs with the infamouse empty password (that failes on libpoppler)
- It asks for the password for encrypted PDFs and removes the encryption (if password is correct)

How to use:
- Save the attached program to your ~/bin (or wherever you would like it to reside)
- Change the file association for PDF to use this program
- Open some encrypted/not-encrypted PDFs that did not work in plain kpdf.

Commandline: "/where/ever/you/put/it/decrypt-pdf" PDF.pdf ...

TDE specific file URLS like sftp:// don't work, but maybe "somebody" feels the need to add those.

--> KPDF can now handle all PDFs that it could not cope with.

Enjoy.
Nik

--
Please do not email me anything that you are not comfortable also sharing with the NSA, CIA ...
#!/bin/bash -ex

VIEWER=$(which kpdf || which xpdf)


if [ $# -lt 1 ]; then
	echo "$(basename $0) PDF [PDF [...]]"
	echo "removes password and restrictions on PDF file"
	which qpdf    || echo "please install 'qpdf'"
	which kdialog || echo "please install 'tdebase-trinity-bin'"
	which pdfinfo || echo "please install 'poppler-utils'"
	exit 1
fi

if which qpdf || which kdialog || which pdfinfo ]; then

	while [ $# -gt 0 ]; do
		SHOW=YES
		if [ -f "$1" ]; then
			if ! pdfinfo "$1" > /dev/null 2>&1; then
				if [ ! -z "$(qpdf --password='' --decrypt --remove-restrictions --replace-input $1 2>&1 | head -n 1 | grep -i invalid)" ]; then
					PWD="$(kdialog --title 'Encrypted PDF' --inputbox 'Password for PDF:' '')"
					if [ $? -eq 0 ]; then
						if [ ! -z "$(qpdf --password=$PWD --decrypt --remove-restrictions --replace-input $1 2>&1 | head -n 1 | grep -i invalid)" ]; then
							kdialog --title 'Encrypted PDF' --error "Wrong PDF password."
							SHOW=''
						fi
					fi
				fi
			fi
		fi
		if [ "$SHOW" ]; then
			if [ -e "$VIEWER" ]; then
				$VIEWER "$1" &
			fi
		fi
		shift
	done

else
	if [ -e "$VIEWER" ]; then
		$VIEWER $*
	fi
fi



____________________________________________________
tde-users mailing list -- users@xxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxx
Web mail archive available at https://mail.trinitydesktop.org/mailman3/hyperkitty/list/users@xxxxxxxxxxxxxxxxxx

[Index of Archives]     [Trinity Devel]     [KDE]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]     [Trinity Desktop Environment]

  Powered by Linux