diff options
author | Tim S <tim-st@users.noreply.github.com> | 2019-08-15 14:39:41 +0200 |
---|---|---|
committer | Tim S <tim-st@users.noreply.github.com> | 2019-08-15 14:39:41 +0200 |
commit | 94823924d17ac5bdb913c7c212a82a1ff746356a (patch) | |
tree | e062316e4678201d6b545c31699c68874141484f | |
parent | abb2841fca8cde49264525e891960687315a3908 (diff) |
Add method `SetProducer`
This allows changing or removing the PDF producer string in the metadata of the PDF file.
-rw-r--r-- | def.go | 1 | ||||
-rw-r--r-- | fpdf.go | 14 |
2 files changed, 14 insertions, 1 deletions
@@ -563,6 +563,7 @@ type Fpdf struct { zoomMode string // zoom display mode layoutMode string // layout display mode xmp []byte // XMP metadata + producer string // producer title string // title subject string // subject author string // author @@ -198,6 +198,7 @@ func fpdfNew(orientationStr, unitStr, sizeStr, fontDirStr string, size SizeType) f.gradientList = append(f.gradientList, gradientType{}) // gradientList[0] is unused // Set default PDF version number f.pdfVersion = "1.3" + f.SetProducer("FPDF "+cnFpdfVersion, true) f.layerInit() f.catalogSort = gl.catalogSort f.creationDate = gl.creationDate @@ -559,6 +560,15 @@ func (f *Fpdf) SetCompression(compress bool) { f.compress = compress } +// SetProducer defines the producer of the document. isUTF8 indicates if the string +// is encoded in ISO-8859-1 (false) or UTF-8 (true). +func (f *Fpdf) SetProducer(producerStr string, isUTF8 bool) { + if isUTF8 { + producerStr = utf8toutf16(producerStr) + } + f.producer = producerStr +} + // SetTitle defines the title of the document. isUTF8 indicates if the string // is encoded in ISO-8859-1 (false) or UTF-8 (true). func (f *Fpdf) SetTitle(titleStr string, isUTF8 bool) { @@ -4473,7 +4483,9 @@ func (f *Fpdf) putresources() { func (f *Fpdf) putinfo() { var tm time.Time - f.outf("/Producer %s", f.textstring("FPDF "+cnFpdfVersion)) + if len(f.producer) > 0 { + f.outf("/Producer %s", f.textstring(f.producer)) + } if len(f.title) > 0 { f.outf("/Title %s", f.textstring(f.title)) } |