I want to create a PDF with
new File(["<body>text<body>"],"application/pdf")
But I want it without any libs
With Vanilla Js
And get base 64 string with new FileReader Also tried URL.createObjectURL
it returns a URL but if I open it, after some time it closes automatically Also, how can I add data to a new file for pdf Like => new File([data] , ...)
const file = new File(['<body>Text</body>'] , "app.pdf")
//Or.
const file = new File(['<body>Text</body>'] , "app.pdf" , {type: 'application/pdf'})
const D = new FileReader()
D.onload = ()=> {console.log(this.result || D.result)}
D.readAsDataURL(file)
Or with blob
const file = new File(['<body>Text</body>'] , "app.pdf" )
//Or.
const file = new File(['<body>Text</body>'] , "app.pdf" , {type: "application/pdf"})
URL.createObjectURL(file)