()
| 294 | } |
| 295 | |
| 296 | public void drawPdf() { |
| 297 | showLog(format("drawPdf path:%s %s", this.path, this.page)); |
| 298 | |
| 299 | if (this.path != null){ |
| 300 | |
| 301 | // set scale |
| 302 | this.setMinZoom(this.minScale); |
| 303 | this.setMaxZoom(this.maxScale); |
| 304 | this.setMidZoom((this.maxScale+this.minScale)/2); |
| 305 | Constants.Pinch.MINIMUM_ZOOM = this.minScale; |
| 306 | Constants.Pinch.MAXIMUM_ZOOM = this.maxScale; |
| 307 | |
| 308 | Configurator configurator; |
| 309 | |
| 310 | if (this.path.startsWith("content://")) { |
| 311 | ContentResolver contentResolver = getContext().getContentResolver(); |
| 312 | InputStream inputStream = null; |
| 313 | Uri uri = Uri.parse(this.path); |
| 314 | try { |
| 315 | inputStream = contentResolver.openInputStream(uri); |
| 316 | } catch (FileNotFoundException e) { |
| 317 | throw new RuntimeException(e.getMessage()); |
| 318 | } |
| 319 | configurator = this.fromStream(inputStream); |
| 320 | } else { |
| 321 | configurator = this.fromUri(getURI(this.path)); |
| 322 | } |
| 323 | |
| 324 | configurator.defaultPage(this.page-1) |
| 325 | .swipeHorizontal(this.horizontal) |
| 326 | .onPageChange(this) |
| 327 | .onLoad(this) |
| 328 | .onError(this) |
| 329 | .onDraw(this) |
| 330 | .onPageScroll(this) |
| 331 | .spacing(this.spacing) |
| 332 | .password(this.password) |
| 333 | .enableAntialiasing(this.enableAntialiasing) |
| 334 | .pageFitPolicy(this.fitPolicy) |
| 335 | .pageSnap(this.pageSnap) |
| 336 | .autoSpacing(this.autoSpacing) |
| 337 | .pageFling(this.pageFling) |
| 338 | .enableSwipe(!this.singlePage && this.scrollEnabled) |
| 339 | .enableDoubletap(!this.singlePage && this.enableDoubleTapZoom) |
| 340 | .enableAnnotationRendering(this.enableAnnotationRendering) |
| 341 | .linkHandler(this) |
| 342 | ; |
| 343 | |
| 344 | if (enableRTL) { |
| 345 | try { |
| 346 | int pageCount = getPdfPageCount(new File(this.path)); |
| 347 | int[] reversedPages = new int[pageCount]; |
| 348 | for (int i=0; i<pageCount; i++) { |
| 349 | reversedPages[i] = pageCount-1 - i; |
| 350 | } |
| 351 | configurator.pages(reversedPages); |
| 352 | if(this.page != 1){ |
| 353 | this.page = pageCount; |
no test coverage detected