Skip to content
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

Render interactive form (AcroForm) text widget annotations #7602

Merged
merged 2 commits into from
Sep 8, 2016

Conversation

timvandermeij
Copy link
Contributor

@timvandermeij timvandermeij commented Sep 6, 2016

This patch is the first step towards implementing support for interactive forms (AcroForms). It makes it possible to render text widget annotations exactly like Adobe Reader/Acrobat.

Everything we implement for AcroForms is disabled by default using a preference, mainly because it is not ready to use yet, but has to implemented in many steps to avoid complexity. The preference allows us to work with the code while not exposing the behavior by default. Mainly storing entered values and printing them is still absent, which would be minimal requirements for enabling this by default. The default behavior is therefore unchanged.

You can test the functionality using http://web.archive.org/web/20110918100215/http://www.irs.gov/pub/irs-pdf/f1040.pdf (from https://github.com/mozilla/pdf.js/blob/master/test/pdfs/f1040.pdf.link) and setting the preference renderInteractiveForms to true.

@Snuffleupagus Could you review this PR? I talked to Yury on IRC and he agreed that the preference approach is most useful here so we can iterate on this.

Easier reviewing with https://github.com/mozilla/pdf.js/pull/7602/files?w=1.

@timvandermeij
Copy link
Contributor Author

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Sep 6, 2016

From: Bot.io (Linux)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/d24d9fa8f2fa50b/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Sep 6, 2016

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/d24d9fa8f2fa50b/output.txt

Total script time: 1.24 mins

Published

@timvandermeij
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Sep 6, 2016

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/aa077da287ad638/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Sep 6, 2016

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/a2961c905925f49/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Sep 6, 2016

From: Bot.io (Windows)


Failed

Full output at http://107.22.172.223:8877/aa077da287ad638/output.txt

Total script time: 24.18 mins

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

Image differences available at: http://107.22.172.223:8877/aa077da287ad638/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

pdfjsbot commented Sep 6, 2016

From: Bot.io (Linux)


Failed

Full output at http://107.21.233.14:8877/a2961c905925f49/output.txt

Total script time: 38.55 mins

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

Image differences available at: http://107.21.233.14:8877/a2961c905925f49/reftest-analyzer.html#web=eq.log

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Sep 7, 2016

Review status: 0 of 7 files reviewed at latest revision, 3 unresolved discussions.


a discussion (no related file):
First, let me just say that it's really nice that you've started working on support for forms, and even nicer of you to do it in such manageable chunks :-)

Besides the inline comments, pretty please add reference (and if applicable perhaps also unit) tests!
Since you're adding forms support in this incremental manner, it should hopefully not be too difficult to add tests along the way to ensure that we get at least decent test-coverage from the start.

My suggestion is to add a forms flag to the eq type reference tests, that takes the same code-path in test/driver.js as the existing annotations flag. Note that the file f1040.pdf is already present in the test-suite as a load test, so you should be able to use that one.


src/display/annotation_layer.js, line 442 [r1] (raw file):

      this.container.className = 'textWidgetAnnotation';

      var renderInteractiveForms = getDefaultSetting('renderInteractiveForms');

Let's pass in a renderInteractiveForms parameter when creating the annotationLayer in web/annotation_layer_builder.js instead. I.e. for now I think it'd be sufficient to just add a
renderInteractiveForms: PDFJS.renderInteractiveForms, entry to https://github.com/mozilla/pdf.js/blob/master/web/annotation_layer_builder.js#L75 and then access that here instead.

(We can always improve on these things later on, e.g. how the preference is passed along to the annotationLayer, when we get closer to enabling annotations by default.)


src/display/dom_utils.js, line 213 [r1] (raw file):

      return !!(globalSettings && globalSettings.enableStats);
    case 'renderInteractiveForms':
      return globalSettings ? globalSettings.renderInteractiveForms : false;

Please note the comment at the top of this list:

// The list of the settings and their default is maintained for backward
// compatibility and shall not be extended or modified. See also global.js.

Since this is a new setting, it shouldn't be added here. Please see the other comments for another approach.


Comments from Reviewable

@timvandermeij
Copy link
Contributor Author

timvandermeij commented Sep 7, 2016

Thank you for the review! I had planned to implement unit/reference testing in the next PR, but I can see how it will already be useful here and hopefully it should not take too much code to implement, so I'll instead do that for this PR (in a separate commit) as you suggested.

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Sep 7, 2016

Review status: 0 of 7 files reviewed at latest revision, 4 unresolved discussions.


web/annotation_layer_builder.js, line 83 [r2] (raw file):

          linkService: self.linkService,
          downloadManager: self.downloadManager,
          renderInteractiveForms: PDFJS.renderInteractiveForms,

Please use pdfjsLib instead of directly accessing PDFJS here (and remove the global).


Comments from Reviewable

This patch is the first step towards implementing support for
interactive forms (AcroForms). It makes it possible to render text
widget annotations exactly like Adobe Reader/Acrobat.

Everything we implement for AcroForms is disabled by default using a
preference, mainly because it is not ready to use yet, but has to
implemented in many steps to avoid complexity. The preference allows us
to work with the code while not exposing the behavior by default. Mainly
storing entered values and printing them is still absent, which would be
minimal requirements for enabling this by default.
@timvandermeij timvandermeij force-pushed the interactive-forms branch 3 times, most recently from d91ad0a to 18cf425 Compare September 7, 2016 14:37
@timvandermeij
Copy link
Contributor Author

timvandermeij commented Sep 7, 2016

I have addressed the comments. Reference testing has been enabled in a new commit. This can be tested locally by removing all entries from test/test_manifest.json except for the newly added f1040-eq test and running gulp botmakeref. Back-up your current reference images just in case. When this is done, open the reference images in test/ref and notice the blue input fields.

@timvandermeij
Copy link
Contributor Author

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Sep 7, 2016

From: Bot.io (Linux)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/7c391bd84d1e69b/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Sep 7, 2016

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/7c391bd84d1e69b/output.txt

Total script time: 1.26 mins

Published

@timvandermeij
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Sep 7, 2016

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/ef40f52caa1ef3e/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Sep 7, 2016

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/887baf84acdd5f9/output.txt

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Sep 7, 2016

Review status: 0 of 10 files reviewed at latest revision, 6 unresolved discussions.


test/test_manifest.json, line 735 [r4] (raw file):

       "type": "load"
    },
    {  "id": "f1040-eq",

Let's make this f1040-forms instead.


test/test_manifest.json, line 741 [r4] (raw file):

       "rounds": 1,
       "type": "eq",
       "annotations": true,

Would it be possible to implement the forms option in such a way that it's not necessary to also specify annotations, e.g. with if (task.annotations || task.forms) { in

if (task.annotations) {
?


Comments from Reviewable

@pdfjsbot
Copy link

pdfjsbot commented Sep 7, 2016

From: Bot.io (Windows)


Failed

Full output at http://107.22.172.223:8877/887baf84acdd5f9/output.txt

Total script time: 24.29 mins

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

Image differences available at: http://107.22.172.223:8877/887baf84acdd5f9/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

pdfjsbot commented Sep 7, 2016

From: Bot.io (Linux)


Failed

Full output at http://107.21.233.14:8877/ef40f52caa1ef3e/output.txt

Total script time: 39.83 mins

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

Image differences available at: http://107.21.233.14:8877/ef40f52caa1ef3e/reftest-analyzer.html#web=eq.log

@timvandermeij
Copy link
Contributor Author

The review comments have been addressed, so let's re-run the tests to be sure that the changes are fine.

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Sep 7, 2016

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/368cd609575fbfa/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Sep 7, 2016

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/1a7aab5be168de4/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Sep 7, 2016

From: Bot.io (Windows)


Failed

Full output at http://107.22.172.223:8877/1a7aab5be168de4/output.txt

Total script time: 24.46 mins

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

Image differences available at: http://107.22.172.223:8877/1a7aab5be168de4/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

pdfjsbot commented Sep 7, 2016

From: Bot.io (Linux)


Failed

Full output at http://107.21.233.14:8877/368cd609575fbfa/output.txt

Total script time: 39.02 mins

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

Image differences available at: http://107.21.233.14:8877/368cd609575fbfa/reftest-analyzer.html#web=eq.log

@Snuffleupagus
Copy link
Collaborator

Reviewed 5 of 7 files at r1, 1 of 3 files at r2, 1 of 1 files at r3, 2 of 3 files at r4, 2 of 2 files at r5.
Review status: all files reviewed at latest revision, 7 unresolved discussions.


a discussion (no related file):
A nice start on forms support, thanks for doing this and especially for adding test!

/botio makeref


Comments from Reviewable

@pdfjsbot
Copy link

pdfjsbot commented Sep 8, 2016

From: Bot.io (Windows)


Received

Command cmd_makeref from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.22.172.223:8877/dcf12d6ca6c8230/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Sep 8, 2016

From: Bot.io (Linux)


Received

Command cmd_makeref from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.21.233.14:8877/a0a214127b8aa98/output.txt

@Snuffleupagus Snuffleupagus merged commit ca61ccc into mozilla:master Sep 8, 2016
@pdfjsbot
Copy link

pdfjsbot commented Sep 8, 2016

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/dcf12d6ca6c8230/output.txt

Total script time: 24.36 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@pdfjsbot
Copy link

pdfjsbot commented Sep 8, 2016

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/a0a214127b8aa98/output.txt

Total script time: 37.78 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@timvandermeij timvandermeij deleted the interactive-forms branch September 8, 2016 20:46
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.

3 participants