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