當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。