This class is a helper for creating a PDF file for given print
attributes. It is useful for implementing printing via the native
Android graphics APIs.
This class computes the page width, page height, and content rectangle
from the provided print attributes and these precomputed values can be
accessed via {@link #getPageWidth()}, {@link #getPageHeight()}, and
{@link #getPageContentRect()}, respectively. The {@link #startPage(int)}
methods creates pages whose {@link PageInfo} is initialized with the
precomputed values for width, height, and content rectangle.
A typical use of the APIs looks like this:
// open a new document
PrintedPdfDocument document = new PrintedPdfDocument(context,
printAttributes);
// start a page
Page page = document.startPage(0);
// draw something on the page
View content = getContentView();
content.draw(page.getCanvas());
// finish the page
document.finishPage(page);
. . .
// add more pages
. . .
// write the document content
document.writeTo(getOutputStream());
//close the document
document.close();
|