I sincerely believe you need much more than one billion tokens to rewrite the entire PDF dependency stack in a memory safe language. I think you underestimate how many features PDF has.
Re security, there are many pdf viewers, so the rewrites exist, and some of them do not have the js execution engine and all that jazz that opens up all sorts of potential exploits.