1

Can someone give me some pointers on how to convert a HTML page loaded in a webview to a pdf file. Is there a builtin android function that can help or some third party library that can be used to achieve this functionality.

Here is the complete scenario

I have a custom form that has various fields for user to fill in. After the submission of data, I want end users to be able to download the pdf version of the form.

For this, I plan to have a button say somewhere in the action bar, that converts the entire page to pdf.

user3276940
  • 487
  • 5
  • 16

1 Answers1

1

Read about Picture listener

Obtain Bitmap :

private static Bitmap pictureDrawable2Bitmap(PictureDrawable pictureDrawable) {
        Bitmap bitmap = Bitmap.createBitmap(
                pictureDrawable.getIntrinsicWidth(),
                pictureDrawable.getIntrinsicHeight(), Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        canvas.drawPicture(pictureDrawable.getPicture());
        return bitmap;
    }

Then use PDFDocument to create your file

PDF

garima
  • 5,154
  • 11
  • 46
  • 77