bitcrowd / chromic_pdf

Convenient HTML to PDF/A rendering library for Elixir based on Chrome & Ghostscript
Apache License 2.0
409 stars 37 forks source link

Ability to call `Emulation.setScriptExecutionDisabled` on a per-page basis? #267

Closed osbre closed 1 year ago

osbre commented 1 year ago

Hello. I'm wondering whether it's possible to set :disable_scripts not globally for all pages, but only on specific pages.

I'm guessing it would've been possible by calling Emulation.setScriptExecutionDisabled when needed?
(make it a parameter for print_to_pdf)

I've tried to attempt on contributing this feature in ChromicPDF.Navigate, however, failed to do so due to a limited experience with Elixir. (some things are beyond my understanding - it looks like there is a restriction on what can be called inside the Navigate module, and this list is in the @type navigate_option from Supervisor?)

As a side note, looks like there are more methods that can be called this way, I've noticed in this script: https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/src/common/EmulationManager.ts#L208

list of methods in EmulationManager.ts
MaeIsBad commented 1 year ago

This was how I implemented this feature in the original PR, so I think this could be implemented by just reverting https://github.com/bitcrowd/chromic_pdf/pull/168

osbre commented 1 year ago

Thank you @MaeIsBad, sent a PR: https://github.com/bitcrowd/chromic_pdf/pull/268

maltoe commented 1 year ago

See discussion in PR, this can now be done by using multiple session pools.