farling42 / fvtt-pdf-pager

PDF Pager for Foundry
MIT License
6 stars 4 forks source link

Allow PDF buttons to trigger foundry JS scripts #83

Open farling42 opened 6 months ago

farling42 commented 6 months ago

Update the field mapping object so that PDF buttons can be triggered and will call an appropriate function on the field object.

farling42 commented 6 months ago

pdfjs library has ButtonWidgetAnnotation in src/core/annotation.js

button.data.checkBox (not RADIO and not PUSHBUTTON) button.data.radioButton (RADIO and not PUSHBUTTON) button.data.pushButton (PUSHBUTTON)

Then uses one of _processCheckBox, _processRadioButton, _processPushButton

pdfjs creates elements of type "button".

farling42 commented 6 months ago

It looks like setValue will always be called (even if the value hasn't changed, because pdf-pager doesn't know if the application value has changed). But the event handler hooks might only register on blur or updatefromsandbox events.

farling42 commented 6 months ago

I can't find a free PDF editor which will let me edit buttons (not checkable or radio buttons), so that I can set just the "alternativeText" which is required if there isn't an "A" or "AA" link associated with the button.

farling42 commented 6 months ago

The simplest option at the moment is to create a checkbox and set the setValue function to trigger the corresponding Foundry JS code.

farling42 commented 6 months ago

Version 0.49.1 has some basic support for clicking on a button. I haven't been able to get hold of a form-fillable PDF which has buttons configured it which will get displayed by the pdfjs library (the button needs to have an A or AA link in it).