/** * @see com.lowagie.text.pdf.PdfContentByte#setColorFill(com.lowagie.text.pdf.PdfSpotColor, float) */ public void setColorFill(PdfSpotColor sp, float tint) { checkNoColor(); super.setColorFill(sp, tint); }
/** * @see com.lowagie.text.pdf.PdfContentByte#setColorFill(java.awt.Color) */ public void setColorFill(Color color) { checkNoColor(); super.setColorFill(color); }
/** * @see com.lowagie.text.pdf.PdfContentByte#setColorFill(java.awt.Color) */ public void setColorFill(Color color) { checkNoColor(); super.setColorFill(color); }
/** * @see com.lowagie.text.pdf.PdfContentByte#setColorFill(com.lowagie.text.pdf.PdfSpotColor, float) */ public void setColorFill(PdfSpotColor sp, float tint) { checkNoColor(); super.setColorFill(sp, tint); }
/** * @see com.lowagie.text.pdf.PdfContentByte#setColorFill(com.google.code.appengine.awt.Color) */ public void setColorFill(Color color) { checkNoColor(); super.setColorFill(color); }
/** * @see com.lowagie.text.pdf.PdfContentByte#setColorFill(com.lowagie.text.pdf.PdfSpotColor, float) */ public void setColorFill(PdfSpotColor sp, float tint) { checkNoColor(); super.setColorFill(sp, tint); }
private void setFill(Color color) { // Color and transparency PdfGState state = new PdfGState(); state.setFillOpacity(color.getAlpha() / 255f); state.setBlendMode(PdfGState.BM_NORMAL); template.setGState(state); template.setColorFill(color); }
/** * Draw text in the center of the specified box. * * @param text text * @param font font * @param box box to put text int * @param fontColor colour */ public void drawText(String text, Font font, Rectangle box, Color fontColor) { template.saveState(); // get the font DefaultFontMapper mapper = new DefaultFontMapper(); BaseFont bf = mapper.awtToPdf(font); template.setFontAndSize(bf, font.getSize()); // calculate descent float descent = 0; if (text != null) { descent = bf.getDescentPoint(text, font.getSize()); } // calculate the fitting size Rectangle fit = getTextSize(text, font); // draw text if necessary template.setColorFill(fontColor); template.beginText(); template.showTextAligned(PdfContentByte.ALIGN_LEFT, text, origX + box.getLeft() + 0.5f * (box.getWidth() - fit.getWidth()), origY + box.getBottom() + 0.5f * (box.getHeight() - fit.getHeight()) - descent, 0); template.endText(); template.restoreState(); }