Save pdf data in storage

63 views
Skip to first unread message

Soni Kumari

unread,
Jul 4, 2026, 9:11:10 PM (2 days ago) Jul 4
to DroidScript
Hi there! I'm working on a project that converts image to pdf. To convert i use base64
data:application/pdf;base64 so how to save this data in device storage.
Please tell me the way, I'd very appreciative 🙏 

Jumar

unread,
Jul 5, 2026, 6:08:40 AM (2 days ago) Jul 5
to DroidScript
Try this:

var appFolder = "/Internal/Documents/MyFolder";

function writePdfToDocuments(filePath, b64pdf) {
        const perm = "internal"
       
        if( !app.CheckPermission(appFolder) ) {
                app.GetPermission(perm, path => {
                        if (!path) {
                            app.ShowPopup("Permission not granted")
                        }
                        else {
                            writePdfToDocuments(filePath, b64pdf)
                        }
                    })
            return
        }
       
        app.MakeFolder(appFolder)
        app.WriteFile(filePath, b64pdf, "Base64")
        app.ShowPopup("PDF is saved to Documents/MyFolder folder")
    }

Regards

Soni Kumari

unread,
Jul 5, 2026, 9:36:40 AM (2 days ago) Jul 5
to DroidScript
Thank you so much for this! 
But Is there any more ways to save direct in Documents without permission?

Jumar

unread,
Jul 5, 2026, 10:15:20 AM (2 days ago) Jul 5
to DroidScript
Saving directly without asking permission is a NO for latest android.

To avoid asking for permission, initiate a download action the way download works for the web. I haven't tried this btw.

Soni Kumari

unread,
Jul 5, 2026, 1:44:50 PM (2 days ago) Jul 5
to DroidScript
Thanks for replying Jumar!
I was asking because when i convert lots images to pdf in base64 then app get hangs sp there any to fast processing and without app freezing?

Jumar

unread,
Jul 5, 2026, 9:03:20 PM (2 days ago) Jul 5
to DroidScript
Try running a background nodejs process to handle batch conversion so that your main thread will not hang.

Soni Kumari

unread,
Jul 5, 2026, 11:45:38 PM (2 days ago) Jul 5
to DroidScript
I don't understand this :(

Jumar

unread,
Jul 6, 2026, 7:40:22 AM (18 hours ago) Jul 6
to DroidScript
When creating an app we are working mostly in the main thread. When we do heavy operation (such as batch image to pdf conversion), this will take some time to complete making our main thread seems like hanging. Luckily, DroidScript supports Nodejs so we can run a nodejs thread in the background which is separated from our main ui thread. You just let nodejs handle heavy processing and then notify the main thread once nodejs finishes the job.

Soni Kumari

unread,
Jul 6, 2026, 4:13:29 PM (9 hours ago) Jul 6
to DroidScript
But how sir! I'm really confused here any demo files
I use js lib to convert image to pdf 

Reply all
Reply to author
Forward
0 new messages