【发布时间】:2015-06-25 11:07:16
【问题描述】:
我必须在 Android 上使用 PdfDocument 从我的 webView 创建 PDF。 https://developer.android.com/reference/android/graphics/pdf/PdfDocument.html pdf创建得很好,但它只有一页文档。
// create a new document
PdfDocument document = new PdfDocument();
// create a page description
PageInfo pageInfo = new PageInfo.Builder(width,
height, 1).create();
// start 1st page
Page page = document.startPage(pageInfo);
// draw something on the page
View content = myWebview;
content.draw(page.getCanvas());
// finish 1st page
document.finishPage(page);
// start 2nd page
Page page = document.startPage(pageInfo);
// draw something on the page
View content = someOtherWebview;
content.draw(page.getCanvas());
// finish 2nd page
document.finishPage(page);
// and so on...
FileOutputStream out;
try {
out = new FileOutputStream(fileNameWithPath, false);
// write the document content
document.writeTo(out);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// close the document
document.close();
如何在页面中划分 webview 内容?
【问题讨论】:
标签: java javascript android html canvas