title: WebView: java.lang.IllegalArgumentException: width and height must be > 0
body: <p>I get the error <code>java.lang.IllegalArgumentException: width and height must be &gt; 0</code> and I think this error may be caused by the webview. I am trying to display a rendered PDF file in a webview and there are some files which work fine but others launch this error.</p>
  
  <p>activity_convert.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
  &lt;WebView
      android:id="@+id/webView1"
      android:layout_width="match_parent"
      android:layout_height="match_parent"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>onCreate method:</p>
  
  <pre><code>//Setup webview
      wv = (WebView)findViewById(R.id.webView1);
      wv.getSettings().setBuiltInZoomControls(true);//show zoom buttons
      wv.getSettings().setSupportZoom(true);//allow zoom
      //get the width of the webview
  
      wv.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
          @Override
          public void onGlobalLayout() {
              ViewSize = wv.getWidth();
              //ViewSize = wv.getHeight();
              System.out.println("webView: " + wv.getWidth());
              System.out.println("webView: " + wv.getHeight());
              wv.getViewTreeObserver().removeGlobalOnLayoutListener(this);
          }
      });
  </code></pre>
  
  <p>PDF render:</p>
  
  <pre><code>//create pdf document object from bytes
  ByteBuffer bb = ByteBuffer.NEW(data);
  PDFFile pdf = new PDFFile(bb);
  //Get the first page from the pdf doc
  PDFPage PDFpage = pdf.getPage(1, true);
  //create a scaling value according to the WebView Width
  final float scale = ViewSize / PDFpage.getWidth() * 0.95f;
  //convert the page into a bitmap with a scaling value
  Bitmap page = PDFpage.getImage((int)(PDFpage.getWidth() * scale), (int)(PDFpage.getHeight() * scale), null, true, true)
  </code></pre>
  
  <p>I have been reading several posts here with the same problem but their solutions don't work for my code. I've tried to get the width and height parameters but I can't figure out why this doesn't work.</p>