Android APIs
public final class

PdfRenderer.Page

extends Object
implements AutoCloseable
java.lang.Object
   ↳ android.graphics.pdf.PdfRenderer.Page

Class Overview

This class represents a PDF document page for rendering.

Summary

Constants
int RENDER_MODE_FOR_DISPLAY Mode to render the content for display on a screen.
int RENDER_MODE_FOR_PRINT Mode to render the content for printing.
Public Methods
void close()
Closes this page.
int getHeight()
Gets the page height in points (1/72").
int getIndex()
Gets the page index.
int getWidth()
Gets the page width in points (1/72").
void render(Bitmap destination, Rect destClip, Matrix transform, int renderMode)
Renders a page to a bitmap.
Protected Methods
void finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.AutoCloseable

Constants

public static final int RENDER_MODE_FOR_DISPLAY

Added in API level 21

Mode to render the content for display on a screen.

Constant Value: 1 (0x00000001)

public static final int RENDER_MODE_FOR_PRINT

Added in API level 21

Mode to render the content for printing.

Constant Value: 2 (0x00000002)

Public Methods

public void close ()

Added in API level 21

Closes this page.

See Also

public int getHeight ()

Added in API level 21

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

Returns
  • The height in points.

public int getIndex ()

Added in API level 21

Gets the page index.

Returns
  • The index.

public int getWidth ()

Added in API level 21

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

Returns
  • The width in points.

public void render (Bitmap destination, Rect destClip, Matrix transform, int renderMode)

Added in API level 21

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 Destination bitmap to which to render.
destClip Optional clip in the bitmap bounds.
transform Optional transformation to apply when rendering.
renderMode The render mode.

Protected Methods

protected void finalize ()

Added in API level 21

Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.

Note that objects that override finalize are significantly more expensive than objects that don't. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it's better to provide an explicit close method (and implement Closeable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like a BigInteger where typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.

If you must use finalizers, consider at least providing your own ReferenceQueue and having your own thread process that queue.

Unlike constructors, finalizers are not automatically chained. You are responsible for calling super.finalize() yourself.

Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.

Throws
Throwable