mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 17:55:37 +02:00
[api-minor] Introduce a new annotationMode
-option, in PDFPageProxy.{render, getOperatorList}
*This is a follow-up to PRs 13867 and 13899.* This patch is tagged `api-minor` for the following reasons: - It replaces the `renderInteractiveForms`/`includeAnnotationStorage`-options, in the `PDFPageProxy.render`-method, with the single `annotationMode`-option that controls which annotations are being rendered and how. Note that the old options were mutually exclusive, and setting both to `true` would result in undefined behaviour. - For improved consistency in the API, the `annotationMode`-option will also work together with the `PDFPageProxy.getOperatorList`-method. - It's now also possible to disable *all* annotation rendering in both the API and the Viewer, since the other changes meant that this could now be supported with a single added line on the worker-thread[1]; fixes 7282. --- [1] Please note that in order to simplify the overall implementation, we'll purposely only support disabling of *all* annotations and that the option is being shared between the API and the Viewer. For any more "specialized" use-cases, where e.g. only some annotation-types are being rendered and/or the API and Viewer render different sets of annotations, that'll have to be handled in third-party implementations/forks of the PDF.js code-base.
This commit is contained in:
parent
56e7bb626c
commit
41efa3c071
16 changed files with 272 additions and 134 deletions
|
@ -46,7 +46,7 @@ const DEFAULT_TAB_INDEX = 1000;
|
|||
* @property {AnnotationStorage} [annotationStorage]
|
||||
* @property {string} [imageResourcesPath] - Path for image resources, mainly
|
||||
* for annotation icons. Include trailing slash.
|
||||
* @property {boolean} renderInteractiveForms
|
||||
* @property {boolean} renderForms
|
||||
* @property {Object} svgFactory
|
||||
* @property {boolean} [enableScripting]
|
||||
* @property {boolean} [hasJSActions]
|
||||
|
@ -154,7 +154,7 @@ class AnnotationElement {
|
|||
this.linkService = parameters.linkService;
|
||||
this.downloadManager = parameters.downloadManager;
|
||||
this.imageResourcesPath = parameters.imageResourcesPath;
|
||||
this.renderInteractiveForms = parameters.renderInteractiveForms;
|
||||
this.renderForms = parameters.renderForms;
|
||||
this.svgFactory = parameters.svgFactory;
|
||||
this.annotationStorage = parameters.annotationStorage;
|
||||
this.enableScripting = parameters.enableScripting;
|
||||
|
@ -676,7 +676,7 @@ class WidgetAnnotationElement extends AnnotationElement {
|
|||
class TextWidgetAnnotationElement extends WidgetAnnotationElement {
|
||||
constructor(parameters) {
|
||||
const isRenderable =
|
||||
parameters.renderInteractiveForms ||
|
||||
parameters.renderForms ||
|
||||
(!parameters.data.hasAppearance && !!parameters.data.fieldValue);
|
||||
super(parameters, { isRenderable });
|
||||
}
|
||||
|
@ -700,7 +700,7 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||
this.container.className = "textWidgetAnnotation";
|
||||
|
||||
let element = null;
|
||||
if (this.renderInteractiveForms) {
|
||||
if (this.renderForms) {
|
||||
// NOTE: We cannot set the values using `element.value` below, since it
|
||||
// prevents the AnnotationLayer rasterizer in `test/driver.js`
|
||||
// from parsing the elements correctly for the reference tests.
|
||||
|
@ -952,7 +952,7 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||
|
||||
class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
|
||||
constructor(parameters) {
|
||||
super(parameters, { isRenderable: parameters.renderInteractiveForms });
|
||||
super(parameters, { isRenderable: parameters.renderForms });
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -1031,7 +1031,7 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||
|
||||
class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
|
||||
constructor(parameters) {
|
||||
super(parameters, { isRenderable: parameters.renderInteractiveForms });
|
||||
super(parameters, { isRenderable: parameters.renderForms });
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -1123,7 +1123,7 @@ class PushButtonWidgetAnnotationElement extends LinkAnnotationElement {
|
|||
|
||||
class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
|
||||
constructor(parameters) {
|
||||
super(parameters, { isRenderable: parameters.renderInteractiveForms });
|
||||
super(parameters, { isRenderable: parameters.renderForms });
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -2033,7 +2033,7 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
|
|||
* @property {DownloadManager} downloadManager
|
||||
* @property {string} [imageResourcesPath] - Path for image resources, mainly
|
||||
* for annotation icons. Include trailing slash.
|
||||
* @property {boolean} renderInteractiveForms
|
||||
* @property {boolean} renderForms
|
||||
* @property {boolean} [enableScripting] - Enable embedded script execution.
|
||||
* @property {boolean} [hasJSActions] - Some fields have JS actions.
|
||||
* The default value is `false`.
|
||||
|
@ -2076,7 +2076,7 @@ class AnnotationLayer {
|
|||
linkService: parameters.linkService,
|
||||
downloadManager: parameters.downloadManager,
|
||||
imageResourcesPath: parameters.imageResourcesPath || "",
|
||||
renderInteractiveForms: parameters.renderInteractiveForms !== false,
|
||||
renderForms: parameters.renderForms !== false,
|
||||
svgFactory: new DOMSVGFactory(),
|
||||
annotationStorage:
|
||||
parameters.annotationStorage || new AnnotationStorage(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue