📄
PDF Creator Android
  • Introduction
  • Docs
  • Installation
  • Getting Started
  • Available Views
    • PDFVerticalView
    • PDFHorizontalView
    • PDFTextView
    • PDFImageView
    • PDFLineSeparatorView
    • PDFPageBreakView
    • PDFTableView
      • PDFTableRowView
  • Generate Pdf From HTML
    • Html To Pdf
    • WebView To Pdf
Powered by GitBook
On this page
  1. Generate Pdf From HTML

WebView To Pdf

PreviousHtml To Pdf

Last updated 4 years ago

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: of app.

Example:

// 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();
    }
});
PdfEditorActivity