From f4786191eb9b711ee2be1dcf78e6c01458bd6b22 Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Sat, 4 Jul 2009 00:14:50 -0400 Subject: [PATCH] Bug 3390 Enabling ZIP compression in pdf generation to reduce file size 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 --- C4/Labels.pm | 6 +++++- labels/label-print-pdf.pl | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/C4/Labels.pm b/C4/Labels.pm index 9992526093..e4fbd5d650 100644 --- a/C4/Labels.pm +++ b/C4/Labels.pm @@ -1202,6 +1202,7 @@ sub DrawBarcode { ySize => ( .02 * $height ), xSize => $xsize_ratio, hide_asterisk => 1, + mode => 'graphic', # the only other option here is Type3... ); }; if ($@) { @@ -1227,6 +1228,7 @@ sub DrawBarcode { ySize => ( .02 * $height ), xSize => $xsize_ratio, hide_asterisk => 1, + mode => 'graphic', # the only other option here is Type3... ); }; @@ -1252,7 +1254,8 @@ sub DrawBarcode { ySize => ( .02 * $height ), xSize => $xsize_ratio, hide_asterisk => 1, - text => 0, + text => 0, + mode => 'graphic', # the only other option here is Type3... ); }; @@ -1370,6 +1373,7 @@ sub build_circ_barcode { xSize => .85, ySize => 1.3, + mode => 'graphic', # the only other option here is Type3... ); }; if ($@) { diff --git a/labels/label-print-pdf.pl b/labels/label-print-pdf.pl index c66162b7bf..51fefe1281 100755 --- a/labels/label-print-pdf.pl +++ b/labels/label-print-pdf.pl @@ -106,6 +106,17 @@ my $lowerLeftY = 0; my $upperRightX = $page_width; my $upperRightY = $page_height; +warn "Active profile: " . ($profile->{prof_id} || "None") if $DEBUG; + +#### PRINT PRELIMINARY DATA #### +print $cgi->header( -type => 'application/pdf', -attachment => 'barcode.pdf' ); + # Don't print header until very last possible moment + # That way if error or die occurs, fatals_to_browser will still work. + # After we print this header, there is no way back to HTML. All we can do is deliver 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 ); my $codetype; # = 'Code39'; -- 2.39.5