From 157aff3575e05946317098493519bb770b328972 Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 18 Aug 2016 11:53:32 -0400 Subject: Allow default compression mode to be set. Go 1.7 introduces a new compression/flate routine that results in different compressed streams than before. Consequently, PDFs generated with go 1.7 are not generally binary-equivalent with those generated with previous versions. Turning off compression for test files removes this variability. However, it does not help with PDFs that contain images. For now, those reference PDFs have been removed to allow tests to proceed. --- fpdf.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'fpdf.go') diff --git a/fpdf.go b/fpdf.go index c5e8e6b..07005df 100644 --- a/fpdf.go +++ b/fpdf.go @@ -44,6 +44,7 @@ import ( var gl struct { catalogSort bool + noCompress bool // Initial zero value indicates compression creationDate time.Time } @@ -174,7 +175,7 @@ func fpdfNew(orientationStr, unitStr, sizeStr, fontDirStr string, size SizeType) return f.autoPageBreak } // Enable compression - f.SetCompression(true) + f.SetCompression(!gl.noCompress) f.blendList = make([]blendModeType, 0, 8) f.blendList = append(f.blendList, blendModeType{}) // blendList[0] is unused (1-based) f.blendMap = make(map[string]int) @@ -431,15 +432,19 @@ func (f *Fpdf) SetDisplayMode(zoomStr, layoutStr string) { } } +// SetDefaultCompression controls the default setting of the internal +// compression flag. See SetCompression() for more details. Compression is on +// by default. +func SetDefaultCompression(compress bool) { + gl.noCompress = !compress +} + // SetCompression activates or deactivates page compression with zlib. When // activated, the internal representation of each page is compressed, which // leads to a compression ratio of about 2 for the resulting document. // Compression is on by default. func (f *Fpdf) SetCompression(compress bool) { - // if(function_exists('gzcompress')) f.compress = compress - // else - // $this->compress = false; } // SetTitle defines the title of the document. isUTF8 indicates if the string -- cgit v1.2.1-24-ge1ad