本文整理了Java中com.lowagie.text.pdf.PdfContentByte.rectangle()
方法的一些代码示例,展示了PdfContentByte.rectangle()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PdfContentByte.rectangle()
方法的具体详情如下:
包路径:com.lowagie.text.pdf.PdfContentByte
类名称:PdfContentByte
方法名:rectangle
[英]Adds a rectangle to the current path.
[中]将矩形添加到当前路径。
代码示例来源:origin: stackoverflow.com
PdfWriter writer = ...;
PdfContentByte cb = writer.getDirectContent();
cb.saveState();
cb.setColorStroke(Color.black);
cb.rectangle(x,y,x1,y1);
cb.stroke();
cb.restoreState();
代码示例来源:origin: stackoverflow.com
rect.setBorder(Rectangle.BOX);
rect.setBorderWidth(0.5f);
rect.setBorderColor(BaseColor.RED);
PdfContentByte cb = writer.getDirectContent();
cb.rectangle(rect);
代码示例来源:origin: stackoverflow.com
PdfContentByte canvas = writer.getDirectContent();
canvas.rectangle(50, 600, 500, 40);
canvas.setColorFill(BaseColor.GRAY);
canvas.fill();
代码示例来源:origin: stackoverflow.com
public class MyTableEvent implements PdfPTableEvent {
public void tableLayout(PdfPTable table, float[][] width, float[] height,
int headerRows, int rowStart, PdfContentByte[] canvas) {
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 cb = canvas[PdfPTable.LINECANVAS];
cb.rectangle(x1, y1, x2 - x1, y2 - y1);
cb.stroke();
cb.resetRGBColorStroke();
}
}
代码示例来源:origin: stackoverflow.com
public class BorderEvent implements PdfPTableEvent {
public void tableLayout(PdfPTable table, float[][] widths,
float[] heights, int headerRows, int rowStart,
PdfContentByte[] canvases) {
float width[] = widths[0];
float x1 = width[0];
float x2 = width[width.length - 1];
float y1 = heights[0];
float y2 = heights[heights.length - 1];
PdfContentByte cb = canvases[PdfPTable.LINECANVAS];
cb.rectangle(x1, y1, x2 - x1, y2 - y1);
cb.stroke();
cb.resetRGBColorStroke();
}
}
代码示例来源:origin: stackoverflow.com
PdfContentByte canvas = writer.getDirectContent();
Rectangle rect1 = new Rectangle(llx, lly, urx, ury);
rect1.setBackgroundColor(BaseColor.LIGHT_GRAY);
rect1.setBorder(Rectangle.BOX);
rect1.setBorderWidth(1);
canvas.rectangle(rect1);
代码示例来源:origin: stackoverflow.com
class DottedCell implements PdfPCellEvent {
@Override
public void cellLayout(PdfPCell cell, Rectangle position,
PdfContentByte[] canvases) {
PdfContentByte canvas = canvases[PdfPTable.LINECANVAS];
canvas.setLineDash(3f, 3f);
canvas.rectangle(position.getLeft(), position.getBottom(),
position.getWidth(), position.getHeight());
canvas.stroke();
}
}
代码示例来源:origin: stackoverflow.com
private static void rect(PdfWriter writer) {
PdfContentByte cb = writer.getDirectContent();
try {
cb.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false), 24);
cb.rectangle(140f,140f,280f,420f);
cb.stroke();
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
代码示例来源:origin: fr.opensagres.xdocreport.itext-gae/itext-gae
/**
* @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 sp_left = spacing_left;
if (Float.isNaN(sp_left)) sp_left = 0f;
float sp_right = spacing_right;
if (Float.isNaN(sp_right)) sp_right = 0f;
float sp_top = spacing_top;
if (Float.isNaN(sp_top)) sp_top = 0f;
float sp_bottom = spacing_bottom;
if (Float.isNaN(sp_bottom)) sp_bottom = 0f;
Rectangle rect = new Rectangle(position.getLeft(sp_left), position.getBottom(sp_bottom), position.getRight(sp_right), position.getTop(sp_top));
rect.cloneNonPositionParameters(this);
canvases[PdfPTable.BACKGROUNDCANVAS].rectangle(rect);
rect.setBackgroundColor(null);
canvases[PdfPTable.LINECANVAS].rectangle(rect);
}
代码示例来源:origin: stackoverflow.com
public class DrawRectangle extends PdfPageEventHelper {
@Override
public void onGenericTag(PdfWriter writer, Document document, Rectangle rect, String text) {
PdfContentByte canvas = writer.getDirectContent();
canvas.rectangle(rect.getLeft(), rect.getBottom(), rect.getWidth(), rect.getHeight());
canvas.stroke();
canvas.restoreState();
}
}
代码示例来源:origin: com.github.librepdf/openpdf
/**
* @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[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases) {
float[] width = widths[0];
Rectangle rect = new Rectangle(width[0], heights[heights.length - 1], width[width.length - 1], heights[0]);
rect.cloneNonPositionParameters(this);
int bd = rect.getBorder();
rect.setBorder(Rectangle.NO_BORDER);
canvases[PdfPTable.BACKGROUNDCANVAS].rectangle(rect);
rect.setBorder(bd);
rect.setBackgroundColor(null);
canvases[PdfPTable.LINECANVAS].rectangle(rect);
}
代码示例来源:origin: fr.opensagres.xdocreport.itext-gae/itext-gae
/**
* @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[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases) {
float[] width = widths[0];
Rectangle rect = new Rectangle(width[0], heights[heights.length - 1], width[width.length - 1], heights[0]);
rect.cloneNonPositionParameters(this);
int bd = rect.getBorder();
rect.setBorder(Rectangle.NO_BORDER);
canvases[PdfPTable.BACKGROUNDCANVAS].rectangle(rect);
rect.setBorder(bd);
rect.setBackgroundColor(null);
canvases[PdfPTable.LINECANVAS].rectangle(rect);
}
代码示例来源:origin: es.gob.afirma/afirma-crypto-pdf-itext
/**
* @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[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases) {
float[] width = widths[0];
Rectangle rect = new Rectangle(width[0], heights[heights.length - 1], width[width.length - 1], heights[0]);
rect.cloneNonPositionParameters(this);
int bd = rect.getBorder();
rect.setBorder(Rectangle.NO_BORDER);
canvases[PdfPTable.BACKGROUNDCANVAS].rectangle(rect);
rect.setBorder(bd);
rect.setBackgroundColor(null);
canvases[PdfPTable.LINECANVAS].rectangle(rect);
}
代码示例来源:origin: stackoverflow.com
public class Background extends PdfPageEventHelper {
@Override
public void onEndPage(PdfWriter writer, Document document) {
int pagenumber = writer.getPageNumber();
if (pagenumber % 2 == 1 && pagenumber != 1)
return;
PdfContentByte canvas = writer.getDirectContentUnder();
Rectangle rect = document.getPageSize();
canvas.setColorFill(pagenumber <3 ? BaseColor.BLUE : BaseColor.LIGHT_GRAY);
canvas.rectangle(rect.getLeft(), rect.getBottom(), rect.getWidth(), rect.getHeight());
canvas.fill();
}
}
代码示例来源:origin: stackoverflow.com
public class MyBorder implements PdfPCellEvent {
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.rectangle(x1, y1, x2 - x1, y2 - y1);
canvas.stroke();
}
}
代码示例来源:origin: org.jclarion/clarion-runtime
private void pathBox(int x1, int y1, int width, int height,int curve)
{
if (curve==0) {
cb.rectangle(
(x1+xofs)/10.0f,
document.getPageSize().getHeight()-(y1+yofs)/10.0f,
width/10.0f,
height/-10.0f);
} else {
cb.roundRectangle(
(x1+xofs)/10.0f,
document.getPageSize().getHeight()-(y1+yofs)/10.0f,
width/10.0f,
height/-10.0f,curve/10.0f);
}
}
代码示例来源:origin: stackoverflow.com
public class RedBorder extends PdfPageEventHelper {
@Override
public void onEndPage(PdfWriter writer, Document document) {
PdfContentByte canvas = writer.getDirectContent();
Rectangle rect = document.getPageSize();
rect.setBorder(Rectangle.BOX); // left, right, top, bottom border
rect.setBorderWidth(5); // a width of 5 user units
rect.setBorderColor(BaseColor.RED); // a red border
rect.setUseVariableBorders(true); // the full width will be visible
canvas.rectangle(rect);
}
}
代码示例来源:origin: stackoverflow.com
public void onEndPage(PdfWriter writer, Document document) {
PdfContentByte cb = writer.getDirectContent();
cb.saveState();
cb.setColorStroke(new CMYKColor(1f, 0f, 0f, 0f));
cb.setColorFill(new CMYKColor(1f, 0f, 0f, 0f));
cb.rectangle(20,10,10,820);
cb.fill();
cb.restoreState();
}
代码示例来源:origin: stackoverflow.com
public static void drawRectangle(PdfContentByte content, float width, float height) {
content.saveState();
PdfGState state = new PdfGState();
state.setFillOpacity(0.6f);
content.setGState(state);
content.setRGBColorFill(0xFF, 0xFF, 0xFF);
content.setLineWidth(3);
content.rectangle(0, 0, width, height);
content.fillStroke();
content.restoreState();
}
代码示例来源:origin: org.seasar.tuigwaa/tuigwaa-cms
private void renderSidebar(PdfWriter writer, Document document){
// sidebar
cb_.rectangle(0,0,PAGEMARGIN_LEFT/2,document.getPageSize().top());
cb_.setColorFill(cmykSpc_,cmykSpc_.getTint());
cb_.fill();
cb_.resetCMYKColorFill();
// sidebar contents
cb_.beginText();
cb_.setFontAndSize(PdfUtils.BASEFONT_GOTHIC,size_*1.5f);
cb_.setColorFill(Color.BLUE);
cb_.setTextMatrix(0,1,-1,0,PAGEMARGIN_LEFT/3,document.top()/2);
cb_.showText(CREATER_APPLICATION);
cb_.resetRGBColorFill();
cb_.endText();
}