Added in API level 21

Page

class Page : AutoCloseable
kotlin.Any
   ↳ android.graphics.pdf.PdfRenderer.Page

This class represents a PDF document page for rendering.

Summary

Constants
static Int

Mode to render the content for display on a screen.

static Int

Mode to render the content for printing.

Public methods
Unit

Closes this page.

Int

Gets the page height in points (1/72").

Int

Gets the page index.

Int

Gets the page width in points (1/72").

Unit
render(destination: Bitmap, destClip: Rect?, transform: Matrix?, renderMode: Int)

Renders a page to a bitmap.

Protected methods
Unit

Constants

RENDER_MODE_FOR_DISPLAY

Added in API level 21
static val RENDER_MODE_FOR_DISPLAY: Int

Mode to render the content for display on a screen.

Value: 1

RENDER_MODE_FOR_PRINT

Added in API level 21
static val RENDER_MODE_FOR_PRINT: Int

Mode to render the content for printing.

Value: 2

Public methods

close

Added in API level 21
fun close(): Unit

Closes this page.

Exceptions
java.lang.Exception if this resource cannot be closed

getHeight

Added in API level 21
fun getHeight(): Int

Gets the page height in points (1/72").

Return
Int The height in points.

getIndex

Added in API level 21
fun getIndex(): Int

Gets the page index.

Return
Int The index.

getWidth

Added in API level 21
fun getWidth(): Int

Gets the page width in points (1/72").

Return
Int The width in points.

render

Added in API level 21
fun render(
    destination: Bitmap,
    destClip: Rect?,
    transform: Matrix?,
    renderMode: Int
): Unit

Renders a page to a bitmap.

You may optionally specify a rectangular clip in the bitmap bounds. No rendering outside the clip will be performed, hence it is your responsibility to initialize the bitmap outside the clip.

You may optionally specify a matrix to transform the content from page coordinates which are in points (1/72") to bitmap coordinates which are in pixels. If this matrix is not provided this method will apply a transformation that will fit the whole page to the destination clip if provided or the destination bitmap if no clip is provided.

The clip and transformation are useful for implementing tile rendering where the destination bitmap contains a portion of the image, for example when zooming. Another useful application is for printing where the size of the bitmap holding the page is too large and a client can render the page in stripes.

Note: The destination bitmap format must be ARGB.

Note: The optional transformation matrix must be affine as per Matrix.isAffine(). Hence, you can specify rotation, scaling, translation but not a perspective transformation.

Parameters
destination Bitmap: Destination bitmap to which to render. This value cannot be null.
destClip Rect?: Optional clip in the bitmap bounds. This value may be null.
transform Matrix?: Optional transformation to apply when rendering. This value may be null.
renderMode Int: The render mode. Value is android.graphics.pdf.PdfRenderer.Page#RENDER_MODE_FOR_DISPLAY, or android.graphics.pdf.PdfRenderer.Page#RENDER_MODE_FOR_PRINT

Protected methods

finalize

Added in API level 21
protected fun finalize(): Unit
Exceptions
java.lang.Throwable the Exception raised by this method