当前位置: 首页>>代码示例>>Java>>正文


Java PdfContentByte.setRGBColorStroke方法代码示例

本文整理汇总了Java中com.lowagie.text.pdf.PdfContentByte.setRGBColorStroke方法的典型用法代码示例。如果您正苦于以下问题:Java PdfContentByte.setRGBColorStroke方法的具体用法?Java PdfContentByte.setRGBColorStroke怎么用?Java PdfContentByte.setRGBColorStroke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.lowagie.text.pdf.PdfContentByte的用法示例。


在下文中一共展示了PdfContentByte.setRGBColorStroke方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:18,代码来源:FloatingBoxesTest.java

示例2: 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();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:16,代码来源:FloatingBoxesTest.java

示例3: main

import com.lowagie.text.pdf.PdfContentByte; //导入方法依赖的package包/类
/**
 * Writing vertical text.
 */
@Test
public void main() throws Exception {
	Document document = new Document(PageSize.A4, 50, 50, 50, 50);
	texts[3] = convertCid(texts[0]);
	texts[4] = convertCid(texts[1]);
	texts[5] = convertCid(texts[2]);
	PdfWriter writer = PdfWriter.getInstance(document,PdfTestBase.getOutputStream("vertical.pdf"));
	int idx = 0;
	document.open();
	PdfContentByte cb = writer.getDirectContent();
	for (int j = 0; j < 2; ++j) {
		BaseFont bf = BaseFont.createFont("KozMinPro-Regular", encs[j],	false);
		cb.setRGBColorStroke(255, 0, 0);
		cb.setLineWidth(0);
		float x = 400;
		float y = 700;
		float height = 400;
		float leading = 30;
		int maxLines = 6;
		for (int k = 0; k < maxLines; ++k) {
			cb.moveTo(x - k * leading, y);
			cb.lineTo(x - k * leading, y - height);
		}
		cb.rectangle(x, y, -leading * (maxLines - 1), -height);
		cb.stroke();
		VerticalText vt = new VerticalText(cb);
		vt.setVerticalLayout(x, y, height, maxLines, leading);
		vt.addText(new Chunk(texts[idx++], new Font(bf, 20)));
		vt.addText(new Chunk(texts[idx++], new Font(bf, 20, 0, Color.blue)));
		vt.go();
		vt.setAlignment(Element.ALIGN_RIGHT);
		vt.addText(new Chunk(texts[idx++],	new Font(bf, 20, 0, Color.orange)));
		vt.go();
		document.newPage();
	}
	document.close();

}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:42,代码来源:VerticalTest.java

示例4: main

import com.lowagie.text.pdf.PdfContentByte; //导入方法依赖的package包/类
/**
 * Adding text at absolute positions.
 * 
 * @param args
 *            no arguments needed
 */
@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("complextext.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();

	File font = new File (PdfTestBase.RESOURCES_DIR + "/liberation-fonts-ttf/LiberationSans-Regular.ttf");
	// we construct a font
	BaseFont bf = BaseFont.createFont(font.getAbsolutePath(), BaseFont.IDENTITY_H, true);
	Font ft = new Font(bf, 12);
	// This is the text:
	String text = "\u0623\u0648\u0631\u0648\u0628\u0627, \u0628\u0631\u0645\u062c\u064a\u0627\u062a \u0627\u0644\u062d\u0627\u0633\u0648\u0628 + \u0627\u0646\u062a\u0631\u0646\u064a\u062a :";
	Phrase center = new Phrase(text + " Center", ft);
	ColumnText
			.showTextAligned(cb, PdfContentByte.ALIGN_CENTER, center, 250, 700, 0, PdfWriter.RUN_DIRECTION_RTL, 0);
	ColumnText.showTextAligned(cb, PdfContentByte.ALIGN_RIGHT, new Phrase(text + " Right", ft), 250, 650, 20,
			PdfWriter.RUN_DIRECTION_RTL, 0);
	ColumnText.showTextAligned(cb, PdfContentByte.ALIGN_LEFT, new Phrase("Some text Left aligned", ft), 250, 600,
			20);
	float size = ColumnText.getWidth(center, PdfWriter.RUN_DIRECTION_RTL, 0);
	cb.setRGBColorStroke(255, 0, 0);
	cb.rectangle(250 - size / 2, 690, size, 30);
	cb.stroke();

	// step 5: we close the document
	document.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:57,代码来源:ComplexTextTest.java

示例5: 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) {
        widths = width[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();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:51,代码来源:TableEvents2Test.java

示例6: 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();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:54,代码来源:TableEvents1Test.java

示例7: preparePen

import com.lowagie.text.pdf.PdfContentByte; //导入方法依赖的package包/类
/**
 *
 */
private static void preparePen(PdfContentByte pdfContentByte, JRPen pen, int lineCap)
{
	float lineWidth = pen.getLineWidth().floatValue();

	if (lineWidth <= 0)
	{
		return;
	}
	
	pdfContentByte.setLineWidth(lineWidth);
	pdfContentByte.setLineCap(lineCap);

	Color color = pen.getLineColor();
	pdfContentByte.setRGBColorStroke(
		color.getRed(),
		color.getGreen(),
		color.getBlue()
		);

	switch (pen.getLineStyleValue())
	{
		case DOUBLE :
		{
			pdfContentByte.setLineWidth(lineWidth / 3);
			pdfContentByte.setLineDash(0f);
			break;
		}
		case DOTTED :
		{
			switch (lineCap)
			{
				case PdfContentByte.LINE_CAP_BUTT :
				{
					pdfContentByte.setLineDash(lineWidth, lineWidth, 0f);
					break;
				}
				case PdfContentByte.LINE_CAP_PROJECTING_SQUARE :
				{
					pdfContentByte.setLineDash(0, 2 * lineWidth, 0f);
					break;
				}
			}
			break;
		}
		case DASHED :
		{
			switch (lineCap)
			{
				case PdfContentByte.LINE_CAP_BUTT :
				{
					pdfContentByte.setLineDash(5 * lineWidth, 3 * lineWidth, 0f);
					break;
				}
				case PdfContentByte.LINE_CAP_PROJECTING_SQUARE :
				{
					pdfContentByte.setLineDash(4 * lineWidth, 4 * lineWidth, 0f);
					break;
				}
			}
			break;
		}
		case SOLID :
		default :
		{
			pdfContentByte.setLineDash(0f);
			break;
		}
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:73,代码来源:JRPdfExporter.java


注:本文中的com.lowagie.text.pdf.PdfContentByte.setRGBColorStroke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。