Creating PDF file using iText from a Recyclerview (Entire items inside) in Android?

前端 未结 2 398
野趣味
野趣味 2021-01-15 03:39

Hi i was trying to create a PDF output file from a Recyclerview using the library iText . After hours of struggle i was able to create PDF from recylerview .

Followi

2条回答
  •  迷失自我
    2021-01-15 04:12

    You saved my day. But i had to change this line :

    image.scalePercent(70);
    image.setAlignment(Image.MIDDLE);
    

    with this :

    float scaler = ((document.getPageSize().getWidth() - document.leftMargin()
                        - document.rightMargin() - 0) / image.getWidth()) * 100; // 0 means you have no indentation. If you have any, change it.
                image.scalePercent(scaler);
                image.setAlignment(com.itextpdf.text.Image.ALIGN_CENTER | com.itextpdf.text.Image.ALIGN_TOP);
    

    Thank a lot

提交回复
热议问题