0

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;

このようにフラグを設定しても機能しません。これまでのところ、同様の質問で見つけることができる唯一の解決策です。

御時間ありがとうございます!

4

1 に答える 1