本文整理匯總了Java中com.lowagie.text.pdf.PdfContentByte.fillStroke方法的典型用法代碼示例。如果您正苦於以下問題:Java PdfContentByte.fillStroke方法的具體用法?Java PdfContentByte.fillStroke怎麽用?Java PdfContentByte.fillStroke使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.lowagie.text.pdf.PdfContentByte
的用法示例。
在下文中一共展示了PdfContentByte.fillStroke方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Painting Patterns.
*
* @param args
* no arguments needed
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
// 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("pattern.pdf"));
// step 3: we open the document
document.open();
// step 4: we add some content
PdfContentByte cb = writer.getDirectContent();
PdfTemplate tp = cb.createTemplate(400, 300);
PdfPatternPainter pat = cb.createPattern(15, 15, null);
pat.rectangle(5, 5, 5, 5);
pat.fill();
pat.sanityCheck();
PdfSpotColor spc_cmyk = new PdfSpotColor("PANTONE 280 CV",
new CMYKColor(0.9f, .2f, .3f, .1f));
SpotColor spot = new SpotColor(spc_cmyk, 0.25f);
tp.setPatternFill(pat, spot, .9f);
tp.rectangle(0, 0, 400, 300);
tp.fill();
tp.sanityCheck();
cb.addTemplate(tp, 50, 50);
PdfPatternPainter pat2 = cb.createPattern(10, 10, null);
pat2.setLineWidth(2);
pat2.moveTo(-5, 0);
pat2.lineTo(10, 15);
pat2.stroke();
pat2.moveTo(0, -5);
pat2.lineTo(15, 10);
pat2.stroke();
cb.setLineWidth(1);
cb.setColorStroke(Color.black);
cb.setPatternFill(pat2, Color.red);
cb.rectangle(100, 400, 30, 210);
cb.fillStroke();
cb.setPatternFill(pat2, Color.green);
cb.rectangle(150, 400, 30, 100);
cb.fillStroke();
cb.setPatternFill(pat2, Color.blue);
cb.rectangle(200, 400, 30, 130);
cb.fillStroke();
cb.setPatternFill(pat2, new GrayColor(0.5f));
cb.rectangle(250, 400, 30, 80);
cb.fillStroke();
cb.setPatternFill(pat2, new GrayColor(0.7f));
cb.rectangle(300, 400, 30, 170);
cb.fillStroke();
cb.setPatternFill(pat2, new GrayColor(0.9f));
cb.rectangle(350, 400, 30, 40);
cb.fillStroke();
cb.sanityCheck();
// step 5: we close the document
document.close();
}
示例2: 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();
}