diff options
author | 2015-09-23 12:45:49 -0700 | |
---|---|---|
committer | 2015-09-23 12:45:49 -0700 | |
commit | f12a1673f024d30d30f06b9f88b5cc072b8a2d1e (patch) | |
tree | 8b8e41c3737a7041534da2ab78f34f1ae0c35b0d /include/core/SkDocument.h | |
parent | ab26a9b427ec7c525ccd0025f19f0c91b74d8f6d (diff) |
SkPDF: add basic metadata support
Motivation: I want too finalize this API before working on the more
complex problem of adding XMP metadata for PDF/A.
BUG=skia:3110
Review URL: https://codereview.chromium.org/1359943003
Diffstat (limited to 'include/core/SkDocument.h')
-rw-r--r-- | include/core/SkDocument.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/include/core/SkDocument.h b/include/core/SkDocument.h index a35f448208..316d15a253 100644 --- a/include/core/SkDocument.h +++ b/include/core/SkDocument.h @@ -12,6 +12,8 @@ #include "SkPicture.h" #include "SkRect.h" #include "SkRefCnt.h" +#include "SkString.h" +#include "SkTime.h" class SkCanvas; class SkWStream; @@ -104,6 +106,33 @@ public: */ void abort(); + /** + * Set the document's metadata, if supported by the document + * type. The creationDate and modifiedDate parameters can be + * nullptr. For example: + * + * SkDocument* make_doc(SkWStream* output) { + * SkTArray<SkDocument::Attribute> info; + * info.emplace_back(SkString("Title"), SkString("...")); + * info.emplace_back(SkString("Author"), SkString("...")); + * info.emplace_back(SkString("Subject"), SkString("...")); + * info.emplace_back(SkString("Keywords"), SkString("...")); + * info.emplace_back(SkString("Creator"), SkString("...")); + * SkTime::DateTime now; + * SkTime::GetDateTime(&now); + * SkDocument* doc = SkDocument::CreatePDF(output); + * doc->setMetadata(info, &now, &now); + * return doc; + * } + */ + struct Attribute { + SkString fKey, fValue; + Attribute(const SkString& k, const SkString& v) : fKey(k), fValue(v) {} + }; + virtual void setMetadata(const SkTArray<SkDocument::Attribute>&, + const SkTime::DateTime* /* creationDate */, + const SkTime::DateTime* /* modifiedDate */) {} + protected: SkDocument(SkWStream*, void (*)(SkWStream*, bool aborted)); |