85.1 An Overview of Android Custom Document Printing
In simplistic terms, custom document printing uses canvases to represent the pages of the document to be printed. The application draws the content to be printed onto these canvases in the form of shapes, colors, text and images. In actual fact, the canvases are represented by instances of the Android Canvas class, thereby providing access to a rich selection of drawing options. Once all the pages have been drawn, the document is then printed.
While this sounds simple enough, there are actually a number of steps that need to be performed to make this happen, which can be summarized as follows:
•Implement a custom print adapter sub-classed from the PrintDocumentAdapter class
•Obtain a reference to the Print Manager Service
•Create an instance of the PdfDocument class in which to store the document pages
•Add pages to the PdfDocument in the form of PdfDocument.Page instances
•Obtain...