summaryrefslogtreecommitdiff
path: root/fpdf.go
diff options
context:
space:
mode:
authorKurt <kurt.w.jung@gmail.com>2016-08-18 11:53:32 -0400
committerKurt <kurt.w.jung@gmail.com>2016-08-18 11:53:32 -0400
commit157aff3575e05946317098493519bb770b328972 (patch)
tree675c84f2ec31fdab6dc4ced54be388de7a9af29c /fpdf.go
parent5f4a9bf681f9360dc6485cb34108b7fd0bb43c02 (diff)
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.
Diffstat (limited to 'fpdf.go')
-rw-r--r--fpdf.go13
1 files changed, 9 insertions, 4 deletions
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