Document
- class Document
- 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: - canvas = doc.beginPage(…) 
- draw_my_content(canvas) 
- doc.endPage() 
 
- Close the document with doc.close(). 
 - skia-pythonsupports- withsyntax to build a document:- stream = skia.FILEWStream('output.pdf') with skia.PDF.MakeDocument(stream) as document: with document.page(480, 640) as canvas: draw(canvas) - Methods - abort(self: skia.Document) -> None - beginPage(self: skia.Document, width: float, height: float, content: skia.Rect = None) -> SkCanvas - close(self: skia.Document) -> None - endPage(self: skia.Document) -> None - page(self: skia.Document, width: float, height: float) -> (anonymous namespace)::PyAutoDocumentPage - ref(self: skia.RefCntBase) -> None - unique(self: skia.RefCntBase) -> bool - unref(self: skia.RefCntBase) -> None 
Methods
- Document.__init__(*args, **kwargs)
- Document.abort(self: skia.Document) None
- Call - abort()to stop producing the document immediately.- The stream output must be ignored, and should not be trusted. 
- Document.beginPage(self: skia.Document, width: float, height: float, content: skia.Rect = None) SkCanvas
- 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.
- Document.close(self: skia.Document) None
- 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.
- Document.endPage(self: skia.Document) None
- 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.
- Document.page(self: skia.Document, width: float, height: float) (anonymous namespace)::PyAutoDocumentPage
- Document.ref(self: skia.RefCntBase) None
- Increment the reference count. - Must be balanced by a call to - unref().
- Document.unique(self: skia.RefCntBase) bool
- May return true if the caller is the only owner. - Ensures that all previous owner’s actions are complete. 
- Document.unref(self: skia.RefCntBase) None
- Decrement the reference count. - If the reference count is 1 before the decrement, then delete the object. Note that if this is the case, then the object needs to have been allocated via new, and not on the stack.