title: PDFReader renders a smaller output than expected in Android
body: <p>I was following this YouTube tutorial on <a href="https://www.youtube.com/watch?v=8YPJCOxiklQ" rel="nofollow noreferrer">how to use PDFRenderer</a> to display PDFs on an ImageView. I downloaded the code (link in the description) and I tried it myself. It works and it displays the PDF. However, the output I get is rather small. It does not occupy the entire imageView area. </p>
  
  <p>Here is my layout life:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent" 
      android:orientation="vertical" &gt;
  
      &lt;ImageView
          android:id="@+id/image"
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:scaleType="fitXY"
          android:layout_weight="1"/&gt;
  
      &lt;LinearLayout 
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal" &gt;
          &lt;Button 
              android:id="@+id/previous"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="Previous" /&gt;
          &lt;Button 
              android:id="@+id/next"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="Next" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout &gt;
  </code></pre>
  
  <p>Here is my <code>render()</code> function:</p>
  
  <pre><code>private void render() {
  
      try{
          imageView = (ImageView) findViewById(R.id.image);
  
          int REQ_WIDTH = imageView.getWidth();
          int REQ_HEIGHT = imageView.getHeight();
  
          Log.e(TAG, "width = " + REQ_WIDTH);
          Log.e(TAG, "height  = " + REQ_HEIGHT);
  
          File SDCardRoot = Environment.getExternalStorageDirectory();
          String destination = SDCardRoot.toString() + "/my/fileHere.pdf";
  
          Bitmap bitmap = Bitmap.createBitmap(REQ_WIDTH, REQ_HEIGHT, Bitmap.Config.ARGB_4444);
  
          File file = new File(destination);
          PdfRenderer renderer = new PdfRenderer(ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY));
  
          if(currentPage &lt; 0) {
              currentPage = 0;
          } else if(currentPage &gt; renderer.getPageCount()) {
              currentPage = renderer.getPageCount() - 1;
          }
  
          Matrix m = imageView.getImageMatrix();
          Rect rect = new Rect(0, 0, REQ_WIDTH, REQ_HEIGHT);
          renderer.openPage(currentPage).render(bitmap, rect, m, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);
          imageView.setImageMatrix(m);
          imageView.setImageBitmap(bitmap);
          imageView.setScaleType(ImageView.ScaleType.FIT_XY);
          imageView.invalidate();
  
      } catch(Exception e) {
          e.printStackTrace();
          Log.e(TAG, "catch: " + e.toString());
      }
  }
  </code></pre>
  
  <p>My width is 1536 and the height is 1792. However, the output does not maximize the imageview's length and width. I had to play with the width and height values for a while. Multiplying them with an integer gave smaller outputs, while dividing gave larger outputs (albeit that the quality seems to have been compromised). </p>
  
  <p>It seems that this was added in Android L so it is relatively new. However, there seems to be rather minimal tutorials regarding it - considering that we finally have a "native" PDF viewing class.</p>