Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Unified Diff: site/user/sample/pdf.md

Issue 1780463008: SkPDF: metadata first (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/PDFMetadataAttributeTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: site/user/sample/pdf.md
diff --git a/site/user/sample/pdf.md b/site/user/sample/pdf.md
index 0a2aa4d471f16f88c1cd8a801551d64a9588f0f7..360fb4d02372b5a741107d12fe24adeb7e049a32 100644
--- a/site/user/sample/pdf.md
+++ b/site/user/sample/pdf.md
@@ -4,15 +4,24 @@ Using Skia's PDF Backend
Here is an example of using Skia's PDF backend in the recommended way:
via the SkDocument and SkCanvas APIs.
-<!--?prettify?-->
+<!--?prettify lang=cc?-->
#include "SkDocument.h"
- bool WritePDF() {
- SkWStream* outputStream = ....;
-
- SkAutoTUnref<SkDocument> pdfDocument(
- SkDocument::CreatePDF(outputStream));
+ bool WritePDF(SkWStream* outputStream) {
+ sk_sp<SkDocument> pdfDocument(SkDocument::CreatePDF(outputStream));
+ typedef SkDocument::Attribute Attr;
+ Attr info[] = {
+ Attr(SkString("Title"), SkString("....")),
+ Attr(SkString("Author"), SkString("....")),
+ Attr(SkString("Subject"), SkString("....")),
+ Attr(SkString("Keywords"), SkString("....")),
+ Attr(SkString("Creator"), SkString("....")),
+ };
+ int infoCount = sizeof(info) / sizeof(info[0]);
+ SkTime::DateTime now;
+ SkTime::GetDateTime(&now);
+ pdfDocument->setMetadata(info, infoCount, &now, &now);
int numberOfPages = ....;
for (int page = 0; page < numberOfPages; ++page) {
@@ -25,16 +34,5 @@ via the SkDocument and SkCanvas APIs.
pdfDocument->endPage();
}
-
- 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);
- pdfDocument->setMetadata(info, &now, &now);
-
return pdfDocument->close();
}
« no previous file with comments | « no previous file | tests/PDFMetadataAttributeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698