- 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
}
private void ensureFillColor() { if (!(_color.equals(_fillColor))) { _fillColor = _color; _currentPage.setColorFill(_fillColor); } }
public void placeBarcode(PdfContentByte cb, BaseColor foreground, float moduleHeight, float moduleWidth) { int w = width + 2 * ws; int h = height + 2 * ws; int stride = (w + 7) / 8; int ptr = 0; cb.setColorFill(foreground); for (int k = 0; k < h; ++k) { int p = k * stride; for (int j = 0; j < w; ++j) { int b = image[p + j / 8] & 0xff; b <<= j % 8; if ((b & 0x80) != 0) { cb.rectangle(j * moduleWidth, (h - k - 1) * moduleHeight, moduleWidth, moduleHeight); } } } cb.fill(); }
public void placeBarcode(PdfContentByte cb, BaseColor foreground, float moduleHeight, float moduleWidth) { int w = width + 2 * ws; int h = height + 2 * ws; int stride = (w + 7) / 8; int ptr = 0; cb.setColorFill(foreground); for (int k = 0; k < h; ++k) { int p = k * stride; for (int j = 0; j < w; ++j) { int b = image[p + j / 8] & 0xff; b <<= j % 8; if ((b & 0x80) != 0) { cb.rectangle(j * moduleWidth, (h - k - 1) * moduleHeight, moduleWidth, moduleHeight); } } } cb.fill(); }
public void placeBarcode(PdfContentByte cb, BaseColor foreground, float moduleHeight, float moduleWidth) { paintCode(); int stride = (bitColumns + 7) / 8; cb.setColorFill(foreground); for (int k = 0; k < codeRows; ++k) { int p = k * stride; for (int j = 0; j < bitColumns; ++j) { int b = outBits[p + j / 8] & 0xff; b <<= j % 8; if ((b & 0x80) != 0) { cb.rectangle(j * moduleWidth, (codeRows - k - 1) * moduleHeight, moduleWidth, moduleHeight); } } } cb.fill(); }
public void placeBarcode(PdfContentByte cb, BaseColor foreground, float moduleHeight, float moduleWidth) { paintCode(); int stride = (bitColumns + 7) / 8; cb.setColorFill(foreground); for (int k = 0; k < codeRows; ++k) { int p = k * stride; for (int j = 0; j < bitColumns; ++j) { int b = outBits[p + j / 8] & 0xff; b <<= j % 8; if ((b & 0x80) != 0) { cb.rectangle(j * moduleWidth, (codeRows - k - 1) * moduleHeight, moduleWidth, moduleHeight); } } } cb.fill(); }
public void tableLayout(PdfPTable table, float[][] width, float[] height, int headerRows, int rowStart, PdfContentByte[] canvas) { // because table is only one cell length, one can focus on using the first width float xmin = width[0][0]; float xmax = width[0][1]; float ymin = height[height.length - 1]; float ymax = height[0]; float d = 3; PdfContentByte background = canvas[PdfPTable.BASECANVAS]; background.saveState(); background.setColorFill(backgroundColor); background.roundRectangle( xmin - d, ymin - d, (xmax + d) - (xmin - d), (ymax + d) - (ymin - d), d + d); background.fill(); background.restoreState(); }
public void placeBarcode(PdfContentByte cb, BaseColor foreground, float moduleSide) { int width = bm.getWidth(); int height = bm.getHeight(); byte[][] mt = bm.getArray(); cb.setColorFill(foreground); for (int y = 0; y < height; ++y) { byte[] line = mt[y]; for (int x = 0; x < width; ++x) { if (line[x] == 0) { cb.rectangle(x * moduleSide, (height - y - 1) * moduleSide, moduleSide, moduleSide); } } } cb.fill(); }
@Override public void cellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvas) { BaseColor color = colorProviders.apply(percent); if (color != null) { PdfContentByte cb = canvas[PdfPTable.BACKGROUNDCANVAS]; cb.saveState(); cb.setColorFill(color); cb.rectangle( rect.getLeft() + margin.marginLeft, rect.getBottom() + margin.marginBottom, rect.getWidth() * percent - (margin.marginLeft + margin.marginRight), rect.getHeight() - (margin.marginTop + margin.marginBottom)); cb.fill(); cb.restoreState(); } } }
cb.setColorFill(barColor); byte bars[] = getBarsPostnet(code); byte flip = 1;
text.setColorFill(color);
setColorFill(spot.getPdfSpotColor(), spot.getTint()); break; setColorFill(devicen.getPdfDeviceNColor(), devicen.getTints()); break; setColorFill(lab.getLabColorSpace(), lab.getL(), lab.getA(), lab.getB()); break;
setColorFill(spot.getPdfSpotColor(), spot.getTint()); break; setColorFill(devicen.getPdfDeviceNColor(), devicen.getTints()); break; setColorFill(lab.getLabColorSpace(), lab.getL(), lab.getA(), lab.getB()); break;
if (state.getBackgroundMode() == MetaState.OPAQUE) { textColor = state.getCurrentBackgroundColor(); cb.setColorFill(textColor); cb.rectangle(tx, ty + descender, textWidth, ury - descender); cb.fill(); cb.setColorFill(textColor); cb.beginText(); cb.setFontAndSize(bf, fontSize);
content.setColorFill(BaseColor.LIGHT_GRAY); content.setFontAndSize(base, 50);// 设置字体的大小 content.setTextMatrix(70, 200);
backgr.setColorFill(background); backgr.rectangle(left, bottom, right - left, top - bottom); backgr.fill();
backgr.setColorFill(background); backgr.rectangle(left, bottom, right - left, top - bottom); backgr.fill();
setColorFill(new BaseColor(0x00, 0x00, 0x00)); arc(llx + 4f, lly + 4f, urx - 4f, ury - 4f, 0, 360); fill();
setColorFill(new BaseColor(0x00, 0x00, 0x00)); arc(llx + 4f, lly + 4f, urx - 4f, ury - 4f, 0, 360); fill();
setColorFill(new BaseColor(0xC0, 0xC0, 0xC0)); rectangle(llx + 0.5f, lly + 0.5f, urx - llx - 1f, ury - lly - 1f); fill();
setColorFill(new BaseColor(0xFF, 0xFF, 0xFF)); rectangle(llx + 0.5f, lly + 0.5f, urx - llx - 1f, ury -lly - 1f); fill();