List of usage examples for com.lowagie.text Rectangle setBackgroundColor
public void setBackgroundColor(Color backgroundColor)
From source file:questions.images.MakingImageTransparent.java
public static void main(String args[]) { try {/*from w w w . j a va 2s .c o m*/ Rectangle rect; // GIF Image Image gif = Image.getInstance(GIF); gif.setAbsolutePosition(0, 0); gif.setTransparency(new int[] { 0x5B, 0x5D }); rect = new Rectangle(gif.getScaledWidth(), gif.getScaledHeight()); rect.setBackgroundColor(Color.YELLOW); Document document = new Document(rect); PdfWriter.getInstance(document, new FileOutputStream(RESULT)); document.open(); document.add(gif); // JPEG Image java.awt.Image awtImage = Toolkit.getDefaultToolkit().createImage(JPG); Image jpg = Image.getInstance(awtImage, null, true); jpg.setTransparency(new int[] { 0xF0, 0xFF }); jpg.setAbsolutePosition(0, 0); rect = new Rectangle(jpg.getScaledWidth(), jpg.getScaledHeight()); rect.setBackgroundColor(Color.YELLOW); document.setPageSize(rect); document.newPage(); document.add(jpg); document.close(); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:questions.images.TransparentPng.java
public static final void main(String[] args) throws IOException, DocumentException { Image img = Image.getInstance(IMAGE); Rectangle rectangle = new Rectangle(img); rectangle.setBackgroundColor(Color.YELLOW); Document document = new Document(rectangle); PdfWriter.getInstance(document, new FileOutputStream(RESULT)); document.open();/* www.ja v a 2 s. c o m*/ img.setAbsolutePosition(0, 0); document.add(img); document.close(); }
From source file:questions.ocg.StatusBars1.java
public Image getImage(PdfContentByte cb, int i) throws BadElementException { PdfTemplate tmp = cb.createTemplate(100, 10); tmp.setBoundingBox(new Rectangle(-5, -2, 105, 12)); Rectangle r = new Rectangle(0, 0, 100, 10); tmp.rectangle(r);/*from w w w.ja va 2 s. co m*/ r = new Rectangle(0, 0, i, 10); tmp.beginLayer(colorLayerColored); if (i % 2 == 0) r.setBackgroundColor(Color.RED); else r.setBackgroundColor(Color.GREEN); tmp.rectangle(r); tmp.endLayer(); tmp.beginLayer(colorLayerGreyed); r = new Rectangle(0, 0, i, 10); if (i % 2 == 0) r.setBackgroundColor(new GrayColor(10)); else r.setBackgroundColor(new GrayColor(97)); tmp.rectangle(r); tmp.endLayer(); return Image.getInstance(tmp); }
From source file:questions.tables.AddTableAsHeaderFooter.java
public void onOpenDocument(PdfWriter writer, Document document) { try {/*from w ww . ja va 2 s. co m*/ // initializations tpl = writer.getDirectContent().createTemplate(150, 18); Rectangle rect = new Rectangle(0, 0, 150, 18); rect.setBackgroundColor(Color.GRAY); tpl.setBoundingBox(rect); tpl.rectangle(rect); helv = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false); // header headerTable = new PdfPTable(1); PdfPCell cell = new PdfPCell(new Paragraph("Header Text")); headerTable.addCell(cell); headerTable.setTotalWidth(document.right() - document.left()); headerTable.setLockedWidth(true); } catch (Exception e) { throw new ExceptionConverter(e); } }
From source file:questions.tables.AlternateBackground.java
public void tableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases) {/* w ww . ja v a2 s .c om*/ int rows = widths.length; int columns; Rectangle rect; for (int row = headerRows + 1; row < rows; row += 2) { columns = widths[row].length - 1; rect = new Rectangle(widths[row][0], heights[row], widths[row][columns], heights[row + 1]); rect.setBackgroundColor(Color.YELLOW); rect.setBorder(Rectangle.NO_BORDER); canvases[PdfPTable.BACKGROUNDCANVAS].rectangle(rect); } }