- Common ways to obtain PdfContentByte
private void myMethod () {PdfContentByte p =
PdfWriter writer;writer.getDirectContent()
PdfStamper pdfStamper;pdfStamper.getOverContent(pageNum)
PdfStamper pdfStamper;pdfStamper.getUnderContent(pageNum)
- Smart code suggestions by Codota
}
cb.setFontAndSize(bf, font.getSize()); cb.showTextAligned(PdfContentByte.ALIGN_CENTER, label, x, -y - (textHeight / 2f), 0f); cb.endText(); cb.setFontAndSize(bf, font.getSize()); cb.showTextAligned(PdfContentByte.ALIGN_CENTER, label, x, -y - (textHeight / 2f), 0f); cb.endText();
cb.setFontAndSize(bf, font.getSize()); cb.showTextAligned(PdfContentByte.ALIGN_CENTER, label, x, -y - (textHeight / 2f), 0f); cb.endText(); cb.setFontAndSize(bf, font.getSize()); cb.showTextAligned(PdfContentByte.ALIGN_CENTER, label, x, -y - (textHeight / 2f), 0f); cb.endText();
text.setFontAndSize(currentFont.getFont(), currentFont.size());
text.setFontAndSize(currentFont.getFont(), currentFont.size());
cb.setColorFill(textColor); cb.beginText(); cb.setFontAndSize(font, size); cb.setTextMatrix(textStartX, textStartY); cb.showText(fullCode);
@Override public void onEndPage(PdfWriter writer, Document document) { // 在每页结束的时候把“第x页”信息写道模版指定位置 PdfContentByte byteContent = writer.getDirectContent(); String text = "第" + writer.getPageNumber() + "页"; float textWidth = this.baseFont.getWidthPoint(text, 8); float realWidth = document.right() - textWidth; // byteContent.beginText(); byteContent.setFontAndSize(this.baseFont, 10); byteContent.setTextMatrix(realWidth, document.bottom()); byteContent.showText(text); byteContent.endText(); byteContent.addTemplate(this.template, realWidth, document.bottom()); } }
cb.beginText(); cb.setFontAndSize(bf, 15); writeText(cb, "ЧИТАЧ ЕЛЕКТРОНСКЕ ЛИЧНЕ КАРТЕ: ШТАМПА ПОДАТАКА", 62, 760); cb.setFontAndSize(bf, 11); writeLabel(cb, "Подаци о грађанину", 537); writeLabel(cb, "Подаци о документу", 288); cb.setFontAndSize(bf, 10); writeLine(cb, "Презиме:", info.getSurname(), 513); writeLine(cb, "Име:", info.getGivenName(), 489);
FontDescription desc = _font.getFontDescription(); float fontSize = _font.getSize2D() / _dotsPerPoint; cb.setFontAndSize(desc.getFont(), fontSize); float b = (float) mx[1]; float c = (float) mx[2];
cb.setColorFill(textColor); cb.beginText(); cb.setFontAndSize(font, size); cb.setTextMatrix(textStartX, textStartY); cb.showText(fullCode);
cb.setColorFill(textColor); cb.beginText(); cb.setFontAndSize(font, size); cb.setTextMatrix(textStartX, textStartY); cb.showText(fullCode);
content.beginText(); content.setColorFill(BaseColor.LIGHT_GRAY); content.setFontAndSize(base, 50);// 设置字体的大小 content.setTextMatrix(70, 200); content.showTextAligned(Element.ALIGN_CENTER, waterMarkName, 100,
cb.setColorFill(textColor); cb.beginText(); cb.setFontAndSize(font, size); cb.setTextMatrix(textStartX, textStartY); cb.showText(fullCode);
cb.setColorFill(textColor); cb.beginText(); cb.setFontAndSize(font, size); cb.setTextMatrix(textStartX, textStartY); cb.showText(fullCode);
cb.setColorFill(textColor); cb.beginText(); cb.setFontAndSize(font, size); cb.setTextMatrix(textStartX, textStartY); cb.showText(fullCode);
cb.setColorFill(textColor); cb.beginText(); cb.setFontAndSize(font, size); cb.setTextMatrix(textStartX, textStartY); cb.showText(fullCode);
cb.setColorFill(textColor); cb.beginText(); cb.setFontAndSize(bf, fontSize); cb.setTextMatrix(tx, ty); cb.showText(text);
cb.setColorFill(textColor); cb.beginText(); cb.setFontAndSize(bf, fontSize); cb.setTextMatrix(tx, ty); cb.showText(text);
float textBase = document.bottom() - 20; cb.beginText(); cb.setFontAndSize(helv, 12); float adjust = helv.getWidthPoint("0", 12); cb.setTextMatrix(document.right() - textSize - adjust, textBase);
setFontAndSize(bf, size); showTextAligned(PdfContentByte.ALIGN_CENTER, text, (float)(llx + (urx - llx) / 2), (float)(lly + (ury - lly - size) / 2), 0); endText();
setFontAndSize(bf, size); showTextAligned(PdfContentByte.ALIGN_CENTER, text, (float)(llx + (urx - llx) / 2), (float)(lly + (ury - lly - size) / 2), 0); endText();