Skip to content

Commit 62d675f

Browse files
authored
Fix the rendering of PDF covers in some edge cases (#64)
1 parent 72991f7 commit 62d675f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ All notable changes to this project will be documented in this file. Take a look
4444

4545
* Fix building with Kotlin 1.6.
4646

47+
#### Streamer
48+
49+
* Fixed the rendering of PDF covers in some edge cases.
50+
4751
#### Navigator
4852

4953
* Fixed turning pages of an EPUB reflowable resource with an odd number of columns. A virtual blank trailing column is appended to the resource when displayed as two columns.

readium/streamer/src/main/java/org/readium/r2/streamer/parser/pdf/PdfiumDocument.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,20 @@ internal class PdfiumDocument(
5454
}
5555

5656
private fun PdfiumCore.renderCover(document: _PdfiumDocument): Bitmap? {
57-
try {
58-
val pointer = openPage(document, 0)
59-
if (pointer <= 0) return null
60-
57+
return try {
58+
openPage(document, 0)
6159
val width = getPageWidth(document, 0)
6260
val height = getPageHeight(document, 0)
6361
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
6462
renderPageBitmap(document, bitmap, 0, 0, 0, width, height, false)
65-
return bitmap
63+
bitmap
6664

6765
} catch (e: Exception) {
6866
Timber.e(e)
69-
return null
67+
null
7068
} catch (e: OutOfMemoryError) { // We don't want to catch any Error, only OOM.
7169
Timber.e(e)
72-
return null
70+
null
7371
}
7472
}
7573

0 commit comments

Comments
 (0)