我正在我的 pdf 的另一页上创建现有 TextField 的副本,并且我希望重复字段是只读的,以便用户只能更改原始字段的值。这是我创建副本的部分:
PdfPCell totalPriceCell = new PdfPCell()
{
BorderWidthLeft = 0,
BorderWidthRight = 0,
BorderWidthTop = 0,
BorderWidthBottom = 0f
};
BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, false);
TextField tFieldTotalPrice = new TextField(writer, new iTextSharp.text.Rectangle(0, 0), dupTotalPriceName)
{
FieldName = dupTotalPriceName,
Alignment = 1,
FontSize = 12,
Font = bf
};
tFieldTotalPrice.SetRotationFromPage(doc.PageSize);
FieldPositioningEvents eventsTotalPrice = new FieldPositioningEvents(writer, tFieldTotalPrice.GetTextField());
PdfFormField fieldTotalPrice = tFieldTotalPrice.GetTextField();
fieldTotalPrice.SetFieldFlags(PdfFormField.FF_READ_ONLY);
fieldTotalPrice.SetFieldFlags(PdfFormField.FLAGS_READONLY);
//Divide row number by 2 and keep remainder. If remainder is 0, even. Else, odd.
totalPriceCell.BackgroundColor = r % 2 == 0 ? BaseColor.WHITE : new BaseColor(245, 245, 245);
totalPriceCell.CellEvent = eventsTotalPrice;
以这种方式设置标志不起作用,这是迄今为止我在类似问题上能找到的唯一解决方案。
谢谢你的时间!