summaryrefslogtreecommitdiffstats
path: root/core/java/android/webkit/WebView.java
diff options
context:
space:
mode:
authorSelim Gurun <sgurun@google.com>2013-08-05 15:23:09 -0700
committerSelim Gurun <sgurun@google.com>2013-08-12 10:55:39 -0700
commit2167c0be56cc859e38f69df150747055d67b1ea0 (patch)
tree8638745a7af65e65066208153c0d86242b9934ae /core/java/android/webkit/WebView.java
parent9b59e5aa9cd5d239b18f5b864959fb2feae05665 (diff)
downloadframeworks_base-2167c0be56cc859e38f69df150747055d67b1ea0.zip
frameworks_base-2167c0be56cc859e38f69df150747055d67b1ea0.tar.gz
frameworks_base-2167c0be56cc859e38f69df150747055d67b1ea0.tar.bz2
Add the API to support webview printing
Bug: 10190508 Change-Id: I47fc46bb1ea632876048b29621843f781c47aab7
Diffstat (limited to 'core/java/android/webkit/WebView.java')
-rw-r--r--core/java/android/webkit/WebView.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index a6e68d0..afed4f0 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -48,6 +48,7 @@ import android.widget.AbsoluteLayout;
import java.io.BufferedWriter;
import java.io.File;
+import java.io.OutputStream;
import java.util.Map;
/**
@@ -1034,6 +1035,34 @@ public class WebView extends AbsoluteLayout
}
/**
+ * Exports the contents of this Webview as PDF. Only supported for API levels
+ * {@link android.os.Build.VERSION_CODES#KEY_LIME_PIE} and above.
+ *
+ * @param out The stream to export the PDF contents to. Cannot be null.
+ * @param width The page width. Should be larger than 0.
+ * @param height The page height. Should be larger than 0.
+ * @param resultCallback A callback to be invoked when the PDF content is exported.
+ * A true indicates success, and a false failure.
+ *
+ * TODO: explain method parameters, margins, consider making the callback
+ * return more meaningful information, explain any threading concerns, HW
+ * draw limitations, and make it public.
+ * TODO: at the moment we are asking app to provide paper size information (width
+ * and height). This is likely not ideal (I think need margin info too).
+ * Another approach would be using PrintAttributes. This is to be clarified later.
+ *
+ * TODO: explain this webview will not draw during export (onDraw will clear to
+ * background color) so recommend taking it offscreen, or putting in a layer with an
+ * overlaid progress UI / spinner.
+ * @hide
+ */
+ public void exportToPdf(OutputStream out, int width, int height,
+ ValueCallback<Boolean> resultCallback) {
+ checkThread();
+ mProvider.exportToPdf(out, width, height, resultCallback);
+ }
+
+ /**
* Gets the current scale of this WebView.
*
* @return the current scale