You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Unsupported color space kind: COSName{Indexed}. Will try DeviceRGB instead
2023-06-20 22:18:00.871 4848-4968 PdfBox-Android com.app.test E Trying to create other-bit image not supported
To reproduce
Code snippet to reproduce the behavior:
fun checkForPdfUrlExistAndGetFile() {
pdfStream.updateIn {
val pdfStream = repository.getFileStream(url)
val pdDocument: PDDocument = PDDocument.load(assets!!.open("test.pdf"))
val renderer = PDFRenderer(pdDocument)
val width = Util.getScreenWidth()
val listFields = createFields(packet.customDocument.customFormAdditionalData)
val imageBitmaps = pdDocument.use { document ->
document.pages.mapIndexed { index, page ->
val box = page.cropBox
val scaleFactor = if (width > box.width) {
width.toFloat() / box.width
} else {
box.width / width
}
val image = renderer.renderImage(
index,
scaleFactor,
ImageType.ARGB,
RenderDestination.VIEW
).asImageBitmap()
pdfHeight += image.height
PdfPage(
// Render the image to an RGB Bitmap
bitmap = image,
list = listFields[index].orEmpty().map {
createInputField(
field = it,
imageHeight = image.height,
scaleFactor = scaleFactor,
inputType = it.getInputType()
)
}
)
}
}
pdfHeight += pdfResizedheight
val pdfPages = imageBitmaps.toMutableList().apply {
add(
PdfPage(
bitmap = Bitmap.createBitmap(
/* width = */
width,
/* height = */
pdfResizedheight,
/* config = */
Bitmap.Config.ARGB_8888
).asImageBitmap(),
list = emptyList()
)
)
}
}
}
PDF example
Link or attach a PDF demonstrating the issue
Expected behavior
It should create pages bitmap array
Actual behavior
It throws error
Unsupported color space kind: COSName{Indexed}. Will try DeviceRGB instead
2023-06-21 13:54:15.392 4303-4799 PdfBox-Android com.app.test E Trying to create other-bit image not
supported
equest error
java.lang.IllegalArgumentException: width and height must be > 0
at android.graphics.Bitmap.createBitmap(Bitmap.java:1111)
at android.graphics.Bitmap.createBitmap(Bitmap.java:1078)
at android.graphics.Bitmap.createBitmap(Bitmap.java:1028)
at android.graphics.Bitmap.createBitmap(Bitmap.java:989)
at com.tom_roush.pdfbox.pdmodel.graphics.image.SampledImageReader.createBitmapFromRawStream(SampledImageReader.java:422)
at com.tom_roush.pdfbox.pdmodel.graphics.image.SampledImageReader.from8bit(SampledImageReader.java:370)
at com.tom_roush.pdfbox.pdmodel.graphics.image.SampledImageReader.getRGBImage(SampledImageReader.java:222)
at com.tom_roush.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:501)
at com.tom_roush.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:476)
at com.tom_roush.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:849)
at com.tom_roush.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:65)
at com.tom_roush.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:966)
at com.tom_roush.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:541)
at com.tom_roush.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:516)
at com.tom_roush.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:153)
at com.tom_roush.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:259)
at com.tom_roush.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:316)
at com.joinhomebase.homebase.homebase.feature.onboardingforms.viewmodel.CustomFormActivityViewModel$checkForPdfUrlExistAndGetFile$1.invokeSuspend(CustomFormActivityViewModel.kt:138)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Environment details:
PdfBox-Android version: [2.0.27.0]
Android API version: [API 33]
Additional context
I am adding pdf file to reproduce that
Describe the bug
Unsupported color space kind: COSName{Indexed}. Will try DeviceRGB instead
2023-06-20 22:18:00.871 4848-4968 PdfBox-Android com.app.test E Trying to create other-bit image not supported
To reproduce
Code snippet to reproduce the behavior:
PDF example
Link or attach a PDF demonstrating the issue
Expected behavior
It should create pages bitmap array
Actual behavior
It throws error
Unsupported color space kind: COSName{Indexed}. Will try DeviceRGB instead
2023-06-21 13:54:15.392 4303-4799 PdfBox-Android com.app.test E Trying to create other-bit image not
Environment details:
Additional context
I am adding pdf file to reproduce that
test_prod_1.pdf
The text was updated successfully, but these errors were encountered: