當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。