Changes

Jump to: navigation, search

An Android Custom Document Printing Tutorial

93 bytes added, 19:31, 29 January 2014
no edit summary
<br><br><google>BUY_ANDROID</google><br>
As we have seen in the preceding chapters, the Android Printing framework makes it relatively easy to build printing support into applications as long as the content is in the form of an image or HTML markup. More advanced printing requirements can be met by making use of the custom document printing feature of the Printing framework.
Figure 51-2
<google>BUY_ANDROID</google>
When writing the pages to the PDF document, the onWrite() method must take steps to ensure that only those pages specified by the user are printed. To make this possible, the Printing framework passes through as an argument an array of PageRange objects indicating the ranges of pages to be printed. In the above onWrite() implementation, a method named pagesInRange() is called for each page to verify that the page is within the specified ranges. The code for the pagesInRange() method will be implemented later in this chapter.
Although more complex to implement than the Android Printing framework HTML and image printing options, custom document printing provides considerable flexibility in terms of printing complex content from within an Android application. The majority of the work involved in implementing custom document printing involves the creation of a custom Print Adapter class such that it not only draws the content on the document pages, but also responds correctly as changes are made by the user to print settings such as the page size and range of pages to be printed.
<br><google>BUY_ANDROID</google><br>

Navigation menu