Description: Support PROMPT for user_pw and owner_pw simultaneously
 The check if user_pw is not equal to owner_pw should be after prompting for them.
Author: Johann Felix Soden <johfel@gmx.de>
Bug-Debian: http://bugs.debian.org/614071



--- a/pdftk/pdftk.cc
+++ b/pdftk/pdftk.cc
@@ -1720,7 +1720,7 @@
 
 		case output_owner_pw_e: {
 			if( m_output_owner_pw.empty() ) {
-				if( m_output_user_pw!= argv[ii] ) {
+				if( m_output_user_pw!= argv[ii] || strcmp(argv[ii], "PROMPT")== 0 ) {
 					m_output_owner_pw= argv[ii];
 				}
 				else { // error: identical user and owner password
@@ -1751,7 +1751,7 @@
 
 		case output_user_pw_e: {
 			if( m_output_user_pw.empty() ) {
-				if( m_output_owner_pw!= argv[ii] ) {
+				if( m_output_owner_pw!= argv[ii] || strcmp( argv[ii], "PROMPT" )== 0 ) {
 					m_output_user_pw= argv[ii];
 				}
 				else { // error: identical user and owner password
@@ -2585,6 +2585,19 @@
 				}
 				*/
 
+		if( !m_output_user_pw.empty() && m_output_user_pw== m_output_owner_pw ) {
+			// error: identical user and owner password
+			// are interpreted by Acrobat (per the spec.) that
+			// the doc has no owner password
+			cerr << "Error: The user and owner passwords are the same." << endl;
+			cerr << "   PDF Viewers interpret this to mean your PDF has" << endl;
+			cerr << "   no owner password, so they must be different." << endl;
+			cerr << "   Or, supply no owner password to pdftk if this is" << endl;
+			cerr << "   what you desire." << endl;
+			cerr << "Exiting." << endl;
+			return false;
+		}
+
 
 				// un/compress output streams?
 				if( m_output_uncompress_b ) {
