Hello,

I've found the reason for the missing UTF-8 filename support:
The filenames are converted in the C++-Code from Latin1 (to java-intern
encoding). The right way is converting from UTF-8.

Because the standard filename encoding is UTF-8 since Debian Etch, the
appended patch should solve the filename problem on almost all current
systems.

Bye,
 Johann Felix
diff -upNr pdftk-1.41/debian/patches/series pdftk-1.41patched/debian/patches/series
--- pdftk-1.41/debian/patches/series	2009-08-06 22:58:29.000000000 +0200
+++ pdftk-1.41patched/debian/patches/series	2009-08-06 22:54:56.000000000 +0200
@@ -1,2 +1,3 @@
 build_with_gcc-4.2
 no_embedded_libs
+support_utf8_filenames
diff -upNr pdftk-1.41/debian/patches/support_utf8_filenames pdftk-1.41patched/debian/patches/support_utf8_filenames
--- pdftk-1.41/debian/patches/support_utf8_filenames	1970-01-01 01:00:00.000000000 +0100
+++ pdftk-1.41patched/debian/patches/support_utf8_filenames	2009-08-06 22:53:54.000000000 +0200
@@ -0,0 +1,183 @@
+--- a/pdftk/attachments.cc
++++ b/pdftk/attachments.cc
+@@ -204,10 +204,10 @@
+ 									itext::PdfAnnotation::createFileAttachment
+ 									( writer_p,
+ 										annot_bbox_p,
+-										JvNewStringLatin1( filename.c_str() ), // contents
++										JvNewStringUTF( filename.c_str() ), // contents
+ 										0,
+-										JvNewStringLatin1( vit->c_str() ), // the file path
+-										JvNewStringLatin1( filename.c_str() ) ); // display name
++										JvNewStringUTF( vit->c_str() ), // the file path
++										JvNewStringUTF( filename.c_str() ) ); // display name
+ 
+ 								itext::PdfIndirectReference* ref_p=
+ 									writer_p->addToBody( annot_p )->getIndirectReference();
+@@ -280,8 +280,8 @@
+ 								filespec_p= 
+ 									itext::PdfFileSpecification::fileEmbedded
+ 									( writer_p,
+-										JvNewStringLatin1( vit->c_str() ), // the file path
+-										JvNewStringLatin1( filename.c_str() ), // the display name
++										JvNewStringUTF( vit->c_str() ), // the file path
++										JvNewStringUTF( filename.c_str() ), // the display name
+ 										0 );
+ 							}
+ 							catch( java::io::IOException* ioe_p ) { // file open error
+@@ -297,14 +297,14 @@
+ 
+ 							// contruct a name, if necessary, to prevent possible key collision on the name tree
+ 							java::String* key_p= 
+-								JvNewStringLatin1( vit->c_str() );
++								JvNewStringUTF( vit->c_str() );
+ 							{
+ 								int counter= 1;
+ 								while( emb_files_map_p->containsKey( key_p ) ) { // append a unique suffix
+ 									char buff[256];
+ 									sprintf( buff, "-%d", counter++ );
+ 									key_p= 
+-										JvNewStringLatin1( (*vit + buff ).c_str() );
++										JvNewStringUTF( (*vit + buff ).c_str() );
+ 								}
+ 							}
+ 
+--- a/pdftk/pdftk.cc
++++ b/pdftk/pdftk.cc
+@@ -163,7 +163,7 @@
+ 		}
+ 		if( input_pdf_p->m_password.empty() ) {
+ 			reader=
+-				new itext::PdfReader( JvNewStringLatin1( input_pdf_p->m_filename.c_str() ) );
++				new itext::PdfReader( JvNewStringUTF( input_pdf_p->m_filename.c_str() ) );
+ 		}
+ 		else {
+ 			if( input_pdf_p->m_password== "PROMPT" ) {
+@@ -175,7 +175,7 @@
+ 							input_pdf_p->m_password.size() );
+ 
+ 			reader= 
+-				new itext::PdfReader( JvNewStringLatin1( input_pdf_p->m_filename.c_str() ),
++				new itext::PdfReader( JvNewStringUTF( input_pdf_p->m_filename.c_str() ),
+ 															password );
+ 		}
+ 		reader->consolidateNamedDestinations();
+@@ -197,7 +197,7 @@
+ 		}
+ 	}
+ 	catch( java::io::IOException* ioe_p ) { // file open error
+-		if( ioe_p->getMessage()->equals( JvNewStringLatin1( "Bad password" ) ) ) {
++		if( ioe_p->getMessage()->equals( JvNewStringUTF( "Bad password" ) ) ) {
+ 			input_pdf_p->m_authorized_b= false;
+ 		}
+ 		open_success_b= false;
+@@ -1893,7 +1893,7 @@
+ 
+ 		// attempt to open the stream
+ 		java::String* jv_output_filename_p=
+-			JvNewStringLatin1( output_filename.c_str() );
++			JvNewStringUTF( output_filename.c_str() );
+ 		try {
+ 			os_p= new java::FileOutputStream( jv_output_filename_p );
+ 		}
+@@ -1920,7 +1920,7 @@
+ 									jint page_num )
+ {
+ 	itext::PdfName* page_marker_p=
+-		new itext::PdfName( JvNewStringLatin1(g_page_marker) );
++		new itext::PdfName( JvNewStringUTF(g_page_marker) );
+ 	itext::PdfDictionary* page_p= reader_p->getPageN( page_index );
+ 	if( page_p && page_p->isDictionary() ) {
+ 		page_p->put( page_marker_p, new itext::PdfNumber( page_num ) );
+@@ -1939,7 +1939,7 @@
+ 											 jint page_num )
+ {
+ 	itext::PdfName* page_marker_p=
+-		new itext::PdfName( JvNewStringLatin1(g_page_marker) );
++		new itext::PdfName( JvNewStringUTF(g_page_marker) );
+ 	itext::PdfDictionary* page_p= reader_p->getPageN( page_num );
+ 	if( page_p && page_p->isDictionary() ) {
+ 		page_p->remove( page_marker_p );
+@@ -1981,7 +1981,7 @@
+ 
+ 		string creator= "pdftk "+ string(PDFTK_VER)+ " - www.pdftk.com";
+ 		java::String* jv_creator_p= 
+-			JvNewStringLatin1( creator.c_str() );
++			JvNewStringUTF( creator.c_str() );
+ 
+ 		if( m_output_owner_pw== "PROMPT" ) {
+ 			prompt_for_password( "owner", "the output PDF", m_output_owner_pw );
+@@ -2158,7 +2158,7 @@
+ 					char buff[4096]= "";
+ 					sprintf( buff, m_output_filename.c_str(), ii+ 1 );
+ 
+-					java::String* jv_output_filename_p= JvNewStringLatin1( buff );
++					java::String* jv_output_filename_p= JvNewStringUTF( buff );
+ 
+ 					itext::Document* output_doc_p= new itext::Document();
+ 					java::FileOutputStream* ofs_p= new java::FileOutputStream( jv_output_filename_p );
+@@ -2263,13 +2263,13 @@
+ 						// first try fdf
+ 						try {
+ 							fdf_reader_p=
+-								new itext::FdfReader( JvNewStringLatin1( m_form_data_filename.c_str() ) );
++								new itext::FdfReader( JvNewStringUTF( m_form_data_filename.c_str() ) );
+ 						}
+ 						catch( java::io::IOException* ioe_p ) { // file open error
+ 							// maybe it's xfdf?
+ 							try {
+ 								xfdf_reader_p=
+-									new itext::XfdfReader( JvNewStringLatin1( m_form_data_filename.c_str() ) );
++									new itext::XfdfReader( JvNewStringUTF( m_form_data_filename.c_str() ) );
+ 							}
+ 							catch( java::io::IOException* ioe_p ) { // file open error
+ 								cerr << "Error: Failed to open form data file: " << endl;
+@@ -2294,7 +2294,7 @@
+ 																 m_background_filename );
+ 					}
+ 					try {
+-						mark_p= new itext::PdfReader( JvNewStringLatin1( m_background_filename.c_str() ) );
++						mark_p= new itext::PdfReader( JvNewStringUTF( m_background_filename.c_str() ) );
+ 						mark_p->removeUnusedObjects();
+ 						mark_p->shuffleSubsetNames();
+ 					}
+@@ -2312,7 +2312,7 @@
+ 																 m_stamp_filename );
+ 					}
+ 					try {
+-						mark_p= new itext::PdfReader( JvNewStringLatin1( m_stamp_filename.c_str() ) );
++						mark_p= new itext::PdfReader( JvNewStringUTF( m_stamp_filename.c_str() ) );
+ 						mark_p->removeUnusedObjects();
+ 						mark_p->shuffleSubsetNames();
+ 					}
+--- a/pdftk/report.cc
++++ b/pdftk/report.cc
+@@ -477,8 +477,8 @@
+ 						}
+ 
+ 						{ // PageLabelNumStyle
+-							itext::PdfName* r_p= new itext::PdfName(JvNewStringLatin1("r"));
+-							itext::PdfName* a_p= new itext::PdfName(JvNewStringLatin1("a"));
++							itext::PdfName* r_p= new itext::PdfName(JvNewStringUTF("r"));
++							itext::PdfName* a_p= new itext::PdfName(JvNewStringUTF("a"));
+ 
+ 							itext::PdfName* style_p= (itext::PdfName*)
+ 								reader_p->getPdfObject( label_p->get( itext::PdfName::S ) );
+@@ -1219,7 +1219,7 @@
+ 							 it!= info_map.end(); ++it )
+ 						{
+ 							if( it->second.empty() ) {
+-								info_p->remove( new itext::PdfName( JvNewStringLatin1(it->first.c_str()) ) );
++								info_p->remove( new itext::PdfName( JvNewStringUTF(it->first.c_str()) ) );
+ 							}
+ 							else {
+ 								const jsize jvs_size= 4096;
+@@ -1227,7 +1227,7 @@
+ 								jsize jvs_len= 0;
+ 								string_to_jcharstring( jvs, jvs_size, &jvs_len, it->second );
+ 
+-								info_p->put( new itext::PdfName( JvNewStringLatin1(it->first.c_str()) ),
++								info_p->put( new itext::PdfName( JvNewStringUTF(it->first.c_str()) ),
+ 														 new itext::PdfString( JvNewString(jvs, jvs_len), itext::PdfObject::TEXT_UNICODE ) );
+ 							}
+ 						}

Reply via email to