Example usage for com.itextpdf.text BaseColor BLACK

List of usage examples for com.itextpdf.text BaseColor BLACK

Introduction

In this page you can find the example usage for com.itextpdf.text BaseColor BLACK.

Prototype

BaseColor BLACK

To view the source code for com.itextpdf.text BaseColor BLACK.

Click Source Link

Usage

From source file:controllerPDF.Pdf3DTAlpha.java

private void addHeader() throws DocumentException {
    Paragraph paragraph = new Paragraph("3D&T - Defensores de Tquio 3 Edio Alpha");
    paragraph.setFont(new Font(FontFamily.TIMES_ROMAN, 15, Font.BOLD, BaseColor.BLACK));
    paragraph.setAlignment(1);/*from  w  w w  . j  av a2 s .com*/
    document.add(paragraph);
    paragraph = new Paragraph("FICHA DE PERSONAGEM");
    paragraph.setFont(new Font(FontFamily.TIMES_ROMAN, 15, Font.BOLD, BaseColor.BLUE));
    document.add(paragraph);

}

From source file:cz.zcu.kiv.eegdatabase.logic.pdf.PDFUtils.java

License:Apache License

public Paragraph setHeader(Document document, String title) throws IOException, BadElementException {
    Paragraph paragraph = new Paragraph(title,
            FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLD, BaseColor.BLACK));
    paragraph.setAlignment(Element.ALIGN_CENTER);

    Image img = GetResizedAndCenteredImage(path + convertPath("/files/images/" + HEADERIMG));
    float topMargin = img.getHeight() + 2 * PADDING[0];
    img.setAbsolutePosition(PADDING[3], (PageSize.A4.getHeight() - img.getHeight()) - PADDING[0]);
    paragraph.add(img);//from   w ww . j  a va 2 s  .c  o  m
    img = GetResizedAndCenteredImage(path + convertPath("/files/images/" + FOOTERIMG));
    img.setAbsolutePosition((PageSize.A4.getWidth() - img.getWidth()) / 2, PADDING[2]);
    paragraph.add(img);
    float bottomMargin = img.getHeight() + 2 * PADDING[2];

    document.setMargins(topMargin, PADDING[1], bottomMargin, PADDING[3]);

    paragraph.setSpacingAfter(1.5f * PADDING[0]);

    return paragraph;
}

From source file:cz.zcu.kiv.eegdatabase.logic.pdf.ReservationPDF.java

License:Apache License

public static PdfPTable formatReservation(Reservation reservation) {
    int padding = 5;

    GregorianCalendar created = new GregorianCalendar();
    created.setTime(reservation.getCreationTime());
    GregorianCalendar startTime = new GregorianCalendar();
    startTime.setTime(reservation.getStartTime());
    GregorianCalendar endTime = new GregorianCalendar();
    endTime.setTime(reservation.getEndTime());

    String personName = BookingRoomUtils.formatPersonName(reservation.getPerson());

    Font title = FontFactory.getFont("Trebuchet MS", "utf-8", 15, Font.BOLD, new BaseColor(59, 70, 00));
    Font header = FontFactory.getFont(FontFactory.TIMES_BOLD, 13, Font.BOLD, BaseColor.BLACK);
    Font value = FontFactory.getFont(FontFactory.TIMES, 13);

    PdfPTable table = new PdfPTable(2);
    PdfPCell cell;/*from  ww  w . j  ava2s .  c o  m*/
    Phrase phrase;

    phrase = new Phrase("Reservation by " + personName);
    phrase.setFont(title);
    cell = new PdfPCell(phrase);
    cell.setColspan(2);
    cell.setBorder(0);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorderWidthTop(1);
    cell.setBorderWidthLeft(1);
    cell.setBorderWidthRight(1);
    cell.setPadding(padding);
    cell.setPaddingBottom(5);
    table.addCell(cell);

    phrase = new Phrase("Date: ");
    phrase.setFont(header);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthLeft(1);
    cell.setPadding(padding);
    table.addCell(cell);

    phrase = new Phrase(BookingRoomUtils.getDate(startTime));
    phrase.setFont(value);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthRight(1);
    cell.setPadding(padding);
    table.addCell(cell);

    phrase = new Phrase("Start: ");
    phrase.setFont(header);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthLeft(1);
    cell.setPadding(padding);
    table.addCell(cell);

    phrase = new Phrase(BookingRoomUtils.getHoursAndMinutes(startTime));
    phrase.setFont(value);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthRight(1);
    cell.setPadding(padding);
    table.addCell(cell);

    phrase = new Phrase("End: ");
    phrase.setFont(header);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthLeft(1);
    cell.setBorderWidthBottom(1);
    cell.setPadding(padding);
    table.addCell(cell);

    phrase = new Phrase(BookingRoomUtils.getHoursAndMinutes(endTime));
    phrase.setFont(value);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthRight(1);
    cell.setBorderWidthBottom(1);
    cell.setPadding(padding);
    table.addCell(cell);

    table.setSpacingBefore(10);
    table.setSpacingAfter(10);

    return table;
}

From source file:dbms.Bills1Controller.java

@FXML
void OnMouseClick(ActionEvent event)
        throws ClassNotFoundException, SQLException, FileNotFoundException, DocumentException {
    int c = check(phone_no.getText());
    int c1 = phone_no.getText().length();
    String s1 = product_id.getText();
    String s3 = cb1.getSelectionModel().getSelectedItem();
    String s7 = cb2.getSelectionModel().getSelectedItem();
    int s8 = cb3.getSelectionModel().getSelectedItem();
    String s2 = cust_name.getText();
    String s4 = address.getText();
    String s6 = date.getValue().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    String s5 = phone_no.getText();
    String s10 = total.getText();
    String s11 = cb4.getSelectionModel().getSelectedItem();
    String s12 = payment.getText();
    int to = Integer.parseInt(s10);

    if (c == 0 || c1 != 10 || total.getText().equals("") || cust_name.getText().equals("")
            || address.getText().equals("") || payment.getText().equals("")) {
        JOptionPane.showMessageDialog(null, "Something is wrong");
    } else {/*from w ww  .j  a  v a 2s .com*/
        try {
            Class.forName("com.mysql.jdbc.Driver");
            java.sql.Connection con = DriverManager
                    .getConnection("jdbc:mysql://localhost/dbms?user=root&password=india123");
            String str1 = "insert into sold_item values(?,?,?,?,?,?,?,?,?,?)";
            //  System.out.println(str1);
            java.sql.PreparedStatement stmt1 = con.prepareStatement(str1);
            stmt1.setString(1, s1);
            stmt1.setString(2, s3);
            stmt1.setString(3, s7);
            stmt1.setInt(4, s8);
            stmt1.setString(5, s2);
            stmt1.setString(6, s4);
            stmt1.setString(7, s5);
            stmt1.setString(8, s6);
            stmt1.setInt(9, to);
            stmt1.setString(10, s11);
            //   ResultSet rs1 = stmt1.executeQuery();
            stmt1.executeUpdate();
            //   con.close();
            JOptionPane.showMessageDialog(null, "Bill Generated");

            String str6 = "select * from sold_item where billid= '" + s1 + "'";
            PreparedStatement stmt2 = con.prepareStatement(str6);
            ResultSet rs = stmt2.executeQuery(str6);
            Document my_bill = new Document();
            PdfWriter.getInstance(my_bill, new FileOutputStream(s1 + ".pdf"));
            my_bill.open();
            Font f1 = new Font(FontFamily.TIMES_ROMAN, 20.0f, Font.BOLD, BaseColor.BLACK);
            Paragraph p2 = new Paragraph("XYZ Electronics", f1);
            p2.setAlignment(Paragraph.ALIGN_CENTER);
            my_bill.add(p2);
            //my_bill.add(Chunk.NEWLINE);
            Paragraph p3 = new Paragraph("BILL", f1);
            p3.setAlignment(Paragraph.ALIGN_CENTER);
            my_bill.add(p3);
            my_bill.add(Chunk.NEWLINE);
            PdfPTable bill_table = new PdfPTable(2);
            PdfPCell table_cell;
            while (rs.next()) {
                bill_table.addCell("Bill ID");
                String dept_id = rs.getString(1);
                table_cell = new PdfPCell(new Phrase(dept_id));
                bill_table.addCell(table_cell);

                bill_table.addCell("Product Type");
                String dept_name = rs.getString(2);
                table_cell = new PdfPCell(new Phrase(dept_name));
                bill_table.addCell(table_cell);

                bill_table.addCell("Product name");
                String dept_pname = rs.getString(3);
                table_cell = new PdfPCell(new Phrase(dept_pname));
                bill_table.addCell(table_cell);

                bill_table.addCell("Quantity");
                int dept_quan = rs.getInt(4);
                table_cell = new PdfPCell(new Phrase("" + dept_quan));
                bill_table.addCell(table_cell);

                bill_table.addCell("Customer Name");
                String manager_id = rs.getString(5);
                table_cell = new PdfPCell(new Phrase(manager_id));
                bill_table.addCell(table_cell);

                bill_table.addCell("Address");
                String location_id = rs.getString(6);
                table_cell = new PdfPCell(new Phrase(location_id));
                bill_table.addCell(table_cell);

                bill_table.addCell("Phone Number");
                String s = rs.getString(7);
                table_cell = new PdfPCell(new Phrase(s));
                bill_table.addCell(table_cell);

                bill_table.addCell("DATE");
                String ss = rs.getString(8);
                table_cell = new PdfPCell(new Phrase(ss));
                bill_table.addCell(table_cell);

                bill_table.addCell("Total");
                int dept_total = rs.getInt(9);
                table_cell = new PdfPCell(new Phrase("Rs. " + dept_total));
                bill_table.addCell(table_cell);

            }
            my_bill.add(bill_table);
            my_bill.add(Chunk.NEWLINE);
            Font f2 = new Font(FontFamily.TIMES_ROMAN, 20.0f, Font.UNDERLINE, BaseColor.BLACK);
            Paragraph p4 = new Paragraph("Manager Signature", f1);
            p4.setAlignment(Paragraph.ALIGN_RIGHT);
            my_bill.add(p4);

            my_bill.close();
            String spl[] = s7.split("-");
            String strr = "select Quantity from " + s3 + " where Company = '" + spl[0] + "' and ProductName = '"
                    + spl[1] + "'";
            PreparedStatement stmt3 = con.prepareStatement(strr);
            ResultSet rs3 = stmt3.executeQuery();
            rs3.next();
            int f = rs3.getInt(1);
            f = f - s8;
            String strr1 = "Update " + s3 + " set Quantity = " + f + " where Company = '" + spl[0]
                    + "' and ProductName = '" + spl[1] + "' ";
            PreparedStatement stmt4 = con.prepareStatement(strr1);
            stmt4.executeUpdate();

            String strr2 = "insert into payment values(?,?)";
            PreparedStatement stmt5 = con.prepareStatement(strr2);
            stmt5.setString(1, product_id.getText());
            stmt5.setString(2, payment.getText());
            stmt5.executeUpdate();
            rs.close();
            stmt2.close();
            con.close();

            product_id.setText("");
            // prdct_name.setText("");
            cust_name.setText("");
            address.setText("");
            phone_no.setText("");
        } catch (DocumentException | HeadlessException | FileNotFoundException | ClassNotFoundException
                | SQLException e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
    }

}

From source file:de.aidger.utils.pdf.ActivityReportConverter.java

License:Open Source License

/**
 * Adds the specific values to the fields in the template.
 *///from  w  w  w  . j  a v  a  2s. com
private void stampFields() {
    form = stamper.getAcroFields();
    try {
        Calendar calendar = Calendar.getInstance();
        BaseFont fieldFont = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, false);
        BaseFont fatFieldFont = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, false);
        form.setFieldProperty("CreatorName", "textfont", fieldFont, null);
        form.setFieldProperty("CreatorName", "textsize", 12.0f, null);
        form.setFieldProperty("CreatorName", "textcolor", BaseColor.BLACK, null);
        form.setField("CreatorName", Runtime.getInstance().getOption("name"));
        form.setFieldProperty("AssistantName", "textfont", fatFieldFont, null);
        form.setFieldProperty("AssistantName", "textsize", 12.0f, null);
        form.setFieldProperty("AssistantName", "textcolor", BaseColor.BLACK, null);
        form.setField("AssistantName", assistant);
        form.setFieldProperty("Date", "textfont", fieldFont, null);
        form.setFieldProperty("Date", "textsize", 12.0f, null);
        form.setFieldProperty("Date", "textcolor", BaseColor.BLACK, null);
        form.setField("Date", DateUtils.formatDate(calendar.getTime()));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:de.beimax.talenttree.AbstractPageGenerator.java

License:Open Source License

/**
 * add footer information to page, copyright, etc.
 *//*w w  w  .  j a v a  2 s .  co  m*/
protected void addFooter() throws Exception {
    // draw legend text
    canvas.beginText();
    canvas.setFontAndSize(generator.getFontRegular(), 6f);
    canvas.setColorFill(BaseColor.BLACK);
    canvas.showTextAligned(Element.ALIGN_LEFT, getLocalizedString("copyright"), getLeftX(),
            PDFGenerator.marginVertical, 0);
    canvas.showTextAligned(Element.ALIGN_RIGHT,
            "Version " + getLocalizedString("version") + "  " + getLocalizedString("date") + "  "
                    + getLocalizedString("game") + "  http://auxc.de/18w",
            getRightX(), PDFGenerator.marginVertical, 0);
    canvas.endText();
}

From source file:de.beimax.talenttree.PageGeneratorForce.java

License:Open Source License

/**
 * Add help/legend//from   w w w. j a va2 s.  com
 * @throws Exception
 */
protected void addLegend() throws Exception {
    canvas.saveState();

    // draw arrows
    float x = getRightX();
    float y = getTopY() - 20;

    drawLegendArrow(PDFGenerator.passiveColor, x, y);

    // draw ranked
    drawRanked(PDFGenerator.passiveColor, x, y - 15);

    canvas.restoreState();

    // draw legend text
    canvas.beginText();
    canvas.setFontAndSize(generator.getFontRegular(), 10f);
    canvas.setColorFill(BaseColor.BLACK);
    canvas.showTextAligned(Element.ALIGN_RIGHT, getLocalizedString("ForcePowerWedge"), x - 20, y - 7, 0);
    canvas.showTextAligned(Element.ALIGN_RIGHT, getLocalizedString("Ranked"), x - 20, y - 24, 0);
    canvas.endText();
}

From source file:de.beimax.talenttree.PageGeneratorSignature.java

License:Open Source License

/**
 * Add help/legend/*from w ww. j a v  a  2  s  .  c  o m*/
 * @throws Exception
 */
protected void addLegend() throws Exception {
    canvas.saveState();

    // draw arrows
    float x = getRightX();
    float y = getTopY() - 20;

    drawLegendArrow(PDFGenerator.activeColor, x, y);
    drawLegendArrow(PDFGenerator.passiveColor, x, y - 15);

    // draw ranked
    drawRanked(PDFGenerator.passiveColor, x, y - 30);

    canvas.restoreState();

    // draw legend text
    canvas.beginText();
    canvas.setFontAndSize(generator.getFontRegular(), 10f);
    canvas.setColorFill(BaseColor.BLACK);
    canvas.showTextAligned(Element.ALIGN_RIGHT, getLocalizedString("BaseAbility"), x - 20, y - 7, 0);
    canvas.showTextAligned(Element.ALIGN_RIGHT, getLocalizedString("Upgrade"), x - 20, y - 22, 0);
    canvas.showTextAligned(Element.ALIGN_RIGHT, getLocalizedString("Ranked"), x - 20, y - 37, 0);
    canvas.endText();
}

From source file:de.beimax.talenttree.PageGeneratorSimple.java

License:Open Source License

/**
 * Add help/legend//from  www .  j av  a2s  .co  m
 * @throws Exception
 */
protected void addLegend() throws Exception {
    canvas.saveState();

    // draw arrows
    float x = getRightX();
    float y = getTopY() - 20;

    drawLegendArrow(PDFGenerator.activeColor, x, y);
    drawLegendArrow(PDFGenerator.passiveColor, x, y - 15);

    // draw ranked
    drawRanked(PDFGenerator.passiveColor, x, y - 30);

    canvas.restoreState();

    // draw legend text
    canvas.beginText();
    canvas.setFontAndSize(generator.getFontRegular(), 10f);
    canvas.setColorFill(BaseColor.BLACK);
    canvas.showTextAligned(Element.ALIGN_RIGHT, getLocalizedString("Active"), x - 20, y - 7, 0);
    canvas.showTextAligned(Element.ALIGN_RIGHT, getLocalizedString("Passive"), x - 20, y - 22, 0);
    canvas.showTextAligned(Element.ALIGN_RIGHT, getLocalizedString("Ranked"), x - 20, y - 37, 0);
    canvas.endText();
}

From source file:de.beimax.talenttree.PageGeneratorSimple.java

License:Open Source License

/**
 * Add single talent in box//from   www .ja  v a 2 s. c  o m
 * @param row row to print talent in
 * @param col column to print talent in
 * @param key key for talent information
 * @param multiCols span multiple columns or 1
 * @param customCost custom cost of talent (instead of default) - 0 means box will not be printed
 */
protected void addTalent(int row, int col, String key, int multiCols, int customCost) throws Exception {
    // get data
    HeaderProperties headerProperties = parseHeaderProperty(key);

    // define color
    BaseColor bgColor = headerProperties.active ? PDFGenerator.activeColor : PDFGenerator.passiveColor;
    boolean headerTwoLine = headerProperties.title.contains("\n");

    // calculate offsets
    float x = calculateColOffset(col);
    float y = calculateRowOffset(row);

    // sanity check for multiple columns
    if (multiCols < 1)
        multiCols = 1;
    else if (multiCols > 4)
        multiCols = 4;

    // box width and height
    float talentBoxWidth = PDFGenerator.talentBoxWidth * multiCols
            + calculateHorizontalSpacing() * (multiCols - 1);
    float talentBoxHeight = PDFGenerator.talentBoxHeight;

    // draw shapes
    canvas.saveState();
    // draw outer rectangle
    drawTalentRectangle(bgColor, x, y, talentBoxWidth, talentBoxHeight);
    // draw left footer shape
    float yFooterBoxOffset = y - talentBoxHeight + PDFGenerator.talentBoxStroke;
    if (customCost != 0) {
        drawFooterShape(bgColor, x + PDFGenerator.wedgeOffset + PDFGenerator.talentBoxStroke,
                y - talentBoxHeight + PDFGenerator.talentBoxStroke, 25);
    }
    // draw right footer shape
    drawFooterShape(bgColor, x + talentBoxWidth - PDFGenerator.wedgeOffset - PDFGenerator.talentBoxStroke - 50,
            y - talentBoxHeight + PDFGenerator.talentBoxStroke, 50);
    // draw header shape
    drawHeaderShape(bgColor, x + PDFGenerator.talentBoxStroke * 2.5f, y - PDFGenerator.talentBoxStroke * 2.5f,
            talentBoxWidth - PDFGenerator.talentBoxStroke * 5, headerTwoLine, headerProperties.status);
    canvas.restoreState();

    // draw text
    canvas.beginText();
    canvas.setColorFill(BaseColor.WHITE);
    // title
    canvas.setFontAndSize(generator.getFontHeader(), 13);
    float offSetYTalentText;
    if (headerTwoLine) {
        String[] parts = headerProperties.title.split("\\n");
        canvas.showTextAligned(Element.ALIGN_LEFT, parts[0], x + PDFGenerator.talentBoxStroke * 3.5f,
                y - PDFGenerator.talentBoxStroke * 2 - 14f, 0);
        canvas.showTextAligned(Element.ALIGN_LEFT, parts[1], x + PDFGenerator.talentBoxStroke * 3.5f,
                y - PDFGenerator.talentBoxStroke * 2 - 27f, 0);
        offSetYTalentText = y - PDFGenerator.talentBoxStroke * 2 - 28f;
    } else {
        canvas.showTextAligned(Element.ALIGN_LEFT, headerProperties.title,
                x + PDFGenerator.talentBoxStroke * 3.5f, y - PDFGenerator.talentBoxStroke * 2 - 14f, 0);
        offSetYTalentText = y - PDFGenerator.talentBoxStroke * 2 - 15f;
    }
    // mini text
    canvas.setFontAndSize(generator.getFontBold(), 6.25f);
    float textOffsetY = yFooterBoxOffset + 8 - 6.25f / 2 + 0.5f;
    // draw page
    canvas.showTextAligned(Element.ALIGN_CENTER, headerProperties.page,
            x + PDFGenerator.wedgeOffset + PDFGenerator.talentBoxStroke + 25f / 2, textOffsetY, 0);
    // draw costs
    if (customCost != 0) {
        if (customCost == -1)
            customCost = (row + 1) * 5;
        canvas.showTextAligned(Element.ALIGN_LEFT, getLocalizedString("Cost") + " " + customCost,
                x + talentBoxWidth - PDFGenerator.talentBoxStroke - 50, textOffsetY, 0);
    }
    canvas.endText();

    // draw talent text
    canvas.setColorFill(BaseColor.BLACK);
    PdfPTable table = getTalentCell(key, talentBoxWidth, 9f);
    // too large?
    float max = y - talentBoxHeight;
    if (table.getRowHeight(0) > offSetYTalentText - max - 2 * PDFGenerator.wedgeOffset)
        table = getTalentCell(key, talentBoxWidth, 8.5f); // create smaller cell
    if (table.getRowHeight(0) > offSetYTalentText - max - 2 * PDFGenerator.wedgeOffset)
        table = getTalentCell(key, talentBoxWidth, 7.5f); // create tiny cell
    table.writeSelectedRows(0, -1, x + PDFGenerator.talentBoxStroke * 1.5f, offSetYTalentText, canvas);
}