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

Side by Side Diff: site/user/sample/pdf.md

Issue 1360193002: Documentation: SkDocument::setMetadata() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 Using Skia's PDF Backend 1 Using Skia's PDF Backend
2 ======================== 2 ========================
3 3
4 Here is an example of using Skia's PDF backend in the recommended way: 4 Here is an example of using Skia's PDF backend in the recommended way:
5 via the SkDocument and SkCanvas APIs. 5 via the SkDocument and SkCanvas APIs.
6 6
7 <!--?prettify?--> 7 <!--?prettify?-->
8 8
9 #include "SkDocument.h" 9 #include "SkDocument.h"
10 10
11 bool WritePDF() { 11 bool WritePDF() {
12 SkWStream* output = ....; 12 SkWStream* outputStream = ....;
13 13
14 SkAutoTUnref<SkDocument> pdfDocument( 14 SkAutoTUnref<SkDocument> pdfDocument(
15 SkDocument::CreatePDF(outputStream)); 15 SkDocument::CreatePDF(outputStream));
16 16
17 int numberOfPages = ....; 17 int numberOfPages = ....;
18 for (int page = 0; page < numberOfPages; ++page) { 18 for (int page = 0; page < numberOfPages; ++page) {
19 SkScalar pageWidth = ....; 19 SkScalar pageWidth = ....;
20 SkScalar pageHeight = ....; 20 SkScalar pageHeight = ....;
21 SkCanvas* pageCanvas = 21 SkCanvas* pageCanvas =
22 pdfDocument->beginPage(pageWidth, pageHeight); 22 pdfDocument->beginPage(pageWidth, pageHeight);
23 23
24 // ....insert canvas draw commands here.... 24 // ....insert canvas draw commands here....
25 25
26 pdfDocument->endPage(); 26 pdfDocument->endPage();
27 } 27 }
28
29 SkTArray<SkDocument::Attribute> info;
30 info.emplace_back(SkString("Title"), SkString("...."));
31 info.emplace_back(SkString("Author"), SkString("...."));
32 info.emplace_back(SkString("Subject"), SkString("...."));
33 info.emplace_back(SkString("Keywords"), SkString("...."));
34 info.emplace_back(SkString("Creator"), SkString("...."));
35 SkTime::DateTime now;
36 SkTime::GetDateTime(&now);
37 pdfDocument->setMetadata(info, &now, &now);
38
28 return pdfDocument->close(); 39 return pdfDocument->close();
29 } 40 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698