diff options
author | Svet Ganov <svetoslavganov@google.com> | 2014-06-14 22:29:00 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2014-07-09 18:43:38 +0000 |
commit | 525a66b2bb5abf844aff2109bdc9ed819566bece (patch) | |
tree | f1823f5ce8a6d26f538094bc6f99f23724e64d2f /graphics/java/android/graphics/pdf | |
parent | d8da5c8ff5535fffce0c11d017d64efbda05def6 (diff) | |
download | frameworks_base-525a66b2bb5abf844aff2109bdc9ed819566bece.zip frameworks_base-525a66b2bb5abf844aff2109bdc9ed819566bece.tar.gz frameworks_base-525a66b2bb5abf844aff2109bdc9ed819566bece.tar.bz2 |
Adding print preview.
This change adds the pring preview part of the new print UX. The
UI has two parts, the top section is the print options and the
bottom section print preview with a list of pages. The user can
interact only with one of them. When print options are expanded
they cover the preview content and a scrim is laid out on top of
the preview. Tapping the scrim collapses the print options. When
the user types in page ranges and closes the options to look at
the preview, the latter is updated to show only these pages. In
the list of pages the user can further prune pages by deselecting
them.
Change-Id: I0b23d2c598afe2a34400ccfa43e4e935af83c72f
Diffstat (limited to 'graphics/java/android/graphics/pdf')
-rw-r--r-- | graphics/java/android/graphics/pdf/PdfRenderer.java | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/graphics/java/android/graphics/pdf/PdfRenderer.java b/graphics/java/android/graphics/pdf/PdfRenderer.java index b63edce..b5d9729 100644 --- a/graphics/java/android/graphics/pdf/PdfRenderer.java +++ b/graphics/java/android/graphics/pdf/PdfRenderer.java @@ -70,6 +70,32 @@ import java.lang.annotation.RetentionPolicy; * renderer.close(); * </pre> * + * <h3>Print preview and print output</h3> + * <p> + * If you are using this class to rasterize a PDF for printing or show a print + * preview, it is recommended that you respect the following contract in order + * to provide a consistent user experience when seeing a preview and printing, + * i.e. the user sees a preview that is the same as the printout. + * </p> + * <ul> + * <li> + * Respect the property whether the document would like to be scaled for printing + * as per {@link #shouldScaleForPrinting()}. + * </li> + * <li> + * When scaling a document for printing the aspect ratio should be preserved. + * </li> + * <li> + * Do not inset the content with any margins from the {@link android.print.PrintAttributes} + * as the application is responsible to render it such that the margins are respected. + * </li> + * <li> + * If document page size is greater than the printed media size the content should + * be anchored to the upper left corner of the page for left-to-right locales and + * top right corner for right-to-left locales. + * </li> + * </ul> + * * @see #close() */ public final class PdfRenderer implements AutoCloseable { @@ -188,7 +214,6 @@ public final class PdfRenderer implements AutoCloseable { private void doClose() { if (mCurrentPage != null) { mCurrentPage.close(); - mCurrentPage = null; } nativeClose(mNativeDocument); try { @@ -280,7 +305,7 @@ public final class PdfRenderer implements AutoCloseable { * </p> * <p> * You may optionally specify a matrix to transform the content from page coordinates - * which are in points (1/72") to bitmap coordintates which are in pixels. If this + * 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. @@ -375,6 +400,7 @@ public final class PdfRenderer implements AutoCloseable { nativeClosePage(mNativePage); mNativePage = 0; mCloseGuard.close(); + mCurrentPage = null; } private void throwIfClosed() { |