Description: Improve error message on non standard conform pdf files.
 itext cannot handle pdf files where the information dictionary is a direct
 object.
Author: Johann Felix Soden <johfel@gmx.de>
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/pdftk/+bug/544636

--- a/pdftk/pdftk.cc
+++ b/pdftk/pdftk.cc
@@ -38,6 +38,7 @@
 #include <unistd.h> // for access()
 
 #include <java/lang/System.h>
+#include <java/lang/ClassCastException.h>
 #include <java/lang/Throwable.h>
 #include <java/lang/String.h>
 #include <java/io/IOException.h>
@@ -2838,6 +2839,20 @@
 			break;
 			}
 		}
+		catch(java::lang::ClassCastException * c_p ) {
+			jstring message=c_p->getMessage();
+			int found=message->indexOf(JvNewStringUTF("com.lowagie.text.pdf.PdfDictionary"));
+			if (found >= 0 && message->indexOf(JvNewStringUTF("com.lowagie.text.pdf.PRIndirectReference"))>=0 )
+			{
+				cerr << "Error: One input pdf file seems to be not standard conform." << endl;
+				cerr << "The document information dictionary is a direct object, "
+				     <<  "not an indirect reference. " << endl;
+				cerr << "Please report this bug to the program which have produced the pdf file." << endl;
+				cerr << endl;
+			}
+			cerr << "Java Exception:" << endl;
+			c_p->printStackTrace();
+		}
 		catch( java::lang::Throwable* t_p )
 			{
 				cerr << "Unhandled Java Exception:" << endl;
