Technically commendable. But please please please stop contributing to PDF, especially in the conversion to PDF. It’s a horrible format.
Accessible, lighter, works on screen readers, extensible, a standard.
As for rogue JS, there are good, open-source countermeasures such as dompurify.
PDF is not reflowable and results in a crappy reading experience unless the device screen size is just right.