本文整理汇总了Java中com.lowagie.text.pdf.PdfTemplate.rectangle方法的典型用法代码示例。如果您正苦于以下问题:Java PdfTemplate.rectangle方法的具体用法?Java PdfTemplate.rectangle怎么用?Java PdfTemplate.rectangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.pdf.PdfTemplate
的用法示例。
在下文中一共展示了PdfTemplate.rectangle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.lowagie.text.pdf.PdfTemplate; //导入方法依赖的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.PdfTemplate; //导入方法依赖的package包/类
/**
* Draws the iText logo.
*/
@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("logo.pdf"));
// step 3: we open the document
document.open();
// step 4:
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252,
BaseFont.NOT_EMBEDDED);
PdfContentByte cb = writer.getDirectContent();
PdfTemplate template = cb.createTemplate(500, 200);
template.setLineWidth(2f);
template.rectangle(2.5f, 2.5f, 495f, 195f);
template.stroke();
template.setLineWidth(12f);
template.arc(40f - (float) Math.sqrt(12800),
120f + (float) Math.sqrt(12800),
200f - (float) Math.sqrt(12800),
-40f + (float) Math.sqrt(12800), 281.25f, 33.75f);
template.arc(40f, 120f, 200f, -40f, 90f, 45f);
template.stroke();
template.setLineCap(1);
template.setLineWidth(12f);
template.arc(80f, 40f, 160f, 120f, 90f, 180f);
template.arc(115f, 75f, 125f, 85f, 0f, 360f);
template.stroke();
template.beginText();
template.setFontAndSize(bf, 180);
template.setRGBColorFill(0xFF, 0x00, 0x00);
template.showTextAligned(PdfContentByte.ALIGN_LEFT, "T", 125f, 35f, 0f);
template.resetRGBColorFill();
template.showTextAligned(PdfContentByte.ALIGN_LEFT, "ext", 220f, 35f,
0f);
template.endText();
template.sanityCheck();
cb.addTemplate(template, 0, 1, -1, 0, 500, 200);
cb.addTemplate(template, .5f, 0, 0, .5f, 100, 400);
cb.addTemplate(template, 0.25f, 0, 0, 0.25f, 100, 100);
cb.sanityCheck();
// step 5: we close the document
document.close();
}
示例3: main
import com.lowagie.text.pdf.PdfTemplate; //导入方法依赖的package包/类
/**
* Draws the iText logo.
*
* @param args
* no arguments needed
*/
public static void main(String[] args) {
System.out.println("iText logo");
// step 1: creation of a document-object
Document document = new Document();
try {
// step 2: creation of the writer
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "logo.pdf"));
// step 3: we open the document
document.open();
// step 4:
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
PdfContentByte cb = writer.getDirectContent();
PdfTemplate template = cb.createTemplate(500, 200);
template.setLineWidth(2f);
template.rectangle(2.5f, 2.5f, 495f, 195f);
template.stroke();
template.setLineWidth(12f);
template.arc(40f - (float) Math.sqrt(12800), 120f + (float) Math.sqrt(12800), 200f - (float) Math
.sqrt(12800), -40f + (float) Math.sqrt(12800), 281.25f, 33.75f);
template.arc(40f, 120f, 200f, -40f, 90f, 45f);
template.stroke();
template.setLineCap(1);
template.setLineWidth(12f);
template.arc(80f, 40f, 160f, 120f, 90f, 180f);
template.arc(115f, 75f, 125f, 85f, 0f, 360f);
template.stroke();
template.beginText();
template.setFontAndSize(bf, 180);
template.setRGBColorFill(0xFF, 0x00, 0x00);
template.showTextAligned(PdfContentByte.ALIGN_LEFT, "T", 125f, 35f, 0f);
template.resetRGBColorFill();
template.showTextAligned(PdfContentByte.ALIGN_LEFT, "ext", 220f, 35f, 0f);
template.endText();
template.sanityCheck();
cb.addTemplate(template, 0, 1, -1, 0, 500, 200);
cb.addTemplate(template, .5f, 0, 0, .5f, 100, 400);
cb.addTemplate(template, 0.25f, 0, 0, 0.25f, 100, 100);
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();
}
示例4: main
import com.lowagie.text.pdf.PdfTemplate; //导入方法依赖的package包/类
/**
* Painting Patterns.
*
* @param args
* no arguments needed
*/
public static void main(String[] args) {
System.out.println("Stencil");
// step 1: creation of a document-object
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
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, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "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", 0.25f, new CMYKColor(0.9f, .2f, .3f, .1f));
SpotColor spot = new SpotColor(spc_cmyk);
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();
} catch (Exception de) {
de.printStackTrace();
}
// step 5: we close the document
document.close();
}