acroform 文本字段未右对齐

acroform text field not align to right

我有this acro form

我正在尝试使用此代码将字段右对齐:

acroForm.getField("NewRentWithoutChargesChf").setValue("1.00");
((PDTextField) acroForm.getField("NewRentWithoutChargesChf")).setQ(PDVariableText.QUADDING_RIGHT); //align right not works

我希望字段右对齐但它没有(仍然左对齐)。

已经检查过这个真实的 SO

PDFBox(以及许多其他 PDF 库)仅在设置 字段值 时生成外观(如果有的话);他们不会在每次其他 字段 属性 更改时一次又一次地更新外观。

因此,您应该首先设置平方值,然后然后更改字段值,即

((PDTextField) acroForm.getField("NewRentWithoutChargesChf")).setQ(PDVariableText.QUADDING_RIGHT); //align right works
acroForm.getField("NewRentWithoutChargesChf").setValue("1.00");