High-level API for creating a document-based canvas.
More...
#include <SkDocument.h>
|
enum | State { kBetweenPages_State,
kInPage_State,
kClosed_State
} |
|
|
| SkDocument (SkWStream *, void(*)(SkWStream *, bool aborted)) |
|
virtual SkCanvas * | onBeginPage (SkScalar width, SkScalar height, const SkRect &content)=0 |
|
virtual void | onEndPage ()=0 |
|
virtual void | onClose (SkWStream *)=0 |
|
virtual void | onAbort ()=0 |
|
SkWStream * | getStream () |
|
State | getState () const |
|
void | internal_dispose_restore_refcnt_to_1 () const |
| Allow subclasses to call this if they've overridden internal_dispose so they can reset fRefCnt before the destructor is called or if they choose not to call the destructor (e.g. More...
|
|
High-level API for creating a document-based canvas.
To use..
- Create a document, specifying a stream to store the output.
- For each "page" of content: a. canvas = doc->beginPage(...) b. draw_my_content(canvas); c. doc->endPage();
- Close the document with doc->close().
void SkDocument::abort |
( |
| ) |
|
Call abort() to stop producing the document immediately.
The stream output must be ignored, and should not be trusted.
SkCanvas* SkDocument::beginPage |
( |
SkScalar |
width, |
|
|
SkScalar |
height, |
|
|
const SkRect * |
content = NULL |
|
) |
| |
Begin a new page for the document, returning the canvas that will draw into the page.
The document owns this canvas, and it will go out of scope when endPage() or close() is called, or the document is deleted.
void SkDocument::close |
( |
| ) |
|
Call close() when all pages have been drawn.
This will close the file or stream holding the document's contents. After close() the document can no longer add new pages. Deleting the document will automatically call close() if need be.
void SkDocument::endPage |
( |
| ) |
|
Call endPage() when the content for the current page has been drawn (into the canvas returned by beginPage()).
After this call the canvas returned by beginPage() will be out-of-scope.
Create a PDF-backed document, writing the results into a SkWStream.
PDF pages are sized in point units. 1 pt == 1/72 inch == 127/360 mm.
- Parameters
-
stream | A PDF document will be written to this stream. The document may write to the stream at anytime during its lifetime, until either close() is called or the document is deleted. |
dpi | The DPI (pixels-per-inch) at which features without native PDF support will be rasterized (e.g. draw image with perspective, draw text with perspective, ...) A larger DPI would create a PDF that reflects the original intent with better fidelity, but it can make for larger PDF files too, which would use more memory while rendering, and it would be slower to be processed or sent online or to printer. |
metadata | a PDFmetadata object. Any fields may be left empty. |
jpegEncoder | For PDF documents, if a jpegEncoder is set, use it to encode SkImages and SkBitmaps as [JFIF]JPEGs. This feature is deprecated and is only supplied for backwards compatability. The prefered method to create PDFs with JPEG images is to use SkImage::NewFromEncoded() and not jpegEncoder. Chromium uses NewFromEncoded. If the encoder is unset, or if jpegEncoder->onEncode() returns NULL, fall back on encoding images losslessly with Deflate. |
pdfa | Iff true, include XMP metadata, a document UUID, and sRGB output intent information. This adds length to the document and makes it non-reproducable, but are necessary features for PDF/A-2b conformance |
- Returns
- NULL if there is an error, otherwise a newly created PDF-backed SkDocument.
The documentation for this class was generated from the following file: