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:com.devox.GUI.PDF.CrearReporteDestruccion.java

@Override
public PdfPTable crearTabla() {
    PdfPTable table = new PdfPTable(6);
    PdfPCell cell;//from  ww  w  . j  av a 2  s  . co m
    cell = new PdfPCell(new Phrase("DESCRIPCIN", FUENTE_CABECERA_TABLA_CHICA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setFixedHeight(20f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("LOTE", FUENTE_CABECERA_TABLA_CHICA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("CDIGO", FUENTE_CABECERA_TABLA_CHICA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("CANTIDAD", FUENTE_CABECERA_TABLA_CHICA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("PRECIO UNITARIO", FUENTE_CABECERA_TABLA_CHICA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("SUBTOTAL", FUENTE_CABECERA_TABLA_CHICA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(AMARILLO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    try {
        table.setWidths(new float[] { 5f, 2f, 3f, 1.2f, 1.4f, 1.5f });
        table.setWidthPercentage(98);

    } catch (DocumentException ex) {
        Log.print(ex);
    }
    return table;

}

From source file:com.devox.GUI.PDF.CrearReportePorEstado.java

@Override
public PdfPTable crearTabla() {
    PdfPTable table = new PdfPTable(2);
    PdfPCell cell;//from w ww .  j  a  va2  s  .  com
    cell = new PdfPCell(new Phrase("FOLIO DHL", FUENTE_CABECERA_TABLA_MEDIANA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setFixedHeight(20f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("DESTINO", FUENTE_CABECERA_TABLA_MEDIANA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    return table;
}

From source file:com.devox.GUI.PDF.CrearReporteTarimas.java

@Override
public PdfPTable crearTabla() {
    PdfPTable table = new PdfPTable(4);
    PdfPCell cell;//from  w  w  w .j a v  a 2s. c o m
    cell = new PdfPCell(new Phrase("FOLIO DHL", FUENTE_CABECERA_TABLA_MEDIANA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setFixedHeight(20f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("PRODUCTO (Descripcin)", FUENTE_CABECERA_TABLA_MEDIANA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("CDIGO INTERNO", FUENTE_CABECERA_TABLA_MEDIANA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("CANTIDAD", FUENTE_CABECERA_TABLA_MEDIANA));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    try {
        table.setWidths(new float[] { 1f, 1.5f, 2.5f, 1f });
        table.setWidthPercentage(100);

    } catch (DocumentException ex) {
        Log.print(ex);
    }
    return table;
}

From source file:com.devox.GUI.PDF.ExportarAPDF.java

private static PdfPTable createTable() {
    PdfPTable table = new PdfPTable(6);
    PdfPCell cell;/*from   www .j a  v  a2s .co m*/
    cell = new PdfPCell(new Phrase("DESCRIPCIN", font_headertable1));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setFixedHeight(20f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("LOTE", font_headertable1));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("CDIGO", font_headertable1));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("CANTIDAD", font_headertable1));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("PRECIO UNITARIO", font_headertable1));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("SUBTOTAL", font_headertable1));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(AMARILLO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    try {
        table.setWidths(new float[] { 5f, 2f, 3f, 1.2f, 1.4f, 1.5f });
        table.setWidthPercentage(98);

    } catch (DocumentException ex) {
        Log.print(ex);
        Log.print(ex);
    }
    return table;
}

From source file:com.devox.GUI.PDF.ExportarAPDF.java

private static PdfPTable createSigningTable() {
    PdfPTable table = new PdfPTable(4);
    PdfPCell cell;//from   w w w.  j av  a2  s .c o  m
    cell = new PdfPCell(new Phrase("RMA", font_headertable2));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setFixedHeight(25f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("ORDEN", font_headertable2));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("ELABOR", font_headertable2));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("DICTAMIN QA", font_headertable2));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("  "));
    cell.setFixedHeight(50f);
    for (int i = 0; i < 4; i++) {
        table.addCell(cell);
    }

    cell = new PdfPCell(new Phrase("  "));
    cell.setFixedHeight(25f);
    cell.setBackgroundColor(GRIS_CLARO);
    for (int i = 0; i < 2; i++) {
        table.addCell(cell);
    }

    cell = new PdfPCell(new Phrase("NOMBRE Y FIRMA", font_table));
    cell.setFixedHeight(25f);
    cell.setBackgroundColor(GRIS_CLARO);
    for (int i = 0; i < 2; i++) {
        table.addCell(cell);
    }

    table.setTotalWidth(500);
    return table;
}

From source file:com.devox.GUI.PDF.ExportarAPDF.java

private PdfPTable createTableTarimas() {
    PdfPTable table = new PdfPTable(4);
    PdfPCell cell;// w  ww. j  av a  2  s. c  om
    cell = new PdfPCell(new Phrase("FOLIO DHL", font_headertable1));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setFixedHeight(20f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("PRODUCTO (Descripcin)", font_headertable1));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("CDIGO INTERNO", font_headertable1));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("CANTIDAD", font_headertable1));
    cell.setBackgroundColor(AMARILLO);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderColorLeft(GRIS_CLARO);
    cell.setBorderColorRight(GRIS_CLARO);
    cell.setBorderColorTop(AMARILLO);
    table.addCell(cell);

    try {
        table.setWidths(new float[] { 1f, 1.5f, 2.5f, 1f });
        table.setWidthPercentage(100);

    } catch (DocumentException ex) {
        Log.print(ex);
        Log.print(ex);
    }
    return table;
}

From source file:com.github.luischavez.levsym.modulos.funcion.PDF.java

License:Open Source License

public void GeneraPDF(ResultSet Resultados) throws Exception {

    ResultSetMetaData metaData = Resultados.getMetaData();
    Object[] Columnas = new Object[metaData.getColumnCount()];

    String encabezado = "Reportes del Sistema Administrativo" + "\n" + "REGISTROS ACTUALES EN AL BASE DE DATOS"
            + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n";
    Calendar c = Calendar.getInstance();
    String date = Integer.toString(c.get(Calendar.DAY_OF_MONTH)) + "-" + Integer.toString(c.get(Calendar.MONTH))
            + "-" + Integer.toString(c.get(Calendar.YEAR)) + " " + Integer.toString(c.get(Calendar.HOUR_OF_DAY))
            + "-" + Integer.toString(c.get(Calendar.MINUTE)) + "-" + Integer.toString(c.get(Calendar.SECOND));

    Font fuente = new Font(Font.getFamily("ARIAL"), 12, Font.BOLD);

    String choro = "Reporte por fecha de los modulos\n" + "de catalogo" + "\n" + "Systema Administrativo" + "\n"
            + "\n" + "\n" + "\n";

    Image imagen = Image.getInstance(System.getProperty("user.dir") + "/Image/logo.png");
    imagen.setAlignment(Image.TEXTWRAP);

    try {/*from w  w w .  ja va  2 s. c om*/
        Paragraph linea = new Paragraph(encabezado, fuente);
        Phrase para = new Phrase(choro);
        Paragraph fecha = new Paragraph(date + "\n" + "\n");

        PdfPTable tabla = new PdfPTable(Columnas.length);
        tabla.setWidthPercentage(100);

        //Document documento = new Document(PageSize.LETTER);
        Document documento = new Document(PageSize.A4.rotate(), 50, 50, 100, 72);
        File Dir = new File(System.getProperty("user.dir") + "/Reportes/");
        if (!Dir.exists()) {
            Dir.mkdirs();
        }

        String file = System.getProperty("user.dir") + "/Reportes/" + metaData.getTableName(1) + " " + date
                + ".pdf";

        PdfWriter.getInstance(documento, new FileOutputStream(file));

        documento.open();
        documento.add(imagen);
        documento.add(linea);
        documento.add(para);
        documento.add(fecha);

        for (int x = 0; x < Columnas.length; x++) {
            PdfPCell Celda = new PdfPCell(new Paragraph(metaData.getColumnName(x + 1),
                    FontFactory.getFont("arial", 9, Font.BOLD, BaseColor.RED)));
            Celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(Celda);
        }

        while (Resultados.next()) {
            for (int x = 0; x < Columnas.length; x++) {
                //if(Resultados.getObject(x+1).getClass().getSimpleName().equals("Integer"))
                PdfPCell Celda = new PdfPCell(new Paragraph(String.valueOf(Resultados.getObject(x + 1)),
                        FontFactory.getFont("arial", 9, BaseColor.BLACK)));
                Celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabla.addCell(Celda);
            }
        }

        documento.add(tabla);
        documento.close();
    } catch (DocumentException e) {
        Log.SaveLog(e.toString());
        JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    } catch (IOException e) {
        Log.SaveLog(e.toString());
        JOptionPane.showMessageDialog(null, e.getMessage(), "error", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:com.github.ossdevs.jhocr.converter.HocrPageProcessor.java

License:Open Source License

/**
 * TODO describe this method.//from w w w .  j a  v a 2  s.c  om
 *
 * @param imageInputStream of the image.
 * @return true if the initialisation was successful.
 */
private boolean init(InputStream imageInputStream) {

    boolean result = false;

    try {

        /**
         * fontname the name of the font
         * encoding the encoding of the font
         * embedded true if the font is to be embedded in the PDF
         * size the size of this font
         * style the style of this font
         * color the BaseColor of this font.
         */
        font = FontFactory.getFont("/fonts/Sansation_Regular.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 0.8f,
                Font.NORMAL, BaseColor.BLACK);
        baseFont = font.getBaseFont();
        logger.trace("Loaded font: '{}'.", baseFont.getPostscriptFontName());

        byte[] bytes = new byte[imageInputStream.available()];

        imageInputStream.read(bytes);

        this.image = Image.getInstance(bytes);

        int dpiX, dpiY;

        /**
         * TODO add documentation, for example what if and what else
         */
        if (useImageDpi) {
            dpiX = getImage().getDpiX();
            if (dpiX == 0) {
                dpiX = DPI_DEFAULT;
            }
            dpiY = getImage().getDpiY();
            if (dpiY == 0) {
                dpiY = DPI_DEFAULT;
            }

        } else {
            dpiX = DPI_DEFAULT;
            dpiY = DPI_DEFAULT;
        }

        this.dotsPerPointX = dpiX / HocrToPdf.POINTS_PER_INCH;
        this.dotsPerPointY = dpiY / HocrToPdf.POINTS_PER_INCH;

        /**
         * TODO add documentation
         * TODO simplify this line, too many arguments.
         */
        this.imageRectangle = new Rectangle(getHocrPage().getBbox().getWidth() / getDotsPerPointX(),
                getHocrPage().getBbox().getHeight() / getDotsPerPointY());

        result = true;

    } catch (DocumentException e) {
        logger.error("Error while processing the document, please check th elog for more information.", e);
        result = false;
    } catch (IOException e) {
        logger.error("Error while processing the document, please check th elog for more information.", e);
        result = false;
    }

    return result;

}

From source file:com.github.wolfposd.imsqti2pdf.PDFCreator.java

License:Open Source License

private void addQuestionText(Paragraph paragraph, Question question, int questionnumber) throws IOException {
    String fixedFonts = question.questiontext.replace("font-size: 12pt", "font-size: 10pt");

    fixedFonts = fixedFonts.replace("face=\"courier new\"", "face=\"Courier\"");

    fixedFonts = fixedFonts.replace("src=\"media/", getPathToMedia());

    ArrayList<Element> htmllist = (ArrayList<Element>) HTMLWorker.parseToList(new StringReader(fixedFonts),
            null);//from  w  ww .ja  va2 s.co  m

    ArrayList<Paragraph> codeParagraphs = new ArrayList<Paragraph>();

    for (int i = 0; i < htmllist.size(); i++) {
        Element e = htmllist.get(i);
        if (e instanceof Paragraph) {
            Paragraph p = (Paragraph) e;
            if (i == 0) {
                p.setIndentationLeft(INDENTATION);
                p.getFont().setSize(OVERALLFONTSIZE);
                p.add(0, getQuestionNumberChunk(p.getFont(), questionnumber));
                p.add(getPointsChunk(p.getFont(), question));
                paragraph.add(p);
            } else {
                codeParagraphs.add(p);
            }
        }
    }
    if (codeParagraphs.size() > 0) {
        PdfPTable table = new PdfPTable(1);
        table.setWidthPercentage(90);
        table.setKeepTogether(true);

        Paragraph codeParagraph = new Paragraph();

        for (Paragraph p : codeParagraphs) {
            p.setIndentationLeft(INDENTATION);
            p.getFont().setSize(OVERALLFONTSIZE);
            codeParagraph.add(p);
            fixFonts(p);
        }
        codeParagraph.add(Chunk.NEWLINE);

        PdfPCell cell = new PdfPCell();
        cell.addElement(codeParagraph);
        cell.setBorderColor(BaseColor.BLACK);
        table.addCell(cell);

        paragraph.add(Chunk.NEWLINE);
        paragraph.add(table);
    }
}

From source file:com.innoviu.signature.Signature.java

public static void main(String[] args) {
    boolean isEncrypted = false;
    boolean isFailed = false;
    try {/*  w  w  w  . j  av  a 2 s  . c  o  m*/
        if (args.length < 2) {
            throw new FileNotFoundException();
        }
        PdfReader reader = new PdfReader(args[0]);
        isEncrypted = reader.isEncrypted();
        String suffix = ".pdf";
        if (isEncrypted) {
            System.out.println("Encrypted");
            String[] cmd = { "pdftk", args[0], "output", args[0] + ".pdftk.pdf" };
            try {
                Process proc = Runtime.getRuntime().exec(cmd);
                proc.waitFor();
            } catch (Exception e) {
                System.out.println("Exception is:" + e);
            }
            reader = new PdfReader(args[0] + ".pdftk.pdf");
            suffix = ".dec.pdf";
        }
        PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(args[0] + suffix));
        PdfContentByte over = stamper.getOverContent(1);
        String type = args[2];
        int xpos = 0;
        //int xpos = (type == "in") ? 120 : 10;
        if ("in".equals(type)) {
            xpos = 0;
        } else {
            xpos = 120;
        }
        over.setColorFill(BaseColor.WHITE);
        over.rectangle(xpos + 10, 8, 120, 8);
        over.fill();
        over.beginText();
        BaseFont bf_times = BaseFont.createFont(BaseFont.TIMES_ROMAN, "Cp1252", false);
        over.setFontAndSize(bf_times, 6);
        over.setColorFill(BaseColor.BLACK);
        over.showTextAligned(PdfContentByte.ALIGN_RIGHT, args[1], 120 + xpos, 10, 0);
        over.endText();
        stamper.close();
        if (isEncrypted) {
            File file = new File(args[0] + ".pdftk.pdf");
            file.delete();
        }
    } catch (FileNotFoundException e) {
        isFailed = true;
        e.printStackTrace();
    } catch (DocumentException e) {
        isFailed = true;
        e.printStackTrace();
    } catch (IOException e) {
        isFailed = true;
        e.printStackTrace();
    } finally {
        if (isEncrypted) {
            maintain(args[0]);
        } else if (isFailed) {
            fail(args[0]);
        } else {

        }
    }
}