PdfName.NM in iText TextField not Visible after calling setName() -


this how create textfield in itext 5.

import com.itextpdf.text.pdf.textfield;  textfield tf = new textfield(stamper.getwriter(), rect, "fieldname"); tf.settext("fieldvalue"); tf.setbackgroundcolor(basecolor.white); tf.setbordercolor(basecolor.black); tf.gettextfield().setname("name_here"); stamper.addannotation(tf.gettextfield(), 1); 

this works. however, when check in rups. pdfname.nm not exist. setname() correct method, right?

you assuming methods can chained in itext 5, assumption wrong. introduced chained methods in itext 7.

in itext 5, need split things up:

pdfformfield ff = tf.gettextfield(); ff.setname("name_here"); stamper.addannotation(ff, 1); 

the pdfformfield isn't member-variable of textfield class, , gettextfield() isn't real getter. when trigger gettextfield(), new pdfformfield instance created (itext open source, check if you're not sure).

itext 5 grew organically. don't have degree in computer sciences; self-taught in programming. if @ evolution of itext, can see how programming skills improved. if want clean version of itext, please use itext 7.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -