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

Export the XFA/StructTree-layers in the viewer components #13942

Merged

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus Snuffleupagus commented Aug 28, 2021

While e.g. the simpleviewer and singlepageviewer examples work, since they're based on the BaseViewer-class, the standalone pageviewer example currently doesn't support either XFA- or StructTree-layers. This seems like an obvious oversight, which can be easily addressed simply by exporting the necessary functionality through pdf_viewer.component.js, similar to the existing Text/Annotation-layers.

While working on, and testing, these changes I happened to notice a number of smaller things that's also fixed in this patch:

  • Ensure that XfaLayerBuilder.render always have a consistent return type, to prevent possible run-time failures in PDFPageView; PR [api-minor] XFA - Support text search in XFA documents. #13908 follow-up.

  • Change the order of the options in the XfaLayerBuilder-constructor to agree with the parameter order in the DefaultXfaLayerFactory.createXfaLayerBuilder-method.

  • Add a missing textHighlighterFactory-option, in the JSDocs for the PDFPageView-class.

  • A couple of small tweaks in the TextLayerBuilder.render-method: Re-use an existing Array rather than creating a new one, and replace an if with optional chaining instead.

Please note: For now XFA-support is currently disabled by default, similar to the regular viewer.

While e.g. the `simpleviewer` and `singlepageviewer` examples work, since they're based on the `BaseViewer`-class, the standalone `pageviewer` example currently doesn't support either XFA- or StructTree-layers. This seems like an obvious oversight, which can be easily addressed simply by exporting the necessary functionality through `pdf_viewer.component.js`, similar to the existing Text/Annotation-layers.

While working on, and testing, these changes I happened to notice a number of smaller things that's also fixed in this patch:

 - Ensure that `XfaLayerBuilder.render` always have a *consistent* return type, to prevent possible run-time failures in `PDFPageView`; PR 13908 follow-up.

 - Change the order of the options in the `XfaLayerBuilder`-constructor to agree with the parameter order in the `DefaultXfaLayerFactory.createXfaLayerBuilder`-method.

 - Add a missing `textHighlighterFactory`-option, in the JSDocs for the `PDFPageView`-class.

 - A couple of small tweaks in the `TextLayerBuilder.render`-method: Re-use an existing Array rather than creating a new one, and replace an `if` with optional chaining instead.

*Please note:* For now XFA-support is currently disabled by default, similar to the regular viewer.
@Snuffleupagus Snuffleupagus force-pushed the viewer-components-export-layers branch from b493412 to c6d400e Compare August 28, 2021 16:43
@Snuffleupagus
Copy link
Collaborator Author

/botio integrationtest

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://3.101.106.178:8877/99f9664b60f1e7c/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/4d8da4438723f6c/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/4d8da4438723f6c/output.txt

Total script time: 4.50 mins

  • Integration Tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://3.101.106.178:8877/99f9664b60f1e7c/output.txt

Total script time: 5.47 mins

  • Integration Tests: Passed

@timvandermeij timvandermeij merged commit a270bae into mozilla:master Aug 29, 2021
@timvandermeij
Copy link
Contributor

Thank you for improving this!

@Snuffleupagus Snuffleupagus deleted the viewer-components-export-layers branch August 29, 2021 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants