Skip to content

[api-minor]XFA - Add a layer to display XFA forms #13069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2021

Conversation

calixteman
Copy link
Contributor

  • add an option to enable XFA rendering if any;
  • for now, let the canvas layer: it could be useful to implement XFAF forms (embedded pdf in xml stream for the background and xfa form for the foreground);
  • ui elements in template DOM are pretty close to their html counterpart so we generate a fake html DOM from template one:
    • it makes easier to translate template properties to html ones;
    • it makes faster the creation of the html element in the main thread.

@calixteman calixteman force-pushed the xfa_layer branch 2 times, most recently from ae94a07 to 84a0758 Compare March 11, 2021 09:18

class XfaLayer {
static setAttributes(html, attrs) {
for (const [key, value] of Object.entries(attrs)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm, only the predefined attributes from the various toHTML can be set here right? I just want to confirm we don't need need to remove any potentially malicious attributes from XFA (e.g. onclick).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, normally everything is under control:

  • only nodes and attributes defined in spec are in the final form DOM;
  • the various toHTML functions will generate some HTML based on those attributes and nodes.
    So it's impossible to have some injections.
    XFA can contain some xhtml, by spec nodes and attributes are limited too. And for xhtml nodes style is parsed to filter out any forbidden property:
    https://github.com/mozilla/pdf.js/blob/master/src/core/xfa/xhtml.js#L63
    So it should be safe.

@brendandahl brendandahl changed the title XFA - Add a layer to display XFA forms [api-minor]XFA - Add a layer to display XFA forms Mar 18, 2021
@@ -1165,6 +1176,14 @@ class PDFPageProxy {
));
}

/**
* @returns {Promise<Object | null>} A promise that is resolved with
* an {Object} with a fake DOM object, or `null` if no XFA exists.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should describe what fake DOM object means.

Copy link
Contributor

@brendandahl brendandahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+ with more documentation on the public API part.

  - add an option to enable XFA rendering if any;
  - for now, let the canvas layer: it could be useful to implement XFAF forms (embedded pdf in xml stream for the background and xfa form for the foreground);
  - ui elements in template DOM are pretty close to their html counterpart so we generate a fake html DOM from template one:
    - it makes easier to translate template properties to html ones;
    - it makes faster the creation of the html element in the main thread.
@calixteman
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @calixteman received. Current queue size: 0

Live output at: http://54.67.70.0:8877/9fffb7a6f7ae842/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @calixteman received. Current queue size: 0

Live output at: http://3.101.106.178:8877/8b5cbe9758360e8/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/9fffb7a6f7ae842/output.txt

Total script time: 24.46 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/9fffb7a6f7ae842/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://3.101.106.178:8877/8b5cbe9758360e8/output.txt

Total script time: 29.69 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED

Image differences available at: http://3.101.106.178:8877/8b5cbe9758360e8/reftest-analyzer.html#web=eq.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants