mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Text widget annotations: do not render on canvas as well
If interactive forms are enabled, then the display layer takes care of rendering the form elements. There is no need to draw them on the canvas as well. This also leads to issues when values are prefilled, because the text fields are transparent, so the contents that have been rendered onto the canvas will be visible too. We address this issue by passing the `renderInteractiveForms` parameter to the render task and handling it when the page is rendered (i.e., when the canvas is rendered).
This commit is contained in:
parent
adf0972ca5
commit
dbea302a6e
5 changed files with 30 additions and 7 deletions
|
@ -68,10 +68,12 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
|
|||
* @param {Object} ref
|
||||
* @param {string} uniquePrefix
|
||||
* @param {Object} idCounters
|
||||
* @param {boolean} renderInteractiveForms
|
||||
* @returns {Annotation}
|
||||
*/
|
||||
create: function AnnotationFactory_create(xref, ref,
|
||||
uniquePrefix, idCounters) {
|
||||
uniquePrefix, idCounters,
|
||||
renderInteractiveForms) {
|
||||
var dict = xref.fetchIfRef(ref);
|
||||
if (!isDict(dict)) {
|
||||
return;
|
||||
|
@ -90,6 +92,7 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
|
|||
ref: isRef(ref) ? ref : null,
|
||||
subtype: subtype,
|
||||
id: id,
|
||||
renderInteractiveForms: renderInteractiveForms,
|
||||
};
|
||||
|
||||
switch (subtype) {
|
||||
|
@ -693,6 +696,8 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
|
|||
function TextWidgetAnnotation(params) {
|
||||
WidgetAnnotation.call(this, params);
|
||||
|
||||
this.renderInteractiveForms = params.renderInteractiveForms;
|
||||
|
||||
// Determine the alignment of text in the field.
|
||||
var alignment = Util.getInheritableProperty(params.dict, 'Q');
|
||||
if (!isInt(alignment) || alignment < 0 || alignment > 2) {
|
||||
|
@ -715,12 +720,18 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
|
|||
Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
|
||||
getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator,
|
||||
task) {
|
||||
var operatorList = new OperatorList();
|
||||
|
||||
// Do not render form elements on the canvas when interactive forms are
|
||||
// enabled. The display layer is responsible for rendering them instead.
|
||||
if (this.renderInteractiveForms) {
|
||||
return Promise.resolve(operatorList);
|
||||
}
|
||||
|
||||
if (this.appearance) {
|
||||
return Annotation.prototype.getOperatorList.call(this, evaluator, task);
|
||||
}
|
||||
|
||||
var operatorList = new OperatorList();
|
||||
|
||||
// Even if there is an appearance stream, ignore it. This is the
|
||||
// behaviour used by Adobe Reader.
|
||||
if (!this.data.defaultAppearance) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue