I am using the following:
Stream os = new FileStream(PDFPath, FileMode.CreateNew); PdfReader reader = new PdfReader(memIO); PdfStamper stamper = new PdfStamper(reader, os, '9', true); AcroFields fields = stamper.AcroFields; fields.SetField("Pgo", 1.0 "Percentage");
1.0 will not be changed into
I assume that this is a typo:
fields.SetField("Pgo", 1.0 "Percentage");
This line doesn't even compile in iText 5. Your IDE should show an error when typing this line. Even if I would add the missing comma between the second and third parameter (assuming that
"Percentage" are two separate parameters), you'd get an error saying that there is no
setField() method that accepts a
double and a
In iText 7 we use
setValue() method for this purpose
There are four
setValue(String value, boolean generateAppearance): the first parameter is the value and the second is the flag if you want to keep the appearance of the field generated before
setValue(String value, String display): the first parameter is the value (e.g. the
"1.0"), and the second parameter is what should be displayed (e.g.
setValue(String value, PdfFont font, int fontSize): the first parameter is the value, the second is the
PdfFont, which should be used in the field, and the third is the size of font which should be used.
For instance, when you do this:
iText will display 100%, but the value of the field will be 1.0.
See also How to format a field as a currency?
Click this link if you want to see how to answer this question in iText 5.