나는 내 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'를 만들고, 열 크기를 설정하고, 내용을 추가하고'go()'메서드를 사용하는 대신'ColumnText.showTextAligned()'를 사용하고있을 것입니다. 나는 Alexey와 동의한다. 코드를 보여주지 않으면 더 정교한 답을 기대해서는 안됩니다. –
이제는 분명합니다. 단일 행 필드가 있고 다중 행 필드가되기를 원합니다. 쉽습니다. –