本文整理匯總了Java中com.lowagie.text.pdf.PdfContentByte.stroke方法的典型用法代碼示例。如果您正苦於以下問題:Java PdfContentByte.stroke方法的具體用法?Java PdfContentByte.stroke怎麽用?Java PdfContentByte.stroke使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.lowagie.text.pdf.PdfContentByte
的用法示例。
在下文中一共展示了PdfContentByte.stroke方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawLine
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Draws a horizontal line.
* @param canvas the canvas to draw on
* @param leftX the left x coordinate
* @param rightX the right x coordindate
* @param y the y coordinate
*/
public void drawLine(PdfContentByte canvas, float leftX, float rightX, float y) {
float w;
if (getPercentage() < 0)
w = -getPercentage();
else
w = (rightX - leftX) * getPercentage() / 100.0f;
float s;
switch (getAlignment()) {
case Element.ALIGN_LEFT:
s = 0;
break;
case Element.ALIGN_RIGHT:
s = rightX - leftX - w;
break;
default:
s = (rightX - leftX - w) / 2;
break;
}
canvas.setLineWidth(getLineWidth());
if (getLineColor() != null)
canvas.setColorStroke(getLineColor());
canvas.moveTo(s + leftX, y + offset);
canvas.lineTo(s + w + leftX, y + offset);
canvas.stroke();
}
示例2: tableLayout
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* @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();
}
示例3: cellLayout
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* @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();
}
示例4: main
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* 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();
}
示例5: pictureBackdrop
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Prints a square and fills half of it with a gray rectangle.
* @param x
* @param y
* @param cb
* @throws Exception
*/
public static void pictureBackdrop(float x, float y, PdfContentByte cb) throws Exception {
cb.setColorStroke(Color.black);
cb.setColorFill(Color.red);
cb.rectangle(x, y, 100, 200);
cb.fill();
cb.setLineWidth(2);
cb.rectangle(x, y, 200, 200);
cb.stroke();
}
示例6: pictureBackdrop
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Prints a square and fills half of it with a gray rectangle.
*
* @param x
* @param y
* @param cb
* @throws Exception
*/
private static void pictureBackdrop(float x, float y, PdfContentByte cb)
throws Exception {
cb.setColorStroke(Color.black);
cb.setColorFill(Color.gray);
cb.rectangle(x, y, 100, 200);
cb.fill();
cb.setLineWidth(2);
cb.rectangle(x, y, 200, 200);
cb.stroke();
}
示例7: cellLayout
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* @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) {
PdfContentByte cb = canvases[PdfPTable.TEXTCANVAS];
cb.moveTo(position.getLeft(), position.getBottom());
cb.lineTo(position.getRight(), position.getTop());
cb.stroke();
}
示例8: main
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Draws some concentric circles.
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
try {
// step 2: creation of the writer
PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream( "circles.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();
cb.circle(250.0f, 500.0f, 200.0f);
cb.circle(250.0f, 500.0f, 150.0f);
cb.stroke();
cb.setRGBColorFill(0xFF, 0x00, 0x00);
cb.circle(250.0f, 500.0f, 100.0f);
cb.fillStroke();
cb.setRGBColorFill(0xFF, 0xFF, 0xFF);
cb.circle(250.0f, 500.0f, 50.0f);
cb.fill();
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();
}
示例9: main
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Creates a PDF document with shapes, lines and text at specific X and Y coordinates.
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
try {
// step 2: creation of the writer
PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream( "XandY.pdf"));
// step 3: we open the document
document.open();
// step 4:
PdfContentByte cb = writer.getDirectContent();
// we create a PdfTemplate
PdfTemplate template = cb.createTemplate(25, 25);
// we add some crosses to visualize the coordinates
template.moveTo(13, 0);
template.lineTo(13, 25);
template.moveTo(0, 13);
template.lineTo(50, 13);
template.stroke();
template.sanityCheck();
// we add the template on different positions
cb.addTemplate(template, 216 - 13, 720 - 13);
cb.addTemplate(template, 360 - 13, 360 - 13);
cb.addTemplate(template, 360 - 13, 504 - 13);
cb.addTemplate(template, 72 - 13, 144 - 13);
cb.addTemplate(template, 144 - 13, 288 - 13);
cb.moveTo(216, 720);
cb.lineTo(360, 360);
cb.lineTo(360, 504);
cb.lineTo(72, 144);
cb.lineTo(144, 288);
cb.stroke();
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
cb.beginText();
cb.setFontAndSize(bf, 12);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(3\", 10\")", 216 + 25, 720 + 5, 0);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(5\", 5\")", 360 + 25, 360 + 5, 0);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(5\", 7\")", 360 + 25, 504 + 5, 0);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(1\", 2\")", 72 + 25, 144 + 5, 0);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(2\", 4\")", 144 + 25, 288 + 5, 0);
cb.endText();
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();
}
示例10: main
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Changes the default coordinate system so that the origin is in the upper left corner
* instead of the lower left corner.
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document(PageSize.A4);
try {
// step 2: creation of the writer
PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream( "upsidedown.pdf"));
// step 3: we open the document
document.open();
// step 4:
PdfContentByte cb = writer.getDirectContent();
cb.concatCTM(1f, 0f, 0f, -1f, 0f, PageSize.A4.getHeight());
// we create a PdfTemplate
PdfTemplate template = cb.createTemplate(25, 25);
// we add some crosses to visualize the coordinates
template.moveTo(13, 0);
template.lineTo(13, 25);
template.moveTo(0, 13);
template.lineTo(50, 13);
template.stroke();
template.sanityCheck();
// we add the template on different positions
cb.addTemplate(template, 216 - 13, 720 - 13);
cb.addTemplate(template, 360 - 13, 360 - 13);
cb.addTemplate(template, 360 - 13, 504 - 13);
cb.addTemplate(template, 72 - 13, 144 - 13);
cb.addTemplate(template, 144 - 13, 288 - 13);
cb.moveTo(216, 720);
cb.lineTo(360, 360);
cb.lineTo(360, 504);
cb.lineTo(72, 144);
cb.lineTo(144, 288);
cb.stroke();
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
cb.beginText();
cb.setFontAndSize(bf, 12);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(3\", 10\")", 216 + 25, 720 + 5, 0);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(5\", 5\")", 360 + 25, 360 + 5, 0);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(5\", 7\")", 360 + 25, 504 + 5, 0);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(1\", 2\")", 72 + 25, 144 + 5, 0);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(2\", 4\")", 144 + 25, 288 + 5, 0);
cb.endText();
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();
}
示例11: main
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Changes the transformation matrix with AffineTransform.
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document(PageSize.A4);
// step 2: creation of the writer
PdfWriter writer = PdfWriter.getInstance(document,
PdfTestBase.getOutputStream("affinetransformation.pdf"));
// step 3: we open the document
document.open();
// step 4:
PdfContentByte cb = writer.getDirectContent();
cb.transform(AffineTransform.getScaleInstance(1.2, 0.75));
// we create a PdfTemplate
PdfTemplate template = cb.createTemplate(25, 25);
// we add some crosses to visualize the coordinates
template.moveTo(13, 0);
template.lineTo(13, 25);
template.moveTo(0, 13);
template.lineTo(50, 13);
template.stroke();
template.sanityCheck();
// we add the template on different positions
cb.addTemplate(template, 216 - 13, 720 - 13);
cb.addTemplate(template, 360 - 13, 360 - 13);
cb.addTemplate(template, 360 - 13, 504 - 13);
cb.addTemplate(template, 72 - 13, 144 - 13);
cb.addTemplate(template, 144 - 13, 288 - 13);
cb.moveTo(216, 720);
cb.lineTo(360, 360);
cb.lineTo(360, 504);
cb.lineTo(72, 144);
cb.lineTo(144, 288);
cb.stroke();
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252,
BaseFont.NOT_EMBEDDED);
cb.beginText();
cb.setFontAndSize(bf, 12);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER,
"(3\" * 1.2, 10\" * .75)", 216 + 25, 720 + 5, 0);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER,
"(5\" * 1.2, 5\" * .75)", 360 + 25, 360 + 5, 0);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER,
"(5\" * 1.2, 7\" * .75)", 360 + 25, 504 + 5, 0);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER,
"(1\" * 1.2, 2\" * .75)", 72 + 25, 144 + 5, 0);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER,
"(2\" * 1.2, 4\" * .75)", 144 + 25, 288 + 5, 0);
cb.endText();
cb.sanityCheck();
// step 5: we close the document
document.close();
}
示例12: main
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Adding text at absolute positions.
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
// step 2: creation of the writer
PdfWriter writer = PdfWriter.getInstance(document,
PdfTestBase.getOutputStream("text.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();
// first we draw some lines to be able to visualize the text alignment
// functions
cb.setLineWidth(0f);
cb.moveTo(250, 500);
cb.lineTo(250, 800);
cb.moveTo(50, 700);
cb.lineTo(400, 700);
cb.moveTo(50, 650);
cb.lineTo(400, 650);
cb.moveTo(50, 600);
cb.lineTo(400, 600);
cb.stroke();
// we tell the ContentByte we're ready to draw text
cb.beginText();
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252,
BaseFont.NOT_EMBEDDED);
cb.setFontAndSize(bf, 12);
String text = "Sample text for alignment";
// we show some text starting on some absolute position with a given
// alignment
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, text + " Center", 250,
700, 0);
cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, text + " Right", 250,
650, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, text + " Left", 250, 600,
0);
// we draw some text on a certain position
cb.setTextMatrix(100, 400);
cb.showText("Text at position 100,400.");
// we draw some rotated text on a certain position
cb.setTextMatrix(0, 1, -1, 0, 100, 300);
cb.showText("Text at position 100,300, rotated 90 degrees.");
// we draw some mirrored, rotated text on a certain position
cb.setTextMatrix(0, 1, 1, 0, 200, 200);
cb.showText("Text at position 200,200, mirrored and rotated 90 degrees.");
// we tell the contentByte, we've finished drawing text
cb.endText();
cb.sanityCheck();
// step 5: we close the document
document.close();
}
示例13: onEndPage
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document)
*/
public void onEndPage(PdfWriter writer, Document document) {
PdfContentByte cb = writer.getDirectContent();
cb.saveState();
// write the headertable
table.setTotalWidth(document.right() - document.left());
table.writeSelectedRows(0, -1, document.left(), document.getPageSize().getHeight() - 50, cb);
// compose the footer
String text = "Page " + writer.getPageNumber() + " of ";
float textSize = helv.getWidthPoint(text, 12);
float textBase = document.bottom() - 20;
cb.beginText();
cb.setFontAndSize(helv, 12);
// for odd pagenumbers, show the footer at the left
if ((writer.getPageNumber() & 1) == 1) {
cb.setTextMatrix(document.left(), textBase);
cb.showText(text);
cb.endText();
cb.addTemplate(tpl, document.left() + textSize, textBase);
}
// for even numbers, show the footer at the right
else {
float adjust = helv.getWidthPoint("0", 12);
cb.setTextMatrix(document.right() - textSize - adjust, textBase);
cb.showText(text);
cb.endText();
cb.addTemplate(tpl, document.right() - adjust, textBase);
}
// draw a Rectangle around the page
cb.setColorStroke(Color.orange);
cb.setLineWidth(2);
cb.rectangle(20, 20, document.getPageSize().getWidth() - 40, document.getPageSize().getHeight() - 40);
cb.stroke();
// starting on page 3, a watermark with an Image that is made transparent
if (writer.getPageNumber() >= 3) {
cb.setGState(gstate);
cb.setColorFill(Color.red);
cb.beginText();
cb.setFontAndSize(helv, 48);
cb.showTextAligned(Element.ALIGN_CENTER, "Watermark Opacity " + writer.getPageNumber(), document.getPageSize().getWidth() / 2, document.getPageSize().getHeight() / 2, 45);
cb.endText();
try {
cb.addImage(headerImage, headerImage.getWidth(), 0, 0, headerImage.getHeight(), 440, 80);
}
catch(Exception e) {
throw new ExceptionConverter(e);
}
}
cb.restoreState();
cb.sanityCheck();
}
示例14: plotProperties
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
private void plotProperties(Properties tp, Properties props, List<String> xDate, List<String> yHeight, float height, PdfContentByte cb, boolean countEven) {
StringBuilder temp = null;
String tempValue = null;
String className = null;
String[] tempYcoords;
int origX = 0;
int origY = 0;
Properties args = new Properties();
for (Enumeration e = tp.propertyNames(); e.hasMoreElements();) {
temp = new StringBuilder(e.nextElement().toString());
tempValue = tp.getProperty(temp.toString()).trim();
if (temp.toString().equals("__finalEDB"))
args.setProperty(temp.toString(), props.getProperty(tempValue));
else if (temp.toString().equals("__xDateScale"))
args.setProperty(temp.toString(), props.getProperty(tempValue));
else if (temp.toString().equals("__dateFormat"))
args.setProperty(temp.toString(),tempValue);
else if (temp.toString().equals("__nMaxPixX"))
args.setProperty(temp.toString(),tempValue);
else if (temp.toString().equals("__nMaxPixY"))
args.setProperty(temp.toString(),tempValue);
else if (temp.toString().equals("__fStartX"))
args.setProperty(temp.toString(),tempValue);
else if (temp.toString().equals("__fEndX"))
args.setProperty(temp.toString(),tempValue);
else if (temp.toString().equals("__fStartY"))
args.setProperty(temp.toString(),tempValue);
else if (temp.toString().equals("__fEndY"))
args.setProperty(temp.toString(),tempValue);
else if (temp.toString().equals("__origX"))
origX = Integer.parseInt(tempValue);
else if (temp.toString().equals("__origY"))
origY = Integer.parseInt(tempValue);
else if (temp.toString().equals("__className"))
className = tempValue;
else {
MiscUtils.getLogger().debug("Adding xDate " + temp.toString() + " VAL: " + props.getProperty(temp.toString()));
MiscUtils.getLogger().debug("Adding yHeight " + tempValue + " VAL: " + props.getProperty(tempValue));
xDate.add(props.getProperty(temp.toString()));
yHeight.add(props.getProperty(tempValue));
}
} // end for read in from config file
FrmPdfGraphic pdfGraph = FrmGraphicFactory.create(className);
pdfGraph.init(args);
Properties gProp = pdfGraph.getGraphicXYProp(xDate, yHeight);
//draw the pic
cb.setLineWidth(1.5f);
if (countEven) {
cb.setRGBColorStrokeF(0f, 0f, 255f);
} else {
cb.setRGBColorStrokeF(255f, 0f, 0f);
}
for (Enumeration e = gProp.propertyNames(); e.hasMoreElements();) {
temp = new StringBuilder(e.nextElement().toString());
tempValue = gProp.getProperty(temp.toString(), "");
if (tempValue.equals("")) {
continue;
}
tempYcoords = tempValue.split(",");
for( int idx = 0; idx < tempYcoords.length; ++idx ) {
tempValue = tempYcoords[idx];
cb.circle((origX + Float.parseFloat(temp.toString())), (height - origY + Float.parseFloat(tempValue)), 1.5f);
cb.stroke();
}
}
}
示例15: tableLayout
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* @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[] heights, int headerRows, int rowStart,
PdfContentByte[] canvases) {
// widths of the different cells of the first row
float widths[] = width[0];
PdfContentByte cb = canvases[PdfPTable.TEXTCANVAS];
cb.saveState();
// border for the complete table
cb.setLineWidth(2);
cb.setRGBColorStroke(255, 0, 0);
cb.rectangle(widths[0], heights[heights.length - 1], widths[widths.length - 1] - widths[0], heights[0]
- heights[heights.length - 1]);
cb.stroke();
// border for the header rows
if (headerRows > 0) {
cb.setRGBColorStroke(0, 0, 255);
cb.rectangle(widths[0], heights[headerRows], widths[widths.length - 1] - widths[0], heights[0]
- heights[headerRows]);
cb.stroke();
}
cb.restoreState();
cb = canvases[PdfPTable.BASECANVAS];
cb.saveState();
// border for the cells
cb.setLineWidth(.5f);
// loop over the rows
for (int line = 0; line < heights.length - 1; ++line) {
// loop over the columns
for (int col = 0; col < widths.length - 1; ++col) {
if (line == 0 && col == 0)
cb.setAction(new PdfAction("http://www.lowagie.com/iText/"), widths[col], heights[line + 1],
widths[col + 1], heights[line]);
cb.setRGBColorStrokeF((float) Math.random(), (float) Math.random(), (float) Math.random());
// horizontal borderline
cb.moveTo(widths[col], heights[line]);
cb.lineTo(widths[col + 1], heights[line]);
cb.stroke();
// vertical borderline
cb.setRGBColorStrokeF((float) Math.random(), (float) Math.random(), (float) Math.random());
cb.moveTo(widths[col], heights[line]);
cb.lineTo(widths[col], heights[line + 1]);
cb.stroke();
}
}
cb.restoreState();
}