I have to create PDF from my webView using PdfDocument on Android. https://developer.android.com/reference/android/graphics/pdf/PdfDocument.html The pdf is created well but it is only one page document.
// 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();
How can I divide webview content in pages?