summaryrefslogtreecommitdiff
path: root/fpdf.go
diff options
context:
space:
mode:
authorAlexander Eichhorn <alex@kidtsunami.com>2017-08-30 15:12:34 +0200
committerAlexander Eichhorn <alex@kidtsunami.com>2017-08-30 15:14:11 +0200
commit0e5c39bf5495154aa9dfd140db18db7345d7b824 (patch)
tree137d993ea22913b6ed3143480aa104cc9af56a34 /fpdf.go
parent4491d0fe5997270270f8e4023786afd99251f604 (diff)
add xmp metadata output
Diffstat (limited to 'fpdf.go')
-rw-r--r--fpdf.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/fpdf.go b/fpdf.go
index 27e0c98..3009dd7 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 {
@@ -3722,6 +3737,8 @@ func (f *Fpdf) enddoc() {
f.putinfo()
f.out(">>")
f.out("endobj")
+ // Metadata
+ f.putxmp()
// Catalog
f.newobj()
f.out("<<")