我有问题。我需要在矩形中添加文字:
PdfContentByte canvas = writer.getDirectContent();
canvas.rectangle(30, 20, 180, 90);
canvas.setColorFill(BaseColor.LIGHT_GRAY);
canvas.setColorStroke(BaseColor.DARK_GRAY);
canvas.setLineWidth(2.5);
canvas.fill();
canvas.stroke();
我试过这个:
String text = "Sign-Up";
BaseFont bf = BaseFont.createFont();
canvas.beginText();
canvas.setFontAndSize(bf, 16);
canvas.moveText(30, 30);
canvas.moveTextWithLeading(0, -24);
canvas.showText(text);
canvas.endText();
但它不起作用。