PdfJet and ContentChooser problem

rafaelmotaquintana

Active Member
Licensed User
I have this line in my code

B4X:
            PdfImage.Initialize(PDFjet,File.OpenInput(lfolder,imagenname),PDFjetConstants1.ImageType.JPG)

After select the image, that happens to be a PNG file, I don't know what extension the file has, so I copy it with jpg.
The problem arises when pdfjet initialize the object, expecting a jpg file, while the real file is Png. It crash.

How do I know the extension of the file after using ContentChooser to select the file from gallery and copy to a folder?
Thanks
 

Descartex

Well-Known Member
Licensed User
Longtime User
Hi
With this, you can know the filename:
B4X:
Sub Button1_Click
    CC.Show("*/*", "Choose a file")
End Sub

Sub ContentChooser_Result (Success As Boolean, Dir As String, FileName As String)
    If Success Then
        Msgbox(FileName, "Result")
    End If
End Sub
try searching the file extension before loading it. Something like
B4X:
Dim fileExtension as String
fileExtension=FileName.SubString2(FileName.LastIndexOf("/"),FileName.Lenght-1)
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…