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


Java PdfContentByte.fill方法代码示例

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


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

示例1: placeBarcode

import com.lowagie.text.pdf.PdfContentByte; //导入方法依赖的package包/类
/**
 *
 * @param cb
 * @param foreground
 * @param moduleSide
 */
public void placeBarcode(PdfContentByte cb, Color foreground, float moduleSide) {

    int width = bm.getWidth();
    int height = bm.getHeight();
    byte[][] mt = bm.getArray();

    cb.setColorFill(foreground);

    for (int y = 0; y < height; ++y) {
        byte[] line = mt[y];
        for (int x = 0; x < width; ++x) {
            if (line[x] == 0) {
                cb.rectangle(x * moduleSide, (height - y - 1) * moduleSide, moduleSide, moduleSide);
            }
        }
    }

    cb.fill();
}
 
开发者ID:TerrenceMiao,项目名称:camel-spring,代码行数:26,代码来源:BarcodeQRCode.java

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

示例3: pictureCircles

import com.lowagie.text.pdf.PdfContentByte; //导入方法依赖的package包/类
/**
 * Prints 3 circles in different colors that intersect with eachother.
 * @param x
 * @param y
 * @param cb
 * @throws Exception
 */
public static void pictureCircles(float x, float y, PdfContentByte cb) throws Exception {
	PdfGState gs = new PdfGState();
	gs.setBlendMode(PdfGState.BM_SOFTLIGHT);
	gs.setFillOpacity(0.7f);
	cb.setGState(gs);
    cb.setColorFill(Color.gray);
    cb.circle(x + 70, y + 70, 50);
    cb.fill();
    cb.circle(x + 100, y + 130, 50);
    cb.fill();
    cb.circle(x + 130, y + 70, 50);
    cb.fill();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:21,代码来源:GroupsTest.java

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

示例5: pictureCircles

import com.lowagie.text.pdf.PdfContentByte; //导入方法依赖的package包/类
/**
 * Prints 3 circles in different colors that intersect with eachother.
 * 
 * @param x
 * @param y
 * @param cb
 * @throws Exception
 */
private static void pictureCircles(float x, float y, PdfContentByte cb)
		throws Exception {
	cb.setColorFill(Color.red);
	cb.circle(x + 70, y + 70, 50);
	cb.fill();
	cb.setColorFill(Color.yellow);
	cb.circle(x + 100, y + 130, 50);
	cb.fill();
	cb.setColorFill(Color.blue);
	cb.circle(x + 130, y + 70, 50);
	cb.fill();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:21,代码来源:TransparencyTest.java

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

示例7: main

import com.lowagie.text.pdf.PdfContentByte; //导入方法依赖的package包/类
/**
 * Changing the Graphics State with saveState() and restoreState().
 * 
 */
@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( "state.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(260.0f, 500.0f, 250.0f);
		cb.fill();
		cb.saveState();
		cb.setColorFill(Color.red);
		cb.circle(260.0f, 500.0f, 200.0f);
		cb.fill();
		cb.saveState();
		cb.setColorFill(Color.blue);
		cb.circle(260.0f, 500.0f, 150.0f);
		cb.fill();
		cb.restoreState();
		cb.circle(260.0f, 500.0f, 100.0f);
		cb.fill();
		cb.restoreState();
		cb.circle(260.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();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:52,代码来源:StateTest.java

示例8: main

import com.lowagie.text.pdf.PdfContentByte; //导入方法依赖的package包/类
/**
 * Changing the Graphics State with PdfGState.
 * 
 */
@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( "gstate.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();

           PdfGState gs = new PdfGState();
           gs.setFillOpacity(0.5f);
           cb.setGState(gs);
		cb.setColorFill(Color.red);
		cb.circle(260.0f, 500.0f, 250.0f);
		cb.fill();
		cb.circle(260.0f, 500.0f, 200.0f);
		cb.fill();
		cb.circle(260.0f, 500.0f, 150.0f);
		cb.fill();
		gs.setFillOpacity(0.2f);
		cb.setGState(gs);
		cb.setColorFill(Color.blue);
		cb.circle(260.0f, 500.0f, 100.0f);
		cb.fill();
		cb.circle(260.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();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:53,代码来源:GStateTest.java

示例9: main

import com.lowagie.text.pdf.PdfContentByte; //导入方法依赖的package包/类
/**
 * Draws different things into different layers.
 */
@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("layers.pdf"));

	// step 3: we open the document
	document.open();

	// step 4:

	// high level
	Paragraph p = new Paragraph();
	for (int i = 0; i < 100; i++)
		p.add(new Chunk("Blah blah blah blah blah. "));
	document.add(p);
	Image img = Image.getInstance(PdfTestBase.RESOURCES_DIR
			+ "hitchcock.png");
	img.setAbsolutePosition(100, 500);
	document.add(img);

	// low level
	PdfContentByte cb = writer.getDirectContent();
	PdfContentByte cbu = writer.getDirectContentUnder();
	cb.setRGBColorFill(0xFF, 0xFF, 0xFF);
	cb.circle(250.0f, 500.0f, 50.0f);
	cb.fill();
	cb.sanityCheck();

	cbu.setRGBColorFill(0xFF, 0x00, 0x00);
	cbu.circle(250.0f, 500.0f, 100.0f);
	cbu.fill();
	cbu.sanityCheck();

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


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