Hopding / pdf-lib

Create and modify PDF documents in any JavaScript environment
https://pdf-lib.js.org
MIT License
6.74k stars 645 forks source link

Run existing PDF Javascript from PDF-Lib #1556

Open nux1701 opened 9 months ago

nux1701 commented 9 months ago

Describe your idea

Besides having a addJavascript() method to add Javascript script to PDFDocument, it would be great if we could run preexisting Javascript from the PDF, applying its effects accordingly.

How could this be implemented?

This could be implemented by proxifying most of the PDF Javascript functions to PDF-Lib ones. Or providing a lower level API that behaves like native PDF Javascript in a contextualized sandbox providing all native features.

What problem are you trying to solve?

I am trying to have a preexisting Javascript code to run and edit fields based on other fields states instead of rewriting it all. Plus, I couldn't figure some low level API to hide/show fields which this script is doing.

Why does this matter to you?

It would help me out with a personnal project where I need this custom JS to run instead of figuring out how most of the low level changes (in appearances for example) work in the least documented part of the documentation.

Would others find this helpful?

Could be a niche solution, but very useful if needed.

Are you interested in implementing your proposal?

Yes, but I don't know if I have the relevant experience and knowledge of the library and PDF API.

Why are you submitting a proposal?

I want to know if it is feasible, or maybe it currently is!

Additional Notes

No response

keshavk2910 commented 6 months ago

+1