farling42 / fvtt-pdf-pager

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

Support Form-Fillable PDFs #8

Closed farling42 closed 1 year ago

farling42 commented 1 year ago

See PDFoundry classes, although some might not work on V10?

See ActorViewer at https://djphoenix719.github.io/PDFoundry/modules/api.html

farling42 commented 1 year ago

The pdfjs viewer.html runs in its own iframe, so getting events into/out of the iframe might be more difficult.

// Get contents of the iframe containing the PDFJS viewer.html
let window = game.journal.getName('OLBH Rulebook').sheet._element.find('iframe')[0].contentWindow;
let inputs = window.document.body.getElementsByTagName('input')
// Set the "NAME" of the Cypher Character Sheet to "Thomas"
for (let elem of inputs) if (elem.name == "Name") elem.value = "Thomas"
// Get the contents of the "Name" field
for (let elem of inputs) if (elem.name == "Name") console.log(elem.value)
farling42 commented 1 year ago

Handle passing user changes back to the Actor with inputelem.addEventListener('change', (event) => {}); on each of the fields.

farling42 commented 1 year ago

Test with : ui.pdfpager.configureInputs(game.journal.getName('OLBH Rulebook'),game.journal.getName('OLBH Rulebook').sheet._element.find('iframe')[0])

farling42 commented 1 year ago

Need to set an iframe.onload function to link in the field editing hooks (probably in render_inner).

Need to hook onto an event which will fire when viewer.html has finished loading the page, since iframe.onload fires as soon as viewer.html starts.

farling42 commented 1 year ago

Two ways of working in 0.12.0