Load pdf kotlin Android

good morning thanks, I am new to Kotlin, I need to upload PDF to Android, I use the developer.android.com documentation.

-We have an Api, which receives the file in Base64.LO QUE FUNCIONA

-With gallery images and taking photos it works,

This is the image code.

val iGaleria = Intent(Intent. ACTION_PICK , MediaStore.Images.Media. EXTERNAL_CONTENT_URI )
iGaleria. type = “image/*”
startActivityForResult(iGaleria, FOTO_GALERIA )

After selecting or taking the photo, the onActivityResult method I get the uri data? .Data

I convert it to base64 and send.

The problem

I try to do the same for PDF files but it doesn’t work for me. (I can view the PDF, delete or delete the PDF from the device)

This is the intent for the PDF

val intent = Intent(Intent. ACTION_GET_CONTENT )
intent. type = “application/pdf”
intent.addCategory(Intent. CATEGORY_OPENABLE )
startActivityForResult(intent, DOCUMENTO )

I have validated this documentation.


Bitmap: I get null the bitmap

InputStream: Data comes out of the pdf, “but as unconfigured without format, some metadata of the PDF”

%PDF-1.4%����3 0 obj<</Type/XObject/ColorSpace/DeviceRGB/Subtype/Image/BitsPerComponent 8/Width 189/Length 4099/Height 107/Filter/FlateDecode>>streamx���sU�