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)
To write mime type text/pdf i.e. a pdf without binary lib encodings you simply need to write a string like this (save as text.pdf to see how it works) Or right click & download the demo pdf cmd writer from https://github.com/GitHubRulesOK/MyNotes/raw/master/MAKE-PDF.cmd
or use in an iFrame