Android create and print pdf from layout view

前端 未结 4 2026
梦毁少年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:15

    Use [PrintContent] (https://developer.android.com/reference/android/support/v4/print/PrintHelper.html)!

     // Get the print manager.
    PrintHelper printHelper = new PrintHelper(this);
    
    // Set the desired scale mode.
    printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT);
    
    // Get the bitmap for the ImageView's drawable.
    Bitmap bitmap = ((BitmapDrawable) mImageView.getDrawable()).getBitmap();
    
    // Print the bitmap.
    printHelper.printBitmap("Print Bitmap", bitmap);
    

提交回复
热议问题