Skip to content

An error will be reported when the output path has ".". #4

@lan2000

Description

@lan2000

android 10
pdf_merger 0.0.6

code:
final outputDirPath= '/data/user/0/com.auc.pdf_merger_example/cache/TestPDFMergerABCEFG5.png';
CreateImageFromPDFResponse response = await PdfMerger.createImageFromPDF(
path: singleFile, outputDirPath: outputDirPath, createOneImage: false);

An error will be reported when the output path has ".".
error log:
W/System.err(28691): java.io.FileNotFoundException: /data/user/0/com0.auc: open failed: EACCES (Permission denied)
W/System.err(28691): at libcore.io.IoBridge.open(IoBridge.java:496)
W/System.err(28691): at java.io.FileOutputStream.(FileOutputStream.java:235)
W/System.err(28691): at java.io.FileOutputStream.(FileOutputStream.java:125)
W/System.err(28691): at com.ril.pdf_merger.CreateImageFromPDF$create$pdfFromMultipleImage$1.invokeSuspend(CreateImageFromPDF.kt:67)
W/System.err(28691): at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
W/System.err(28691): at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
W/System.err(28691): at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
W/System.err(28691): at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
W/System.err(28691): at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
W/System.err(28691): at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
W/System.err(28691): Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
W/System.err(28691): at libcore.io.Linux.open(Native Method)
W/System.err(28691): at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
W/System.err(28691): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
W/System.err(28691): at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
W/System.err(28691): at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8464)
W/System.err(28691): at libcore.io.IoBridge.open(IoBridge.java:482)

CreateImageFromPDF.kt

        for (i in 0 until pageCount) {
                val page: CodecPage = decodeService.getPage(i)
                val rectF = RectF(0.toFloat(), 0.toFloat(), 1.toFloat(), 1.toFloat())

                val bitmap: Bitmap = page.renderBitmap(maxWidth!!, maxHeight!!, rectF)
                pdfImages.add(bitmap)

                if(!createOneImage!!){

                    val splitPath = outputDirPath!!.split(".")[0]
                    val splitPathExt = outputDirPath.split(".")[1];

                    Log.e("----MainActivity outputDirPath", outputDirPath);
                    Log.e("----MainActivity splitPath", splitPath);
                    Log.e("----MainActivity splitPathExt", splitPathExt);
                    print(splitPath)
                    print(splitPathExt)
                    val newPath = """$splitPath$i.$splitPathExt"""
                    pdfImagesPath.add(newPath)
                    val outputStream = FileOutputStream(newPath)
                    bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream)
                    outputStream.close()
                }
            }

log:
E/----MainActivity outputDirPath(28691): /data/user/0/com.auc.pdf_merger_example/cache/TestPDFMergerABCEFG5.png
E/----MainActivity splitPath(28691): /data/user/0/com
E/----MainActivity splitPathExt(28691): auc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions