1

I am trying to convert android view into PDF using itextpdf libray but I am only getting half of view as pdf. Here I am Sharing my code

Code for getting the view

View v1 = getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
screen = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);

Code for converting that view into pdf

try {
     Document document = new Document();
     PdfWriter.getInstance(document, new FileOutputStream(pdfFile));
     document.open();
     ByteArrayOutputStream stream = new ByteArrayOutputStream();
     screen.compress(Bitmap.CompressFormat.PNG, 100, stream);
      byte[] byteArray = stream.toByteArray();
      addImage(document, byteArray);
      document.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  • For debugging purposes, save your screen to a PNG file, right before you add it to the pdf. Check the PNG file. If it is in half too, then you have simplified your question, because you will know for certain that it has nothing to do with iText. Or vice versa. – Amedee Van Gasse Mar 10 '16 at 07:59
  • Hii..I am getting the same issue. Did you find any solution ? If yes, then please share. Thanks in Advance. – priyanka kataria May 04 '17 at 07:00

0 Answers0