Jspdf: textfield does not working as expected in PDF

Created on 4 Jun 2018  路  7Comments  路  Source: MrRio/jsPDF

Im trying to change the TextField value direct in PDF file, when change it and click out the value change back to the old one.

im using this code from acroformstandard.spec.js

var doc = jsPDF()
doc.text(10, 145, 'TextField:')
var textField = new TextField()
textField.Rect = [50, 140, 30, 10]
textField.multiline = true
textField.V = 'The quick brown fox ate the lazy mouse The quick brown fox ate the lazy mouse The quick brown fox ate the lazy mouse'//
textField.T = 'TestTextBox'
// textField.Q = 2; // Text-Alignment
doc.addField(textField)

step to reproduce:

  1. Create pdf with Textfield
  2. Download the PDF
  3. change the Textfield value
  4. Click out of the TextField (any where in the PDF)
  5. the old value appear again

bug

thanks

Most helpful comment

Ok found the error it. It is an error with the Appearance Stream. Have to code a solution

All 7 comments

I think you have to use DV for default value
and not V

Thank you, i changed it to textField.DV = "" but this did not work.

Ok found the error it. It is an error with the Appearance Stream. Have to code a solution

i'm experiencing a similar (but not equal) issue with the HEAD of master (0237c01bc08fc84351b89e7d6a81e86f8fe658c8):
jspdf

@shadirok If you want a temporary fix, I just set the textField.DA = null; before adding it to the document. That seemed to work for me in the meantime, at least.

I used the DA = null solution by @DrSharky and set DA for alle elements to null. Seems that it got fixed.

how I show Textfiled value in the center? any one know

Was this page helpful?
0 / 5 - 0 ratings