diff options
author | Hal Canary <halcanary@google.com> | 2017-01-09 15:58:56 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-09 21:03:29 +0000 |
commit | 6294d3f79ecfb9355ce6d65305e28c5d60f4d05f (patch) | |
tree | 99937c69581e3bad1ed5dfd9b751bf95b133097c /site/user | |
parent | a55ffa2f06af6b9dc1f102eb0410f39408874970 (diff) |
documentation: corrections to PDF docs
NOTRY=true
Change-Id: Ib3a1ca0111c9fa2ed34021420c410f816e196274
Reviewed-on: https://skia-review.googlesource.com/6820
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'site/user')
-rw-r--r-- | site/user/sample/pdf.md | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/site/user/sample/pdf.md b/site/user/sample/pdf.md index d54172bc52..7bd7b74012 100644 --- a/site/user/sample/pdf.md +++ b/site/user/sample/pdf.md @@ -8,36 +8,33 @@ SkDocument and SkCanvas APIs. #include "SkDocument.h" - bool WritePDF(SkWStream* outputStream) { + void WritePDF(SkWStream* outputStream, + const char* documentTitle, + void (*writePage)(SkCanvas*, int page), + int numberOfPages, + SkSize pageSize) { SkDocument::PDFMetadata metadata; - metadata.fCreator = "creator...."; - metadata.fTitle = "title..."; - metadata.fAuthor = "author..."; - metadata.fSubject = "subject..."; - metadata.fKeywords = "keywords..."; - metadata.fCreator = "creator..."; - SkTime::DateTime now = get_current_date_and_time(); - metadata.fCreation.fEnabled = true; + metadata.fTitle = documentTitle; + metadata.fCreator = "Example WritePDF() Function"; + SkTime::DateTime now; + SkTime::GetDateTime(&now); + metadata.fCreation.fEnabled = true; metadata.fCreation.fDateTime = now; - metadata.fModified.fEnabled = true; + metadata.fModified.fEnabled = true; metadata.fModified.fDateTime = now; - sk_sp<SkDocument> pdfDocument(SkDocument::MakePDF( + sk_sp<SkDocument> pdfDocument = SkDocument::MakePDF( outputStream, SK_ScalarDefaultRasterDPI, metadata, nullptr, true); assert(pdfDocument); - int numberOfPages = ....; for (int page = 0; page < numberOfPages; ++page) { - SkScalar pageWidth = ....; - SkScalar pageHeight = ....; SkCanvas* pageCanvas = - pdfDocument->beginPage(pageWidth, pageHeight); - - // ....insert canvas draw commands here.... - + pdfDocument->beginPage(pageSize.width(), + pageSize.height()); + writePage(pageCanvas, page); pdfDocument->endPage(); } - return pdfDocument->close(); + pdfDocument->close(); } * * * |