iText PDF 2.1.7을 사용하여 PDF를 작성 중입니다. iText PDF로 단일 문자 (닫는 중괄호, ASCII 125)의 높이를 늘리면 누구나 생각할 수 있습니다.iText PDF 문자 늘이기
연신 중괄호의 높이 위의 높이 셀의 높이에 따라 달라진다. (사면 내 샘플 이미지는 위 중괄호는 낮은 중괄호보다 키가 있어야합니다. 단일 문자의 높이를 스트레칭 할 수없는 경우
는 다른 해결 방법은 당신은 여전히이 iText PDF 라이브러리를 이용하여 제안 할 수 있을까?
감사합니다 많이.
내가 지금이 iText 버전 5.4.0을 사용하고 있습니다.
이미지의 높이를 조절하는 데 문제가 있습니다. 또한 이미지가 잘못된 위치에 있지만 셀 위치가 복사되었습니다. 중괄호의 맨 아래 부분은 표시되지 않습니다.
이미지 크기를 조정하는 방식과 이미지 배치 방식이 잘못되었는지 알고 계십니까? 감사.
public void cellLayout(PdfPCell cell, Rectangle position,
PdfContentByte[] canvases) {
try {
BaseFont bf = BaseFont.createFont(
CreatePDFCurlyBrace.DEFAULT_ENGLISH_FONT_TTF, BaseFont.IDENTITY_H,
BaseFont.EMBEDDED);
String curlyBrace = "}";
float width = bf.getWidthPoint(curlyBrace, 12);
float height = bf.getAscentPoint(curlyBrace, 12)
- bf.getDescentPoint(curlyBrace, 12);
PdfTemplate template = this.cb.createTemplate(width, height);
template.beginText();
template.setFontAndSize(bf, 12);
template.setTextMatrix(0, bf.getDescentPoint(curlyBrace, 12));
template.showText(curlyBrace);
template.endText();
// Scale the image so that its height corresponds
// with the height of the cell
Image img = Image.getInstance(template);
img.scaleToFit(1000f, position.getHeight());
img.setAbsolutePosition(position.getRight(), position.getBottom());
cb.addImage(img);
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
샘플 코드를 제공해 주시겠습니까? 언급 한 cellLayout()에 대해 구현해야하는 인터페이스는 무엇입니까? 감사. –
http://itextpdf.com/book에는 많은 샘플 코드가 있습니다. http://itextpdf.com/themes/keyword.php?id=201 및 http://itextpdf.com/themes/keyword.php가 필요합니까? id = 149 –
브루노, 당신의 충고를 따랐습니다.하지만 ** 이미지 ** 크기 조정에 문제가있었습니다. 친절하게도 코드가 포함 된 내 게시물을 확인하십시오. 감사. –