AcroFields does not display decimal numbers

PdfReader reader = new PdfReader(“MyOrderTemplate.pdf”);
PdfStamper stamper = new PdfStamper(reader, getServletResponse().getOutputStream());
AcroFields form = stamper.getAcroFields();
form.setField(“customer_id”, (order.getTotal() != null) ? order.getTotal().toString() : “”, (order.getTotal() != null) ? order.getTotal().toString() : “”);
With form.setField(“customer_id”, (order.getTotal() != null) ? order.getTotal().toString() : “”); my output PDF was only displaying the integer part of my decimale, not matter was this attribute type was (BigDecimal, double, String…), even if the template field was expecting 5 digits before and 2 digits after the decimal point
The solution was to use an overloaded version of setField() function, with two parameters: the first one was the value to be stored, and the second one the value to be displayed.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: