PdfViewCtrl Image Conversion

Product: 9.2.1

Product Version: Native Android SDK

Please give a brief summary of your issue:
Image conversion error when file type is not appended to file name

Please describe your issue and provide steps to reproduce it:
When trying to convert image types (jpg, jpeg, png, etc.) to .pdf when the image type is not appended to the file name (test) I see an error

Message: Input file is of unknown type because file extension is not specified.

When the file name has the type appended (test.png) it converts perfectly and displays correctly when using the Convert.toPdf(pdfDoc, file.absolutePath). Is there another way to determine the file’s mimetype for conversion than be a part of the file name’s String?

Reproduction Steps with sample project:

  1. open app
  2. App will Crash with above error.
  3. open the “assets” folder and rename the test file to test.png.
  4. open the MainActivity and go to line 51.
  5. make the line val fileName = "test.png" instead of val fileName = "test"
  6. run app and the file converts perfectly and displays.

Please provide a link to a minimal sample where the issue is reproducible:

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:



Thanks for contacting us. You can pass in a file extension as part of the ConversionOptions, see the following snippet:

    private fun insertImage() {
        val file = getFileFromAssets()
        // Using PDFTRON
        binding.pdfViewCtrl.visibility = View.VISIBLE
        val filter = SecondaryFileFilter(this, Uri.fromFile(file))
        val fileExtension = Utils.getUriExtension(contentResolver, Uri.fromFile(file))
        val option = OfficeToPDFOptions("{\"RemovePadding\": true}")

        if (Utils.isNullOrEmpty(fileExtension)) {
            option.fileExtension = ".png"
        } else {
            option.fileExtension = fileExtension

        val conv = universalConversion(filter, option)

        binding.pdfViewCtrl.doc = conv.doc

Could you please give this a try?