本文整理匯總了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}