当前位置: 首页>>代码示例>>Java>>正文


Java PdfContentByte.setRGBColorFill方法代码示例

本文整理汇总了Java中com.itextpdf.text.pdf.PdfContentByte.setRGBColorFill方法的典型用法代码示例。如果您正苦于以下问题:Java PdfContentByte.setRGBColorFill方法的具体用法?Java PdfContentByte.setRGBColorFill怎么用?Java PdfContentByte.setRGBColorFill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.itextpdf.text.pdf.PdfContentByte的用法示例。


在下文中一共展示了PdfContentByte.setRGBColorFill方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCircleAndText

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
public static void createCircleAndText(PdfContentByte cb, String text, float xCoord, float yCoord, float radius, Font textFont, int circleColorRed, int circleColorGreen, int circleColorBlue)
        throws DocumentException, IOException {
    cb.saveState();
    cb.setRGBColorFill(circleColorRed, circleColorGreen, circleColorBlue);
    cb.circle(xCoord, yCoord, radius);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    PdfPTable table = new PdfPTable(1);
    float[] rows = { 595f };
    table.setTotalWidth(rows);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.getDefaultCell().setFixedHeight(radius * 2);
    table.addCell(new Phrase(new Chunk(text, textFont)));
    table.writeSelectedRows(0, 1, 0, yCoord + radius, cb);
}
 
开发者ID:Dica-Developer,项目名称:weplantaforest,代码行数:20,代码来源:PdfHelper.java

示例2: testSimple

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
@Test
public void testSimple() throws FileNotFoundException, DocumentException
{
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(new File(RESULT_FOLDER, "transparency.pdf")));
    writer.setCompressionLevel(0);
    document.open();
    PdfContentByte content = writer.getDirectContent();

    content.setRGBColorStroke(0, 255, 0);
    for (int y = 0; y <= 400; y+= 10)
    {
        content.moveTo(0, y);
        content.lineTo(500, y);
    }
    for (int x = 0; x <= 500; x+= 10)
    {
        content.moveTo(x, 0);
        content.lineTo(x, 400);
    }
    content.stroke();

    
    content.saveState();
    PdfGState state = new PdfGState();
    state.setFillOpacity(0.5f);
    content.setGState(state);
    content.setRGBColorFill(255, 0, 0);
    content.moveTo(162, 86);
    content.lineTo(162, 286);
    content.lineTo(362, 286);
    content.lineTo(362, 86);
    content.closePath();
    //content.fillStroke();
    content.fill();
    
    content.restoreState();

    document.close();
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:41,代码来源:TestTransparency.java

示例3: testComplex

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
@Test
public void testComplex() throws FileNotFoundException, DocumentException
{
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(new File(RESULT_FOLDER, "transparencyComplex.pdf")));
    writer.setCompressionLevel(0);
    document.open();
    PdfContentByte content = writer.getDirectContent();

    content.setRGBColorStroke(0, 255, 0);
    for (int y = 0; y <= 400; y+= 10)
    {
        content.moveTo(0, y);
        content.lineTo(500, y);
    }
    for (int x = 0; x <= 500; x+= 10)
    {
        content.moveTo(x, 0);
        content.lineTo(x, 400);
    }
    content.stroke();

    PdfTemplate template = content.createTemplate(500, 400);
    PdfTransparencyGroup group = new PdfTransparencyGroup();
    group.put(PdfName.CS, PdfName.DEVICEGRAY);
    group.setIsolated(false);
    group.setKnockout(false);
    template.setGroup(group);
    PdfShading radial = PdfShading.simpleRadial(writer, 262, 186, 10, 262, 186, 190, BaseColor.WHITE, BaseColor.BLACK, true, true);
    template.paintShading(radial);

    PdfDictionary mask = new PdfDictionary();
    mask.put(PdfName.TYPE, PdfName.MASK);
    mask.put(PdfName.S, new PdfName("Luminosity"));
    mask.put(new PdfName("G"), template.getIndirectReference());

    content.saveState();
    PdfGState state = new PdfGState();
    state.put(PdfName.SMASK, mask);
    content.setGState(state);
    content.setRGBColorFill(255, 0, 0);
    content.moveTo(162, 86);
    content.lineTo(162, 286);
    content.lineTo(362, 286);
    content.lineTo(362, 86);
    content.closePath();
    //content.fillStroke();
    content.fill();
    
    content.restoreState();

    document.close();
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:54,代码来源:TestTransparency.java

示例4: writeFillColor

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
/**
 * Write fill color in RGB.
 */
private void writeFillColor(Color color, PdfContentByte cb) {
    cb.setRGBColorFill(color.getRed(), color.getGreen(), color.getBlue());
}
 
开发者ID:OSUCartography,项目名称:ScreePainter,代码行数:7,代码来源:PDFExporter.java

示例5: createBlueBlock

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
private void createBlueBlock(PdfContentByte cb, int treeCount) throws DocumentException {
    cb.saveState();
    cb.setRGBColorFill(0x64, 0xA7, 0xBD);
    cb.rectangle(0.0f, 375.0f, 595.0f, 200.0f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    Font textFont = new Font(FontFamily.TIMES_ROMAN, 14, Font.ITALIC, BaseColor.WHITE);
    Font textBlack = new Font(FontFamily.TIMES_ROMAN, 14, Font.ITALIC, BaseColor.BLACK);
    Font textFontTreeCount = new Font(FontFamily.HELVETICA, 30, Font.BOLD, BaseColor.BLACK);
    PdfPTable tableForTreeCount = new PdfPTable(1);
    float[] rows = { 495f };
    tableForTreeCount.setTotalWidth(rows);
    tableForTreeCount.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    tableForTreeCount.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    tableForTreeCount.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    tableForTreeCount.getDefaultCell().setFixedHeight(40);

    Integer treeCountAsObject = treeCount;
    tableForTreeCount.addCell(new Phrase(new Chunk(treeCountAsObject.toString(), textFontTreeCount)));

    tableForTreeCount.writeSelectedRows(0, 1, 50f, 575f, cb);

    PdfPTable tableForWhiteText = new PdfPTable(1);
    tableForWhiteText.setTotalWidth(rows);
    tableForWhiteText.getDefaultCell().setBorder(Rectangle.BOTTOM);
    tableForWhiteText.getDefaultCell().setBorderWidth(1f);
    tableForWhiteText.getDefaultCell().setBorderColor(BaseColor.WHITE);
    tableForWhiteText.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    tableForWhiteText.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    tableForWhiteText.getDefaultCell().setFixedHeight(40);

    Phrase phraseForTreesPlantForYou = new Phrase();
    if (treeCount == 1) {
        phraseForTreesPlantForYou.add(new Chunk("Baum wurde für Sie gepflanzt!", textFont));
    } else {
        phraseForTreesPlantForYou.add(new Chunk("Bäume wurden für Sie gepflanzt!", textFont));
    }

    PdfPCell longTextCell = new PdfPCell();
    longTextCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    longTextCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    longTextCell.setBorder(Rectangle.BOTTOM);
    longTextCell.setBorderWidth(1f);
    longTextCell.setBorderColor(BaseColor.WHITE);
    longTextCell.setFixedHeight(65);

    Paragraph longText = new Paragraph(new Chunk(
            "Mit diesem Gutschein können sie Ihre Pflanzung in Augenschein nehmen und mehr über die naturnahen Aufforstungsprojekte bei \"I Plant A Tree\" erfahren. Ihre Bäume wachsen auf ehemals brachliegenden Flächen und sind Teil neu entstehender Wälder.",
            textFont));
    longText.setLeading(15f);

    longTextCell.addElement(longText);

    tableForWhiteText.addCell(phraseForTreesPlantForYou);
    tableForWhiteText.addCell(longTextCell);
    tableForWhiteText.writeSelectedRows(0, 2, 50f, 535f, cb);

    PdfPTable tableForHowItWorks = new PdfPTable(1);
    tableForHowItWorks.setTotalWidth(rows);
    tableForHowItWorks.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    tableForHowItWorks.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    tableForHowItWorks.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    tableForHowItWorks.getDefaultCell().setFixedHeight(40);

    tableForHowItWorks.addCell(new Phrase(new Chunk("Und so einfach funktioniert's:", textBlack)));

    tableForHowItWorks.writeSelectedRows(0, 2, 50f, 425f, cb);
}
 
开发者ID:Dica-Developer,项目名称:weplantaforest,代码行数:71,代码来源:PdfGiftView.java

示例6: createTreeCountAndCustomTextBlock

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
private void createTreeCountAndCustomTextBlock(PdfContentByte cb, String customText, int treeCount) throws DocumentException {
    Font textFont = new Font(FontFamily.TIMES_ROMAN, 16, Font.ITALIC, BaseColor.BLACK);
    Font textFontTreeCount = new Font(FontFamily.HELVETICA, 30, Font.BOLD, BaseColor.BLACK);
    Font customTextFont = new Font(FontFamily.HELVETICA, 12, Font.NORMAL, BaseColor.BLACK);

    cb.saveState();
    cb.setRGBColorFill(0xE0, 0xDE, 0xDF);
    cb.rectangle(0.0f, 325.0f, 595.0f, 205.0f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    Integer treeCountAsObj = treeCount;

    PdfPTable table = new PdfPTable(1);
    float[] rows = { 595f };
    table.setTotalWidth(rows);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.getDefaultCell().setFixedHeight(35);
    table.addCell(new Phrase(new Chunk("über die Pflanzung von", textFont)));
    table.addCell(new Phrase(new Chunk(treeCountAsObj.toString(), textFontTreeCount)));
    table.addCell(new Phrase(new Chunk("Bäumen", textFont)));
    table.writeSelectedRows(0, 3, 0, 520, cb);

    cb.saveState();
    cb.setRGBColorFill(0xF7, 0xF2, 0xF4);
    cb.rectangle(50.0f, 345.0f, 495.0f, 60.0f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    PdfPTable textTable = new PdfPTable(1);
    float[] textRows = { 475f };
    textTable.setTotalWidth(textRows);
    textTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    textTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    textTable.getDefaultCell().setFixedHeight(40);
    textTable.addCell(new Phrase(new Chunk(customText, customTextFont)));
    textTable.writeSelectedRows(0, 1, 60, 395, cb);
}
 
开发者ID:Dica-Developer,项目名称:weplantaforest,代码行数:43,代码来源:PdfCertificateView.java

示例7: createTreeCountAndCustomTextBlock

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
private void createTreeCountAndCustomTextBlock(PdfContentByte cb, String customText, int treeCount) throws DocumentException {
    Font textFont = new Font(FontFamily.TIMES_ROMAN, 16, Font.ITALIC, BaseColor.WHITE);
    Font textFontTreeCount = new Font(FontFamily.HELVETICA, 30, Font.BOLD, BaseColor.BLACK);
    Font customTextFont = new Font(FontFamily.HELVETICA, 12, Font.NORMAL, BaseColor.BLACK);

    cb.saveState();
    cb.setRGBColorFill(0x64, 0xA7, 0xBD);
    cb.rectangle(0.0f, 325.0f, 595.0f, 205.0f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    Integer treeCountAsObj = treeCount;

    PdfPTable table = new PdfPTable(1);
    float[] rows = { 595f };
    table.setTotalWidth(rows);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.getDefaultCell().setFixedHeight(35);
    table.addCell(new Phrase(new Chunk("über die Pflanzung von", textFont)));
    table.addCell(new Phrase(new Chunk(treeCountAsObj.toString(), textFontTreeCount)));
    table.addCell(new Phrase(new Chunk("Bäumen", textFont)));
    table.writeSelectedRows(0, 3, 0, 520, cb);

    cb.saveState();
    cb.setRGBColorFill(0xF7, 0xF2, 0xF4);
    cb.rectangle(50.0f, 345.0f, 495.0f, 60.0f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    PdfPTable textTable = new PdfPTable(1);
    float[] textRows = { 475f };
    textTable.setTotalWidth(textRows);
    textTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    textTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    textTable.getDefaultCell().setFixedHeight(40);
    textTable.addCell(new Phrase(new Chunk(customText, customTextFont)));
    textTable.writeSelectedRows(0, 1, 60, 395, cb);
}
 
开发者ID:Dica-Developer,项目名称:weplantaforest,代码行数:43,代码来源:PdfCertificateView2.java

示例8: createGeometricObjects

import com.itextpdf.text.pdf.PdfContentByte; //导入方法依赖的package包/类
private void createGeometricObjects(PdfContentByte cb, long amountOfCarts, Document doc) {
    // first big grey block
    // float y 310 h 325
    cb.saveState();
    cb.setRGBColorFill(0xE0, 0xDE, 0xDF);
    cb.rectangle(0.0f, 325f - (amountOfCarts + 1) * 16f, 595.0f, 310 + (amountOfCarts + 1) * 16f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    // name and address block
    cb.saveState();
    cb.setRGBColorFill(0xFC, 0xFC, 0xFC);
    cb.rectangle(75.0f, 410.0f, 445.0f, 120.0f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    // price block
    cb.saveState();
    cb.setRGBColorFill(0xFC, 0xFC, 0xFC);
    cb.rectangle(75.0f, 350f - (amountOfCarts + 1) * 16f, 295f, 45f + (amountOfCarts + 1) * 16f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    // date block
    cb.saveState();
    cb.setRGBColorFill(0xFC, 0xFC, 0xFC);
    cb.rectangle(385.0f, 350f - (amountOfCarts + 1) * 16f, 135f, 45f + (amountOfCarts + 1) * 16f);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    // small triangle in address block
    cb.saveState();
    cb.setRGBColorFill(0xE0, 0xDE, 0xDF);
    cb.moveTo(74f, 455f);
    cb.lineTo(74f, 485f);
    cb.lineTo(82f, 470f);
    cb.lineTo(74f, 455f);
    cb.fill();
    cb.closePathStroke();
    cb.restoreState();

    // small triangle in price block
    cb.saveState();
    cb.setRGBColorFill(0xE0, 0xDE, 0xDF);
    cb.moveTo(74f, 350f);
    cb.lineTo(74f, 380f);
    cb.lineTo(82f, 365f);
    cb.lineTo(74f, 350f);
    cb.fill();
    cb.closePathStroke();
    cb.restoreState();

}
 
开发者ID:Dica-Developer,项目名称:weplantaforest,代码行数:58,代码来源:PdfReceiptView.java


注:本文中的com.itextpdf.text.pdf.PdfContentByte.setRGBColorFill方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。