you can modify the above code with this val cw = ContextWrapper(applicationContext) val FileDirectory = cw.getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS) val mFilePath = File(FireDirectory, "your pdf file name".pdf"
@@kbcoder8788 Im trying with this, but when I want to open in the default reader it tells me that it cannot open val abrirPdf = Intent(Intent.ACTION_VIEW) abrirPdf.setDataAndType(FileProvider.getUriForFile(this@MainActivity,"com.topoffice.pdfcreator2.fileprovider", File("storage/emulated/0/$mFileName.pdf") ),"application/pdf") abrirPdf.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION abrirPdf.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP abrirPdf.flags = Intent.FLAG_ACTIVITY_NEW_TASK startActivity(abrirPdf)
I was getting the 'open failed: EACCES (Permission denied)' error every time. I could solve it changing the filepath to: val filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString() + "/" + fileName + ".pdf" I hope this helps someone!
Here, how i can do for send it an image instead of a text? what would change?
Like and suscribed :D
Thanks for this tutorial. Is there any way to add image to PDF as well? I would really appreciate it.
how to save content html to pdf? pls
thanks.. how to generate pdf file for say invoice A4 size page
Bro can you do a tutorial video of generate pdf but with images, that we able scanner image and pass it to a pdf
Yes i will do it
@@kbcoder8788 can you help me with a consult?
Getting error getExternalStorageDirectory() is deprecated and app crashing
you can modify the above code with this val cw = ContextWrapper(applicationContext)
val FileDirectory = cw.getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS)
val mFilePath = File(FireDirectory, "your pdf file name".pdf"
thank you for the video but its throwing an error "FileNotFoundException open failed: XXXXXXX EPERM (Operation not permitted)"
me too :(
android:requestLegacyExternalStorage="true"
What do I have to change so that when I press the button it opens the pdf after saving to the device?
Create the function of view PDF
@@kbcoder8788 that is done with intent?
@@kbcoder8788 The pdf is saved on /storage/emulated/ how do i access that?
@@kbcoder8788 Im trying with this, but when I want to open in the default reader it tells me that it cannot open
val abrirPdf = Intent(Intent.ACTION_VIEW)
abrirPdf.setDataAndType(FileProvider.getUriForFile(this@MainActivity,"com.topoffice.pdfcreator2.fileprovider",
File("storage/emulated/0/$mFileName.pdf")
),"application/pdf")
abrirPdf.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
abrirPdf.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
abrirPdf.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(abrirPdf)
@@joaquinuliambre315 I would like to that as well, if you found a solution i'd appreciate it if you could share it
It never worked, try with the help of a comment here, it generates the pdf for me but it cannot be found, dislike
same
no funciona!!
I'm not able to generate pdf
I was getting the 'open failed: EACCES (Permission denied)' error every time. I could solve it changing the filepath to: val filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString() + "/" + fileName + ".pdf"
I hope this helps someone!
thanks alot, its helped me
@Twitch Land you're welcome 😃
@@abdullahtauseef406 you're welcome 😁
This helped me..😊
Thanks a lot Luis
THANK YOU SO MUCH!