> For the complete documentation index, see [llms.txt](https://notes.tejpratapsingh.com/pdf-creator-android/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.tejpratapsingh.com/pdf-creator-android/generate-pdf-from-html/webview-to-pdf.md).

# WebView To Pdf

With this feature, you can directly create Pdf from whatever your WebView is showing.

You can also add `contenteditable="true"` and have user edit data and create pdf from edited Data. You can just call Utility function: `PDFUtil.generatePDFFromWebView(savedPDFFile, webView, callback)`

You can see Example Code At: [PdfEditorActivity](https://github.com/tejpratap46/PDFCreatorAndroid/blob/master/app/src/main/java/com/tejpratapsingh/pdfcreatorandroid/PdfEditorActivity.java) of app.

#### Example:

```java
// Create Temp File to save Pdf To
final File savedPDFFile = FileManager.getInstance().createTempFile(getApplicationContext(), "pdf", false);
// Generate Pdf From Html
PDFUtil.generatePDFFromWebView(savedPDFFile, webView, new PDFPrint.OnPDFPrintListener() {
    @Override
    public void onSuccess(File file) {
        // Open Pdf Viewer
        Uri pdfUri = Uri.fromFile(savedPDFFile);

        Intent intentPdfViewer = new Intent(PdfEditorActivity.this, PdfViewerActivity.class);
        intentPdfViewer.putExtra(PdfViewerActivity.PDF_FILE_URI, pdfUri);

        startActivity(intentPdfViewer);
    }

    @Override
    public void onError(Exception exception) {
        exception.printStackTrace();
    }
});
```
