Bug 3390 Enabling ZIP compression in pdf generation to reduce file size
authorChris Nighswonger <cnighswonger@foundations.edu>
Sat, 4 Jul 2009 04:14:50 +0000 (00:14 -0400)
committerGalen Charlton <galen.charlton@liblime.com>
Mon, 13 Jul 2009 12:19:56 +0000 (08:19 -0400)
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.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
C4/Labels.pm
labels/label-print-pdf.pl

index ce8f359..b9b0dec 100644 (file)
@@ -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...
             );
         };
     }
index 6f48170..3534af2 100755 (executable)
@@ -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