Hi I'm trying to make a pdf only open in the brows...
# react
d
Hi I'm trying to make a pdf only open in the browser and it's still prompting to download
Copy code
IconButton {
                PictureAsPdf()
                onClick = {
                    mainScope.launch {
                        val pdfReport = getSingleReportForView(report.reportFileName)
                        if (pdfReport != null) {
                            val blob = Blob(arrayOf(pdfReport), BlobPropertyBag("application/pdf"))
                            val url = URL.createObjectURL(blob)

                            // Create an iframe element
                            val iframe = document.createElement("iframe") as HTMLIFrameElement
                            iframe.src = url
                            iframe.style.width = "100%"
                            iframe.style.height = "500px" // Set the desired height for the iframe

                            // Append the iframe to the DOM (e.g., inside a specific container)
                            val container = document.getElementById("pdfcontainer") // Replace "pdfContainer" with the ID of the container element
                            container?.appendChild(iframe)
                        }
                    }
                }
            }
b
d
Tried it. Still downloads without opening in browser.
b
Might just be browser defaults at play. Have you tried the same code on different browsers? i.e. chrome, safari, Firefox, gnome web
d
yes