| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2013 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 | |
| 9 #ifndef SkPdfRenderer_DEFINED | |
| 10 #define SkPdfRenderer_DEFINED | |
| 11 | |
| 12 // TODO(edisonn): remove this dependency, and load only from a stream! | |
| 13 #include "SkString.h" | |
| 14 | |
| 15 class SkBitmap; | |
| 16 class SkCanvas; | |
| 17 class SkPdfNativeDoc; | |
| 18 struct SkRect; | |
| 19 class SkStream; | |
| 20 class SkString; | |
| 21 | |
| 22 // What kind of content to render. | |
| 23 enum SkPdfContent { | |
| 24 kNoForms_SkPdfContent, | |
| 25 kAll_SkPdfContent, | |
| 26 }; | |
| 27 | |
| 28 /** \class SkPdfRenderer | |
| 29 * | |
| 30 * The SkPdfRenderer class is used to render a PDF into canvas. | |
| 31 * | |
| 32 */ | |
| 33 class SkPdfRenderer { | |
| 34 public: | |
| 35 SkPdfRenderer() : fPdfDoc(NULL) {} | |
| 36 virtual ~SkPdfRenderer() {unload();} | |
| 37 | |
| 38 // Render a specific page into the canvas, in a specific rectangle. | |
| 39 bool renderPage(int page, SkCanvas* canvas, const SkRect& dst) const; | |
| 40 | |
| 41 // TODO(edisonn): deprecated, should be removed! | |
| 42 bool load(const SkString inputFileName); | |
| 43 | |
| 44 // TODO(edisonn): replace it with a SkSmartStream which would know to to eff
iciently | |
| 45 // deal with a HTTP stream. | |
| 46 bool load(SkStream* stream); | |
| 47 | |
| 48 // Unloads the pdf document. | |
| 49 void unload(); | |
| 50 | |
| 51 // Returns true if we succesfully loaded a document. | |
| 52 bool loaded() const {return fPdfDoc != NULL && pages() > 0;} | |
| 53 | |
| 54 // Returns the number of pages in the loaded pdf. | |
| 55 int pages() const; | |
| 56 | |
| 57 // Returns the MediaBox of a page. Can be used by client to crate a canvas. | |
| 58 SkRect MediaBox(int page) const; | |
| 59 | |
| 60 // TODO(edisonn): for testing only, probably it should be removed, unless so
me client wants to | |
| 61 // let users know how much memory the PDF needs. | |
| 62 size_t bytesUsed() const; | |
| 63 | |
| 64 private: | |
| 65 SkPdfNativeDoc* fPdfDoc; | |
| 66 }; | |
| 67 | |
| 68 // For testing only, reports stats about rendering, like how many operations fai
led, or are NYI, ... | |
| 69 void reportPdfRenderStats(); | |
| 70 | |
| 71 // Renders a page of a pdf in a bitmap. | |
| 72 bool SkPDFNativeRenderToBitmap(SkStream* stream, | |
| 73 SkBitmap* output, | |
| 74 int page = 0, | |
| 75 SkPdfContent content = kAll_SkPdfContent, | |
| 76 double dpi = 72.0); | |
| 77 | |
| 78 // TODO(edisonn): add options to render forms, checkboxes, ... | |
| 79 // TODO(edisonn): Add API for Forms viewing and editing | |
| 80 // e.g. SkBitmap getPage(int page); | |
| 81 // int formsCount(); | |
| 82 // SkForm getForm(int formID); // SkForm(SkRect, .. other data) | |
| 83 // TODO (edisonn): Add intend when loading pdf, for example: for viewing, for pa
rsing content, ... | |
| 84 | |
| 85 #endif // SkPdfRenderer_DEFINED | |
| OLD | NEW |