Bug#595777: unblock: pdftk/1.41+dfsg-9

2010-09-06 Thread Johann Felix Soden
Package: release.debian.org
Severity: normal
User: release.debian@packages.debian.org
Usertags: unblock

Please unblock pdftk 1.41+dfsg-9.

This upload solves a bug that leads to not working pdf compression
support - one of the main features of pdftk.

For this, I extended the existing uncompression patch that was needed
after using a newer upstream version of the itext library in 
pdftk/1.41+dfsg-1.

The changelog entry:
pdftk (1.41+dfsg-9) unstable; urgency=low

  * Fix pdf compression support: Uncompressed files can now be
compressed.
  * Bump Standards-Version to 3.9.1.

 -- Johann Felix Soden joh...@gmx.de  Sun, 08 Aug 2010 11:24:11 +0200

And the diffstat (mainly new code and renamings in
debian/patches/support_compression and patch refreshings):
 debian/changelog   |   10 +++-
 debian/control |2 +-
 debian/patches/fix_return_code |   36 +-
 debian/patches/ignore_locale   |2 +-
 .../patches/improve_error_message_on_invalid_pdf   |2 +-
 debian/patches/series  |2 +-
 .../{support_uncompression = support_compression} |   69 +--
 7 files changed, 78 insertions(+), 45 deletions(-)

Thanks!

unblock pdftk/1.41+dfsg-9

Regards,
 Johann Felix Soden




-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#595777: unblock: pdftk/1.41+dfsg-9

2010-09-06 Thread Julien Cristau
On Mon, Sep  6, 2010 at 17:56:19 +0200, Johann Felix Soden wrote:

  .../{support_uncompression = support_compression} |   69 +--

Care to provide a diff between the old and new patches? (I'm lazy, and
debdiff doesn't know to do that.)

Thanks,
Julien


signature.asc
Description: Digital signature


Bug#595777: unblock: pdftk/1.41+dfsg-9

2010-09-06 Thread Johann Felix Soden
On Mon, Sep  6, 2010 at 23:34 +0200, Julien Cristau wrote:
 On Mon, Sep  6, 2010 at 17:56:19 +0200, Johann Felix Soden wrote:
 
   .../{support_uncompression = support_compression} |   69 
  +--
 
 Care to provide a diff between the old and new patches? (I'm lazy, and
 debdiff doesn't know to do that.)

No problem, the diff between support_uncompression and
support_compression is attached.

Regards,
 Johann Felix Soden



diff -u b/pdftk/pdftk.cc b/pdftk/pdftk.cc
--- b/pdftk/pdftk.cc
+++ b/pdftk/pdftk.cc
@@ -159,8 +159,22 @@
 	}
 }
 
-void uncompress_stream(itext::PRStream* stream)
+void change_compression_stream(itext::PRStream* stream, bool compress_mode )
 {
+	if( compress_mode )
+	{
+
+		try {
+			stream-setData(  itext::PdfReader::getStreamBytes( stream ), compress_mode );
+		}
+		catch (itext::exceptions::UnsupportedPdfException * err ) { // unknow filter detected
+			// ignore this
+		}
+		return;
+	}
+
+	// - uncompress -
+
 	try { // try first itext own way
 		stream-setData( itext::PdfReader::getStreamBytes( stream ) );
 		stream-remove( itext::PdfName::FILTER );
@@ -242,16 +256,16 @@
 }
 
 
-void uncompress_dictionary( itext::PdfDictionary *dict, itext::PdfReader *reader )
+void change_compression_dictionary( itext::PdfDictionary *dict, itext::PdfReader *reader, bool compress_mode )
 {
 	if( !dict )
 		return;
 
 	// prevent circuit references
-	static setvoid* already_uncompressed;
-	if( already_uncompressed.find(dict) != already_uncompressed.end() )
+	static setvoid* already_handled;
+	if( already_handled.find(dict) != already_handled.end() )
 		return;
-	already_uncompressed.insert(dict);
+	already_handled.insert(dict);
 
 	java::util::Iterator * keys=dict-getKeys()-iterator();
 	while( keys-hasNext() ) {
@@ -265,18 +279,19 @@
 		if( !obj || obj == dict )
 			continue;
 		if( obj-isDictionary() )
-			uncompress_dictionary( (itext::PdfDictionary*)obj,reader );
+			change_compression_dictionary( (itext::PdfDictionary*)obj, reader, compress_mode );
 		if( obj-isStream() )
-			uncompress_stream( (itext::PRStream*) obj );
+			change_compression_stream( (itext::PRStream*) obj, compress_mode );
 	}
 }
 
-void uncompress( itext::PdfReader * reader )
+void change_compression( itext::PdfReader * reader, bool compress_mode )
 {
 	int pages = reader-getNumberOfPages();
+	itext::Document::Document::compress = compress_mode;
 
 	itext::PdfDictionary *catalog = reader-getCatalog();
-	uncompress_dictionary( catalog, reader );
+	change_compression_dictionary( catalog, reader, compress_mode );
 
 	for( int i=1; ireader-getXrefSize(); i++ )
 	{
@@ -284,14 +299,14 @@
 		if(!obj)
 			continue;
 		if( obj-isDictionary() )
-			uncompress_dictionary( (itext::PdfDictionary*)obj, reader );
+			change_compression_dictionary( (itext::PdfDictionary*)obj, reader, compress_mode );
 		if( obj-isStream() )
-			uncompress_stream( (itext::PRStream*)obj );
+			change_compression_stream( (itext::PRStream*)obj, compress_mode );
 	}
 
 	for( int i = 1; i = pages; i++ )
 	{
-		reader-setPageContent( i, reader-getPageContent( i ), 0 );
+		reader-setPageContent( i, reader-getPageContent( i ));
 	}
 }
 
@@ -651,6 +666,7 @@
 		return filt_uncompress_k;
 	}
 	else if( strcmp( ss_copy, compress )== 0 ) {
+		itext::Document::Document::compress=true;
 		return filt_compress_k;
 	}
 	else if( strcmp( ss_copy, flatten )== 0 ) {
@@ -2280,11 +2296,12 @@
 
 //
 if( m_output_uncompress_b ) {
-	uncompress(input_reader_p);
+	change_compression(input_reader_p, false );
 	add_mark_to_page( input_reader_p, it-m_page_num, output_page_count+ 1 );
 	writer_p-setCompressionLevel(0);
 }
 else if( m_output_compress_b ) {
+	change_compression(input_reader_p, true );
 	remove_mark_from_page( input_reader_p, it-m_page_num );
 	writer_p-setCompressionLevel(9);
 }
@@ -2358,13 +2375,14 @@
 
 	// un/compress output streams?
 	if( m_output_uncompress_b ) {
+		change_compression( input_reader_p, false );
 		// Absent from itext-2.1.4
 // 		writer_p-filterStreams= true;
 // 		writer_p-compressStreams= false;
  		writer_p-setCompressionLevel(0);
-		uncompress(input_reader_p);
 	}
 	else if( m_output_compress_b ) {
+		change_compression( input_reader_p, true );
 		// Absent from itext-2.1.4
 // 		writer_p-filterStreams= false;
 // 		writer_p-compressStreams= true;
@@ -2600,7 +2618,7 @@
 
 // un/compress output streams?
 if( m_output_uncompress_b ) {
-	uncompress(input_reader_p);
+	change_compression( input_reader_p, false );
 	add_marks_to_pages( input_reader_p );
 	// Absent from itext-2.1.4
 // 	writer_p-filterStreams= true;
@@ -2608,6 +2626,7 @@
  	writer_p-setCompressionLevel(0);
 }
 else if( m_output_compress_b ) {
+	change_compression( input_reader_p, true );
 	remove_marks_from_pages( input_reader_p );
 	// Absent from itext-2.1.4
 // 		

Bug#595777: unblock: pdftk/1.41+dfsg-9

2010-09-06 Thread Johann Felix Soden
On Mon, Sep  7, 2010 at 00:20 +0200, Julien Cristau wrote:
 On Mon, Sep  6, 2010 at 23:48:05 +0200, Johann Felix Soden wrote:
   On Mon, Sep  6, 2010 at 17:56:19 +0200, Johann Felix Soden wrote:
   
 .../{support_uncompression = support_compression} |   69 
+--
   
   Care to provide a diff between the old and new patches? (I'm lazy, and
   debdiff doesn't know to do that.)
  
  No problem, the diff between support_uncompression and
  support_compression is attached.
  
 It's kind of stretching it to call this a bugfix rather than a missing
 feature.  But it's small and unintrusive, so unblocked.
Thanks for unblocking.
In my opinion it is really a bugfix since pdf compression worked until 
pdftk-1.41+dfsg-1 when the code was needed to be adapted to a newer,
dfsg-free itext version with a different API. This resulted in lots of
patches to reintroduce the no longer working features and closing
related bugs. I should have used a more descriptive changelog entry...

Best regards,
 Johann Felix Soden





-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org