Android create and print pdf from layout view

前端 未结 4 2005
梦毁少年i
梦毁少年i 2021-01-12 13:36

I am trying to create PDF file from xml layout view. I have a listview in that layout, adding items and setting height based on child. PDF is creating but not filling the wh

4条回答
  •  逝去的感伤
    2021-01-12 14:16

    Change to this,

            int measureWidth = View.MeasureSpec.makeMeasureSpec(page.getCanvas().getWidth(), View.MeasureSpec.EXACTLY);
            int measuredHeight = View.MeasureSpec.makeMeasureSpec(page.getCanvas().getHeight(), View.MeasureSpec.EXACTLY);
    
            content.measure(measureWidth, measuredHeight);
            content.layout(0, 0, page.getCanvas().getWidth(), page.getCanvas().getHeight());
    

    This will get page full height and width.

提交回复
热议问题