summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt <kurt.w.jung@gmail.com>2017-08-30 09:56:27 -0400
committerKurt <kurt.w.jung@gmail.com>2017-08-30 09:56:27 -0400
commit41ab61b9c9cea6554839b654462e207b251bfa40 (patch)
tree94300ed6fa13355775ec7fbf2b3447380392ca8f
parent4491d0fe5997270270f8e4023786afd99251f604 (diff)
parent16426726215a8fa06ba79853db70a8db933e52b9 (diff)
Merge branch 'echa-master'
-rw-r--r--def.go1
-rw-r--r--fpdf.go17
2 files changed, 18 insertions, 0 deletions
diff --git a/def.go b/def.go
index 552415f..fd6ef81 100644
--- a/def.go
+++ b/def.go
@@ -224,6 +224,7 @@ type Fpdf struct {
footerFncLpi func(bool) // function provided by app and called to write footer with last page flag
zoomMode string // zoom display mode
layoutMode string // layout display mode
+ xmp []byte // XMP metadata
title string // title
subject string // subject
author string // author
diff --git a/fpdf.go b/fpdf.go
index 27e0c98..df16043 100644
--- a/fpdf.go
+++ b/fpdf.go
@@ -510,6 +510,11 @@ func (f *Fpdf) SetCreator(creatorStr string, isUTF8 bool) {
f.creator = creatorStr
}
+// SetXmpMetadata defines XMP metadata that will be embedded with the document.
+func (f *Fpdf) SetXmpMetadata(xmpStream []byte) {
+ f.xmp = xmpStream
+}
+
// AliasNbPages defines an alias for the total number of pages. It will be
// substituted as the document is closed. An empty string is replaced with the
// string "{nb}".
@@ -3650,6 +3655,16 @@ func (f *Fpdf) puttrailer() {
}
}
+func (f *Fpdf) putxmp() {
+ if len(f.xmp) == 0 {
+ return
+ }
+ f.newobj()
+ f.outf("<< /Type /Metadata /Subtype /XML /Length %d >>", len(f.xmp))
+ f.putstream(f.xmp)
+ f.out("endobj")
+}
+
func (f *Fpdf) putbookmarks() {
nb := len(f.outlines)
if nb > 0 {
@@ -3716,6 +3731,8 @@ func (f *Fpdf) enddoc() {
}
// Bookmarks
f.putbookmarks()
+ // Metadata
+ f.putxmp()
// Info
f.newobj()
f.out("<<")