本文整理汇总了Java中com.lowagie.text.pdf.PdfTemplate.setRGBColorFill方法的典型用法代码示例。如果您正苦于以下问题:Java PdfTemplate.setRGBColorFill方法的具体用法?Java PdfTemplate.setRGBColorFill怎么用?Java PdfTemplate.setRGBColorFill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.pdf.PdfTemplate
的用法示例。
在下文中一共展示了PdfTemplate.setRGBColorFill方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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();
}