Java Code Examples for com.lowagie.text.pdf.PdfContentByte#resetRGBColorStroke()
The following examples show how to use
com.lowagie.text.pdf.PdfContentByte#resetRGBColorStroke() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FloatingBoxesTest.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
/** * @see com.lowagie.text.pdf.PdfPTableEvent#tableLayout(com.lowagie.text.pdf.PdfPTable, * float[][], float[], int, int, com.lowagie.text.pdf.PdfContentByte[]) */ public void tableLayout(PdfPTable table, float[][] width, float[] height, int headerRows, int rowStart, PdfContentByte[] canvases) { float widths[] = width[0]; float x1 = widths[0]; float x2 = widths[widths.length - 1]; float y1 = height[0]; float y2 = height[height.length - 1]; PdfContentByte canvas = canvases[PdfPTable.LINECANVAS]; canvas.setRGBColorStroke(0x00, 0x00, 0xFF); canvas.rectangle(x1, y1, x2 - x1, y2 - y1); canvas.stroke(); canvas.resetRGBColorStroke(); }
Example 2
Source File: FloatingBoxesTest.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
/** * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell, * com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[]) */ public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { float x1 = position.getLeft() + 2; float x2 = position.getRight() - 2; float y1 = position.getTop() - 2; float y2 = position.getBottom() + 2; PdfContentByte canvas = canvases[PdfPTable.LINECANVAS]; canvas.setRGBColorStroke(0xFF, 0x00, 0x00); canvas.rectangle(x1, y1, x2 - x1, y2 - y1); canvas.stroke(); canvas.resetRGBColorStroke(); }
Example 3
Source File: ShapesTest.java From itext2 with GNU Lesser General Public License v3.0 | 4 votes |
/** * Draws some shapes. */ @Test public void main() throws Exception { // step 1: creation of a document-object Document document = new Document(); try { // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream( "shapes.pdf")); // step 3: we open the document document.open(); // step 4: we grab the ContentByte and do some stuff with it PdfContentByte cb = writer.getDirectContent(); // an example of a rectangle with a diagonal in very thick lines cb.setLineWidth(10f); // draw a rectangle cb.rectangle(100, 700, 100, 100); // add the diagonal cb.moveTo(100, 700); cb.lineTo(200, 800); // stroke the lines cb.stroke(); // an example of some circles cb.setLineDash(3, 3, 0); cb.setRGBColorStrokeF(0f, 255f, 0f); cb.circle(150f, 500f, 100f); cb.stroke(); cb.setLineWidth(5f); cb.resetRGBColorStroke(); cb.circle(150f, 500f, 50f); cb.stroke(); // example with colorfill cb.setRGBColorFillF(0f, 255f, 0f); cb.moveTo(100f, 200f); cb.lineTo(200f, 250f); cb.lineTo(400f, 150f); // because we change the fill color BEFORE we stroke the triangle // the color of the triangle will be red instead of green cb.setRGBColorFillF(255f, 0f, 0f); cb.closePathFillStroke(); cb.sanityCheck(); } catch(DocumentException de) { System.err.println(de.getMessage()); } catch(IOException ioe) { System.err.println(ioe.getMessage()); } // step 5: we close the document document.close(); }