私は自分のPDFフォームにテーブルを持っていますが、PdfpCelleventヘルパーを使ってテキストフィールドを行に挿入しましたが、テキストフィールドに値を入力できます。セルフィールド。制限長PdfPCellEvent
どのようにして、pdfPcellevent内の可視領域の長さを制限することができますか?
static class MyCellField implements PdfPCellEvent{
public String fieldname;
public MyCellField(String fieldname){
this.fieldname= fieldname;
}
@Override
public void cellLayout(PdfPCell cell, Rectangle rectangle, PdfContentByte[] canvases) {
final PdfWriter writer = canvases[0].getPdfWriter();
final TextField textField = new TextField(writer, rectangle, fieldname);
try {
final PdfFormField field = textField.getTextField();
writer.addAnnotation(field);
} catch (final IOException | DocumentException ioe) {
throw new ExceptionConverter(ioe);
}
}
}
private static PdfPCell createPdfCell(String phrase, String eventValue){
PdfPCell pdfCell = new PdfPCell();
pdfCell.addElement(new Phrase(phrase, FontFactory.getFont(FontFactory.TIMES, 11)));
pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
pdfCell.setBorderColor(BaseColor.BLACK);
pdfCell.setPadding(2);
pdfCell.getFixedHeight();
pdfCell.setCellEvent(new MyCellField(eventValue));
pdfCell.setRowspan(3);
return pdfCell;
}
現在何を表示下図:
あなたのコードと期待される動作を教えてください –
'ColumnText'を作成する代わりに' ColumnText.showTextAligned() 'を使用し、カラムサイズを設定し、内容を追加し、' go() 'メソッドを使用しています。私はアレクセイに同意する。あなたがコードを表示しないと、もっと精巧な答えを期待するべきではありません。 –
今はっきりしています。単一行のフィールドがあり、それを複数行のフィールドにしたいとします。それは簡単です。 –