[Koha-patches] [PATCH 2/2] Bug 3390 Enabling ZIP compression in pdf generation to reduce file size

Chris Nighswonger cnighswonger at foundations.edu
Sat Jul 4 06:14:50 CEST 2009


Enabling compression gives a ~26% *reduction* over non-compressed Type 3 font embedding.
ie. 4.5 K/pg (compressed graphic) vs. 17.5 K/pg (uncompressed Type 3 font) vs 111 K/pg
(uncompressed graphic).

It also appears that most other applications that export in pdf use compression by
default. (OO Writer, etc.) So this approach appears justified. One could always add code
to allow the user to select embedding mode and compression.

Also correcting mode parameter value.
---
 C4/Labels.pm              |   14 +++++++-------
 labels/label-print-pdf.pl |    1 +
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/C4/Labels.pm b/C4/Labels.pm
index ce8f359..b9b0dec 100644
--- a/C4/Labels.pm
+++ b/C4/Labels.pm
@@ -44,9 +44,9 @@ BEGIN {
 		&CreateTemplate &SetActiveTemplate
 		&SaveConf &GetTextWrapCols
 		&GetUnitsValue
-        &DrawSpineText
-        &DrawBarcode
-        &DrawPatronCardText
+                &DrawSpineText
+                &DrawBarcode
+                &DrawPatronCardText
 		&get_printingtypes &GetPatronCardItems
 		&get_layouts
 		&get_barcode_types
@@ -1165,7 +1165,7 @@ sub DrawBarcode {
                 ySize         => ( .02 * $height ),
                 xSize         => $xsize_ratio,
                 hide_asterisk => 1,
-                mode            => '',  # the only other option here is Type3...
+                mode          => 'graphic',  # the only other option here is Type3...
             );
         };
     }
@@ -1186,7 +1186,7 @@ sub DrawBarcode {
                 ySize         => ( .02 * $height ),
                 xSize         => $xsize_ratio,
                 hide_asterisk => 1,
-                mode            => '',  # the only other option here is Type3...
+                mode          => 'graphic',  # the only other option here is Type3...
             );
         };
     }
@@ -1208,7 +1208,7 @@ sub DrawBarcode {
                 xSize         => $xsize_ratio,
                 hide_asterisk => 1,
 		text          => 0, 
-                mode            => '',  # the only other option here is Type3...
+                mode          => 'graphic',  # the only other option here is Type3...
             );
         };
     }
@@ -1297,7 +1297,7 @@ sub build_circ_barcode {
                 # prolong => 2.96,
                 xSize => .85,
                 ySize => 1.3,
-                mode            => '',  # the only other option here is Type3...
+                mode            => 'graphic',  # the only other option here is Type3...
             );
         };
     }
diff --git a/labels/label-print-pdf.pl b/labels/label-print-pdf.pl
index 6f48170..3534af2 100755
--- a/labels/label-print-pdf.pl
+++ b/labels/label-print-pdf.pl
@@ -112,6 +112,7 @@ print $cgi->header( -type => 'application/pdf', -attachment => 'barcode.pdf' );
 prInitVars();
 $| = 1;
 prFile();   # No args means to STDOUT
+prCompress(1);  # turn on zip compression which dramatically reduces file size
 prMbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
 
 # drawbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );  #do page border
-- 
1.6.3.1




More information about the Koha-patches mailing list