你好,我想在Crosswalk中從webview創建PDF,但我沒有找到任何支持方法如何做。目前我使用這個選項來創建位圖Android如何從Crosswalk webview創建PDF?
How can I capture the whole view into a Bitmap when using crosswalk to display webpage?
,然後我試圖利用iText位圖轉換LIB How I can convert a bitmap into PDF format in android作爲輸出我得到空白的PDF(黑頁)。
這裏是位圖的代碼:
private void createBitmap (XWalkView view) {
String pathToFile = Environment.getExternalStorageDirectory() +"/bitmap.jpg";
view.setDrawingCacheEnabled(true);
view.buildDrawingCache(true);
Bitmap btmp = view.getDrawingCache();
Canvas canvas = new Canvas(btmp);
Paint paint = new Paint();
int height = btmp.getHeight();
canvas.drawBitmap(btmp, 0, height, paint);
view.draw(canvas);
try {
OutputStream fOut = null;
File file = new File(pathToFile);
fOut = new FileOutputStream(file);
btmp.compress(Bitmap.CompressFormat.JPEG, 50, fOut);
fOut.flush();
fOut.close();
btmp.recycle();
view.setDrawingCacheEnabled(false);
view.destroyDrawingCache();
} catch (Exception e) {
e.printStackTrace();
}
}
我只需要提示:)。非常感謝。這是我的第一個問題,我爲錯別字道歉
謝謝你幫了我很多:) –