pdf reader - Android - PDFReader renders a smaller output than expected -


good day, following youtube tutorial on how use pdfrenderer display pdfs on imageview. downloaded code (link in description) , tried myself. works , displays pdf. however, output rather small. not occupy entire imageview area.

here layout life:

<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" >      <imageview         android:id="@+id/image"         android:layout_width="match_parent"         android:layout_height="0dp"         android:scaletype="fitxy"         android:layout_weight="1"/>      <linearlayout          android:layout_width="match_parent"         android:layout_height="wrap_content"         android:orientation="horizontal" >         <button              android:id="@+id/previous"             android:layout_width="0dp"             android:layout_height="wrap_content"             android:layout_weight="1"             android:text="previous" />         <button              android:id="@+id/next"             android:layout_width="0dp"             android:layout_height="wrap_content"             android:layout_weight="1"             android:text="next" />     </linearlayout> </linearlayout > 

here render() function:

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 < 0) {             currentpage = 0;         } else if(currentpage > 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());     } } 

my width 1536 , height 1792. however, output not maximize imageview's length , width. had play width , height values while. multiplying them integer gave smaller outputs, while dividing gave larger outputs (albeit quality seems have been compromised).

has spent time tinkering class? seems added in android l relatively new. however, there seems rather minimal tutorials regarding - considering have "native" pdf viewing class.

any appreciated - optimizing performance of class recommending pdf viewing classes vouch for. thanks.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -