Example usage for com.itextpdf.text Font BOLDITALIC

List of usage examples for com.itextpdf.text Font BOLDITALIC

Introduction

In this page you can find the example usage for com.itextpdf.text Font BOLDITALIC.

Prototype

int BOLDITALIC

To view the source code for com.itextpdf.text Font BOLDITALIC.

Click Source Link

Document

this is a possible style.

Usage

From source file:Modelo.DAO.InformeDAO.java

public String generaPDF(String Diagnostico, String Tratamiento, String Datos, Integer idPaciente,
        Integer idPersona, Paciente paciente) throws FileNotFoundException, DocumentException, IOException {

    Calendar cal = Calendar.getInstance();
    String time = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(cal.getTime());
    String timename = new SimpleDateFormat("yyyyMMddHHmm").format(cal.getTime());

    File file = new File("informe" + timename + ".pdf");
    FileOutputStream fileout = new FileOutputStream(file);
    Document document = new Document();
    PdfWriter writer;//from  w w  w. j a  v  a 2  s  .  c o  m
    writer = PdfWriter.getInstance(document, fileout);

    Font fuente = new Font();
    Font fuente2 = new Font();
    Font fuente3 = new Font();

    // fuente.setColor(BaseColor.BLUE);
    fuente.setStyle(Font.UNDERLINE | Font.BOLDITALIC);
    fuente2.setStyle(Font.BOLD);
    fuente2.setSize(12);
    fuente3.setSize(20);
    fuente3.setStyle(Font.BOLD);

    document.open();
    document.add(new Paragraph("\n \n \n \n \n"));
    document.add(new Paragraph("Clnica Mdica INFTEL", fuente3));

    String imageUrl = "src/Imagen/logo.png";
    //  String imagen="src\Imagen\logo.png"; 
    Image image = Image.getInstance(imageUrl);
    image.setAbsolutePosition(300, 750);
    image.scalePercent(80f);
    document.add(image);

    document.add(new Paragraph(" "));
    document.add(new Paragraph("---------------------"));

    document.add(new Paragraph("DATOS DEL PACIENTE", fuente));
    document.add(new Paragraph(" "));
    document.add(
            new Paragraph("Apellidos y Nombre : " + paciente.getApellidos() + ", " + paciente.getNombre()));
    document.add(new Paragraph("NIF : " + paciente.getNif()));
    document.add(new Paragraph("NSS : " + paciente.getNumSS()));
    document.add(new Paragraph("Direccion : " + paciente.getDireccion()));
    document.add(new Paragraph("Telefono : " + paciente.getTelefono()));
    document.add(new Paragraph("Email : " + paciente.getEmail()));
    document.add(new Paragraph("ID Paciente : " + idPaciente));

    document.add(new Paragraph(" "));
    document.add(new Paragraph("---------------------"));
    document.add(new Paragraph(" "));

    document.add(new Paragraph("DATOS CL?NICOS", fuente));
    document.add(new Paragraph(" "));

    document.add(new Paragraph("Diagnstico : ", fuente2));
    document.add(new Paragraph(Diagnostico));
    document.add(new Paragraph(" "));

    document.add(new Paragraph("Tratamiento : ", fuente2));
    document.add(new Paragraph(Tratamiento));
    document.add(new Paragraph(" "));

    document.add(new Paragraph("Datos : ", fuente2));
    document.add(new Paragraph(Datos));
    document.add(new Paragraph(" "));

    absText(writer, time, 450, 50);

    document.close();

    File myFile = new File("informe" + timename + ".pdf");
    Desktop.getDesktop().open(myFile);

    return myFile.toString();

}

From source file:nwk.com.br.documents.OrcamentoPdf.java

private PdfPTable dadosRodape(Orcamento orcamento) throws Exception {
    //tabela que pega com 100% do tamanho do arquivo, alinhada no centro com tres colunas e sem bordas
    PdfPTable rodape = new PdfPTable(new float[] { 0.5f, 0.2f, 0.3f });
    rodape.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento
    rodape.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    rodape.getDefaultCell().setBorder(0);

    PdfPCell obs = new PdfPCell(new Paragraph("\n\n Observaes:\n" + orcamento.getObservacoes(), f));
    PdfPCell ass = new PdfPCell(new Paragraph("\n\n_________________________\nAssinatura", f));

    Font fonteAviso = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLDITALIC);

    PdfPCell spc = new PdfPCell(new Paragraph(" "));
    PdfPCell aviso = new PdfPCell(new Paragraph(
            "AGRADEEMOS A PREFERNCIA\nORAMENTO VALIDO SOMENTE PARA O DIA DE SUA CRIAO!", fonteAviso));

    aviso.setHorizontalAlignment(Element.ALIGN_CENTER);
    obs.setHorizontalAlignment(Element.ALIGN_LEFT);
    ass.setHorizontalAlignment(Element.ALIGN_CENTER);

    obs.setBorder(0);/*from ww w .j  a v  a  2  s  .  co  m*/
    ass.setBorder(0);
    spc.setBorder(0);
    aviso.setBorder(0);

    spc.setColspan(3);
    aviso.setColspan(3);

    rodape.addCell(obs);
    rodape.addCell(new Paragraph(" "));
    rodape.addCell(ass);
    rodape.addCell(spc);
    rodape.addCell(spc);
    rodape.addCell(spc);
    rodape.addCell(spc);
    rodape.addCell(aviso);
    //rodape.setExtendLastRow(true);

    //cria uma nova celula que recebe a tabela anterior
    PdfPCell otherCell = new PdfPCell(rodape);
    otherCell.setBorder(0);
    otherCell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    otherCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    //cria uma nova tabela que recebe a celula otherCell
    PdfPTable rodape2 = new PdfPTable(new float[] { 1.0f });
    rodape2.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento

    rodape2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    rodape2.getDefaultCell().setBorder(0);

    //estende a tabela at o fim da pagina, como o alinhamento horizontal dela  bottom, ela fica toda no rodape
    rodape2.addCell(otherCell);
    rodape2.setExtendLastRow(true);

    return rodape2;
}

From source file:org.flowable.app.rest.runtime.RelatedContentResource.java

License:Apache License

void createPdf(String dest, ArrayList<String> info) throws IOException, DocumentException {
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream(dest));
    document.open();/*w  ww . ja v a  2 s  .  c o  m*/
    Font chapterFont = FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLDITALIC);
    Font paragraphFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL);
    Chunk chunk = new Chunk("Relatrio", chapterFont);
    Chapter chapter = new Chapter(new Paragraph(chunk), 1);
    chapter.setNumberDepth(0);

    int i = 0;
    for (; i < info.size(); i++) {
        chapter.add(new Paragraph(info.get(i), paragraphFont));
    }
    document.add(chapter);
    document.close();
}

From source file:org.jaqpot.core.service.data.ReportService.java

public void report2PDF(Report report, OutputStream os) {

    Document document = new Document();
    document.setPageSize(PageSize.A4);//from  w w w .  j av a2s  .  c  om
    document.setMargins(50, 45, 80, 40);
    document.setMarginMirroring(false);

    try {
        PdfWriter writer = PdfWriter.getInstance(document, os);
        TableHeader event = new TableHeader();
        writer.setPageEvent(event);

    } catch (DocumentException ex) {
        throw new InternalServerErrorException(ex);
    }

    document.open();

    /** setup fonts for pdf */
    Font ffont = new Font(Font.FontFamily.UNDEFINED, 9, Font.ITALIC);
    Font chapterFont = FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLDITALIC);
    Font paragraphFontBold = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
    Font paragraphFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL);
    Font tableFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);

    /** print link to jaqpot*/
    Chunk chunk = new Chunk(
            "This report has been automatically created by the JaqpotQuatro report service. Click here to navigate to our official webpage",
            ffont);
    chunk.setAnchor("http://www.jaqpot.org");

    Paragraph paragraph = new Paragraph(chunk);
    paragraph.add(Chunk.NEWLINE);

    Chapter chapter = new Chapter(paragraph, 1);
    chapter.setNumberDepth(0);

    /** get title */
    String title = null;
    if (report.getMeta() != null && report.getMeta().getTitles() != null
            && !report.getMeta().getTitles().isEmpty())
        title = report.getMeta().getTitles().iterator().next();

    /** print title aligned centered in page */
    if (title == null)
        title = "Report";
    chunk = new Chunk(title, chapterFont);
    paragraph = new Paragraph(chunk);
    paragraph.setAlignment(Element.ALIGN_CENTER);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(Chunk.NEWLINE);

    chapter.add(paragraph);

    /** report Description */
    if (report.getMeta() != null && report.getMeta().getDescriptions() != null
            && !report.getMeta().getDescriptions().isEmpty()
            && !report.getMeta().getDescriptions().toString().equalsIgnoreCase("null")) {
        paragraph = new Paragraph();
        paragraph.add(new Chunk("Description: ", paragraphFontBold));
        paragraph.add(new Chunk(report.getMeta().getDescriptions().toString().replaceAll(":http", ": http"),
                paragraphFont));
        chapter.add(paragraph);
        chapter.add(Chunk.NEWLINE);
    }

    /** report model, algorithm and/or dataset id */
    if (report.getMeta() != null && report.getMeta().getHasSources() != null
            && !report.getMeta().getHasSources().isEmpty() && !report.getMeta().getDescriptions().isEmpty()
            && !report.getMeta().getDescriptions().toString().equalsIgnoreCase("null")) {
        Iterator<String> sources = report.getMeta().getHasSources().iterator();
        sources.forEachRemaining(o -> {
            if (o != null) {
                String[] source = o.split("/");
                if (source[source.length - 2].trim().equals("model")
                        || source[source.length - 2].trim().equals("algorithm")
                        || source[source.length - 2].trim().equals("dataset")) {
                    Paragraph paragraph1 = new Paragraph();
                    paragraph1.add(new Chunk(source[source.length - 2].substring(0, 1).toUpperCase()
                            + source[source.length - 2].substring(1) + ": ", paragraphFontBold));
                    paragraph1.add(new Chunk(source[source.length - 1], paragraphFont));
                    chapter.add(paragraph1);
                    chapter.add(Chunk.NEWLINE);
                }
            }
        });
    }

    /** report single calculations */
    report.getSingleCalculations().forEach((key, value) -> {
        Paragraph paragraph1 = new Paragraph();
        paragraph1 = new Paragraph();
        paragraph1.add(new Chunk(key + ": ", paragraphFontBold));
        paragraph1.add(new Chunk(value.toString().trim().replaceAll(" +", " "), paragraphFont));
        chapter.add(paragraph1);
        chapter.add(Chunk.NEWLINE);
    });

    /** report date of completion */
    if (report.getMeta() != null && report.getMeta().getDate() != null) {
        Paragraph paragraph1 = new Paragraph();
        paragraph1.add(new Chunk("Procedure completed on: ", paragraphFontBold));
        paragraph1.add(new Chunk(report.getMeta().getDate().toString(), paragraphFont));
        chapter.add(paragraph1);
        chapter.add(Chunk.NEWLINE);
    }

    try {
        document.add(chapter);
    } catch (DocumentException ex) {
        throw new InternalServerErrorException(ex);
    }

    Integer chapterNumber = 0;

    /** report all_data */
    for (Entry<String, ArrayCalculation> entry : report.getArrayCalculations().entrySet()) {
        String label = entry.getKey();
        ArrayCalculation ac = entry.getValue();
        PdfPTable table = new PdfPTable(ac.getColNames().size() + 1);
        for (Entry<String, List<Object>> row : ac.getValues().entrySet()) {

            try {
                XMLWorkerHelper.getInstance().parseXHtml(w -> {
                    if (w instanceof WritableElement) {
                        List<Element> elements = ((WritableElement) w).elements();
                        for (Element element : elements) {
                            PdfPCell pdfCell = new PdfPCell();
                            pdfCell.addElement(element);
                            table.addCell(pdfCell);
                        }
                    }
                }, new StringReader(row.getKey()));
            } catch (IOException e) {
                e.printStackTrace();
            }

            for (Object o : row.getValue()) {
                table.addCell(o.toString());
            }
            table.completeRow();
        }
        try {
            Chunk tableChunk = new Chunk(label, tableFont);
            Chapter tableChapter = new Chapter(new Paragraph(tableChunk), ++chapterNumber);
            tableChapter.add(Chunk.NEWLINE);
            tableChapter.add(table);
            document.newPage();
            document.add(tableChapter);
        } catch (DocumentException ex) {
            throw new InternalServerErrorException(ex);
        }
    }

    /** report plots */
    for (Entry<String, String> entry : report.getFigures().entrySet()) {
        try {
            byte[] valueDecoded = Base64.decodeBase64(entry.getValue());
            Image l = Image.getInstance(valueDecoded);
            document.newPage();
            //image starts at the half's half of pdf page
            l.setAbsolutePosition(0, (document.getPageSize().getHeight() / 2 / 2));
            l.scaleToFit(document.getPageSize());

            Chunk tableChunk = new Chunk(entry.getKey(), tableFont);
            Chapter tableChapter = new Chapter(new Paragraph(tableChunk), ++chapterNumber);
            tableChapter.add(l);
            document.add(tableChapter);
        } catch (IOException | DocumentException e) {
            e.printStackTrace();
        }
    }
    document.close();
}

From source file:org.spinsuite.print.ReportPrintData.java

License:Open Source License

/**
 * Create a PDF File/*  w w  w .  ja  v a2 s.  c  o  m*/
 * @author Yamel Senih, ysenih@erpcya.com, ERPCyA http://www.erpcya.com 02/04/2014, 22:52:09
 * @param outFile
 * @throws FileNotFoundException
 * @throws DocumentException
 * @return void
 */
private void createPDF(File outFile) throws FileNotFoundException, DocumentException {
    Document document = new Document(PageSize.LETTER);

    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outFile));
    PDFHeaderAndFooter event = new PDFHeaderAndFooter();
    writer.setPageEvent(event);
    document.open();
    //   
    document.addAuthor(ctx.getResources().getString(R.string.app_name));
    document.addCreationDate();
    //   
    Paragraph title = new Paragraph(m_reportQuery.getInfoReport().getName());
    //   Set Font
    title.getFont().setStyle(Font.BOLD);
    //   Set Alignment
    title.setAlignment(Paragraph.ALIGN_CENTER);
    //   Add Title
    document.add(title);
    //   Add New Line
    document.add(Chunk.NEWLINE);
    //   Parameters
    ProcessInfoParameter[] param = m_pi.getParameter();
    //   Get Parameter
    if (param != null) {
        //   
        boolean isFirst = true;
        //   Iterate
        for (ProcessInfoParameter para : param) {
            //   Get SQL Name
            String name = para.getInfo();
            StringBuffer textParameter = new StringBuffer();
            if (para.getParameter() == null && para.getParameter_To() == null)
                continue;
            else {
                //   Add Parameters Title
                if (isFirst) {
                    Paragraph titleParam = new Paragraph(
                            ctx.getResources().getString(R.string.msg_ReportParameters));
                    //   Set Font
                    titleParam.getFont().setStyle(Font.BOLDITALIC);
                    //   Add to Document
                    document.add(titleParam);
                    isFirst = false;
                }
                //   Add Parameters Name
                if (para.getParameter() != null && para.getParameter_To() != null) { //   From and To is filled
                    //   
                    textParameter.append(name).append(" => ").append(para.getDisplayValue()).append(" <= ")
                            .append(para.getDisplayValue_To());
                } else if (para.getParameter() != null) { //   Only From
                    //   
                    textParameter.append(name).append(" = ").append(para.getDisplayValue());
                } else if (para.getParameter_To() != null) { //   Only To
                    //   
                    textParameter.append(name).append(" <= ").append(para.getDisplayValue_To());
                }
            }
            //   Add to Document
            Paragraph viewParam = new Paragraph(textParameter.toString());
            document.add(viewParam);
        }
    }
    document.add(Chunk.NEWLINE);
    //   
    InfoReportField[] columns = m_reportQuery.getColumns();
    //   Add Table
    PdfPTable table = new PdfPTable(columns.length);
    table.setSpacingBefore(4);
    //   Add Header
    PdfPCell headerCell = new PdfPCell(new Phrase(m_reportQuery.getInfoReport().getName()));
    headerCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    headerCell.setColspan(columns.length);
    //   Add to Table
    table.addCell(headerCell);
    //   Add Header
    //   Decimal and Date Format
    DecimalFormat[] cDecimalFormat = new DecimalFormat[columns.length];
    SimpleDateFormat[] cDateFormat = new SimpleDateFormat[columns.length];
    for (int i = 0; i < columns.length; i++) {
        InfoReportField column = columns[i];
        //   Only Numeric
        if (DisplayType.isNumeric(column.DisplayType))
            cDecimalFormat[i] = DisplayType.getNumberFormat(ctx, column.DisplayType, column.FormatPattern);
        //   Only Date
        else if (DisplayType.isDate(column.DisplayType))
            cDateFormat[i] = DisplayType.getDateFormat(ctx, column.DisplayType, column.FormatPattern);
        //   
        Phrase phrase = new Phrase(column.PrintName);
        PdfPCell cell = new PdfPCell(phrase);
        if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT))
            cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER))
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        else
            cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED);
        //   
        table.addCell(cell);
    }
    //   Add Detail
    for (int row = 0; row < m_data.size(); row++) {
        //   Get Row
        RowPrintData rPrintData = m_data.get(row);
        //   Iterate
        for (int col = 0; col < columns.length; col++) {
            InfoReportField column = columns[col];
            ColumnPrintData cPrintData = rPrintData.get(col);
            Phrase phrase = null;
            PdfPCell cell = new PdfPCell();
            //   
            String value = cPrintData.getValue();
            //   Only Values
            if (value != null) {
                if (DisplayType.isNumeric(column.DisplayType)) { //   Number
                    //   Format
                    DecimalFormat decimalFormat = cDecimalFormat[col];
                    //   Format
                    if (decimalFormat != null)
                        value = decimalFormat.format(DisplayType.getNumber(value));
                    //   Set Value
                    cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                } else if (DisplayType.isDate(column.DisplayType)) { //   Is Date
                    SimpleDateFormat dateFormat = cDateFormat[col];
                    if (dateFormat != null && value.trim().length() > 0) {
                        long date = Long.parseLong(value);
                        value = dateFormat.format(new Date(date));
                    }
                }
            }
            //   Set Value
            phrase = new Phrase(value);
            //   
            if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT))
                cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER))
                cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            else
                cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED);
            //   Set Font
            if (rPrintData.isFunctionRow()) {
                //   Set Function Value
                if (cPrintData.getFunctionValue() != null && cPrintData.getFunctionValue().length() > 0)
                    phrase = new Phrase(cPrintData.getFunctionValue());
                //   Set Font
                phrase.getFont().setStyle(Font.BOLDITALIC);
            }
            //   Add to Table
            cell.setPhrase(phrase);
            table.addCell(cell);
        }
    }
    //   Add Table to Document
    document.add(table);
    //   New Line
    document.add(Chunk.NEWLINE);
    //   Add Footer
    StringBuffer footerText = new StringBuffer(Env.getContext("#SUser"));
    footerText.append("(");
    footerText.append(Env.getContext("#AD_Role_Name"));
    footerText.append("@");
    footerText.append(Env.getContext("#AD_Client_Name"));
    footerText.append(".");
    footerText.append(Env.getContext("#AD_Org_Name"));
    footerText.append("{").append(Build.MANUFACTURER).append(".").append(Build.MODEL).append("}) ");
    //   Date
    SimpleDateFormat pattern = DisplayType.getDateFormat(ctx, DisplayType.DATE_TIME);
    footerText.append(" ").append(ctx.getResources().getString(R.string.Date)).append(" = ");
    footerText.append(pattern.format(new Date()));
    //   
    Paragraph footer = new Paragraph(footerText.toString());
    footer.setAlignment(Paragraph.ALIGN_CENTER);
    //   Set Font
    footer.getFont().setSize(8);
    //   Add Footer
    document.add(footer);
    //   Close Document
    document.close();
}

From source file:org.spinsuite.view.report.ReportPrintData.java

License:Open Source License

/**
 * Create a PDF File//from  w w  w . j a  va  2s. co m
 * @author <a href="mailto:yamelsenih@gmail.com">Yamel Senih</a> 02/04/2014, 22:52:09
 * @param outFile
 * @throws FileNotFoundException
 * @throws DocumentException
 * @return void
 */
private void createPDF(File outFile) throws FileNotFoundException, DocumentException {
    Document document = new Document(PageSize.LETTER);

    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outFile));
    PDFHeaderAndFooter event = new PDFHeaderAndFooter();
    writer.setPageEvent(event);
    document.open();
    //   
    document.addAuthor(ctx.getResources().getString(R.string.app_name));
    document.addCreationDate();
    //   
    Paragraph title = new Paragraph(m_reportQuery.getInfoReport().getName());
    //   Set Font
    title.getFont().setStyle(Font.BOLD);
    //   Set Alignment
    title.setAlignment(Paragraph.ALIGN_CENTER);
    //   Add Title
    document.add(title);
    //   Add New Line
    document.add(Chunk.NEWLINE);
    //   Parameters
    ProcessInfoParameter[] param = m_pi.getParameter();
    //   Get Parameter
    if (param != null) {
        //   
        boolean isFirst = true;
        //   Iterate
        for (ProcessInfoParameter para : param) {
            //   Get SQL Name
            String name = para.getInfo();
            StringBuffer textParameter = new StringBuffer();
            if (para.getParameter() == null && para.getParameter_To() == null)
                continue;
            else {
                //   Add Parameters Title
                if (isFirst) {
                    Paragraph titleParam = new Paragraph(
                            ctx.getResources().getString(R.string.msg_ReportParameters));
                    //   Set Font
                    titleParam.getFont().setStyle(Font.BOLDITALIC);
                    //   Add to Document
                    document.add(titleParam);
                    isFirst = false;
                }
                //   Add Parameters Name
                if (para.getParameter() != null && para.getParameter_To() != null) { //   From and To is filled
                    //   
                    textParameter.append(name).append(" => ").append(para.getDisplayValue()).append(" <= ")
                            .append(para.getDisplayValue_To());
                } else if (para.getParameter() != null) { //   Only From
                    //   
                    textParameter.append(name).append(" = ").append(para.getDisplayValue());
                } else if (para.getParameter_To() != null) { //   Only To
                    //   
                    textParameter.append(name).append(" <= ").append(para.getDisplayValue_To());
                }
            }
            //   Add to Document
            Paragraph viewParam = new Paragraph(textParameter.toString());
            document.add(viewParam);
        }
    }
    document.add(Chunk.NEWLINE);
    //   
    InfoReportField[] columns = m_reportQuery.getColumns();
    //   Add Table
    PdfPTable table = new PdfPTable(columns.length);
    table.setSpacingBefore(4);
    //   Add Header
    PdfPCell headerCell = new PdfPCell(new Phrase(m_reportQuery.getInfoReport().getName()));
    headerCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    headerCell.setColspan(columns.length);
    //   Add to Table
    table.addCell(headerCell);
    //   Add Header
    //   Decimal and Date Format
    DecimalFormat[] cDecimalFormat = new DecimalFormat[columns.length];
    SimpleDateFormat[] cDateFormat = new SimpleDateFormat[columns.length];
    for (int i = 0; i < columns.length; i++) {
        InfoReportField column = columns[i];
        //   Only Numeric
        if (DisplayType.isNumeric(column.DisplayType))
            cDecimalFormat[i] = DisplayType.getNumberFormat(ctx, column.DisplayType, column.FormatPattern);
        //   Only Date
        else if (DisplayType.isDate(column.DisplayType))
            cDateFormat[i] = DisplayType.getDateFormat(ctx, column.DisplayType, column.FormatPattern);
        //   
        Phrase phrase = new Phrase(column.PrintName);
        PdfPCell cell = new PdfPCell(phrase);
        if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT))
            cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER))
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        else
            cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED);
        //   
        table.addCell(cell);
    }
    //   Add Detail
    for (int row = 0; row < m_data.size(); row++) {
        //   Get Row
        RowPrintData rPrintData = m_data.get(row);
        //   Iterate
        for (int col = 0; col < columns.length; col++) {
            InfoReportField column = columns[col];
            ColumnPrintData cPrintData = rPrintData.get(col);
            Phrase phrase = null;
            PdfPCell cell = new PdfPCell();
            //   
            String value = cPrintData.getValue();
            if (DisplayType.isNumeric(column.DisplayType)) { //   Number
                //   Format
                DecimalFormat decimalFormat = cDecimalFormat[col];
                //   Format
                if (decimalFormat != null)
                    value = decimalFormat.format(DisplayType.getNumber(value));
                //   Set Value
                cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            } else if (DisplayType.isDate(column.DisplayType)) { //   Is Date
                SimpleDateFormat dateFormat = cDateFormat[col];
                if (dateFormat != null) {
                    long date = Long.getLong(value, 0);
                    value = dateFormat.format(new Date(date));
                }
            }
            //   Set Value
            phrase = new Phrase(value);
            //   
            if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT))
                cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER))
                cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            else
                cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED);
            //   Set Font
            if (rPrintData.isFunctionRow()) {
                //   Set Function Value
                if (cPrintData.getFunctionValue() != null && cPrintData.getFunctionValue().length() > 0)
                    phrase = new Phrase(cPrintData.getFunctionValue());
                //   Set Font
                phrase.getFont().setStyle(Font.BOLDITALIC);
            }
            //   Add to Table
            cell.setPhrase(phrase);
            table.addCell(cell);
        }
    }
    //   Add Table to Document
    document.add(table);
    //   New Line
    document.add(Chunk.NEWLINE);
    //   Add Footer
    StringBuffer footerText = new StringBuffer(Env.getContext(ctx, "#SUser"));
    footerText.append("(");
    footerText.append(Env.getContext(ctx, "#AD_Role_Name"));
    footerText.append("@");
    footerText.append(Env.getContext(ctx, "#AD_Client_Name"));
    footerText.append(".");
    footerText.append(Env.getContext(ctx, "#AD_Org_Name"));
    footerText.append("{").append(Build.MANUFACTURER).append(".").append(Build.MODEL).append("}) ");
    //   Date
    SimpleDateFormat pattern = DisplayType.getDateFormat(ctx, DisplayType.DATE_TIME);
    footerText.append(" ").append(ctx.getResources().getString(R.string.Date)).append(" = ");
    footerText.append(pattern.format(new Date()));
    //   
    Paragraph footer = new Paragraph(footerText.toString());
    footer.setAlignment(Paragraph.ALIGN_CENTER);
    //   Set Font
    footer.getFont().setSize(8);
    //   Add Footer
    document.add(footer);
    //   Close Document
    document.close();
}

From source file:project1.GENERALCV.java

private void createcvActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createcvActionPerformed
    String firstname, lastname, contactno, email, phonenumber, address;
    String dob, martialStatus, cast, careerObjectives;
    String university, city, startdatee, enddatee, coursesAndQualification;
    String acedemicQualification, certificates, experience, techskills, addSkills;
    String achivements, additionalCertificates, references, hobbies;
    firstname = txtname.getText();//from   w ww  .  java 2s  .co m
    lastname = txtlastname.getText();

    email = txtemail.getText();
    phonenumber = txtMobileNo.getText();

    address = txtAddress.getText();

    SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");

    String link = txtLink.getText();

    // dob= dateFormat.format(dateOfBirth.getDate());
    martialStatus = cmbMartialStatus.getSelectedItem().toString();
    // cast=txtcast.getText();
    //  careerObjectives=txtcareer.getText();

    university = txtCollegeName.getText();
    city = txtCity.getText();
    // startdatee=dateFormat.format(startdate.getDate());
    // enddatee=dateFormat.format(enddate.getDate());
    coursesAndQualification = txtExtraCourses.getText();

    //  certificates=txtcertificats.getText();
    // experience=txtexperience.getText();
    techskills = txttechnical.getText();
    // addSkills=txtadditional.getText();

    references = txtreference.getText();

    try {
        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection("jdbc:mysql://localhost:3306/cvmaker", "root", "12345");

        pInsertPerson = con
                .prepareStatement("INSERT INTO PERSONS(NAMEE,CONTACTNO,EMAILID,ADDRESS) VALUES(?,?,?,?)");

        pInsertPerson.setString(1, firstname + lastname);
        pInsertPerson.setString(2, phonenumber);
        pInsertPerson.setString(3, email);
        pInsertPerson.setString(4, address);
        pInsertPerson.executeUpdate();

        JOptionPane.showMessageDialog(null, "Data Is Alo Saved In Database....");

        showRecords();

    } catch (Exception e) {

        System.out.println(e.toString());

    }

    Statement statement;

    String selectTableSQL = "SELECT ID FROM PERSONS";
    int ss = 0;
    try {
        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection("jdbc:mysql://localhost:3306/cvmaker", "root", "12345");

        statement = con.createStatement();

        //System.out.println(selectTableSQL);
        // execute select SQL stetementS
        ResultSet rs = statement.executeQuery(selectTableSQL);

        while (rs.next()) {

            ss = rs.getInt("ID");
        }
    } catch (SQLException e) {
        System.out.println(e.toString());

    } catch (ClassNotFoundException ex) {
        Logger.getLogger(FRESHERCV.class.getName()).log(Level.SEVERE, null, ex);
    }

    int newcvid = ss;

    try {

        OutputStream file = new FileOutputStream(new File("D:\\PDFFILES\\" + firstname + lastname + ".pdf"));

        Document document = new Document();
        PdfWriter.getInstance(document, file);

        document.open();
        //     Image im=Image.getInstance("E:\\PDFFILES\\FUUAST.png");
        //   document.add(new Paragraph(""));
        // document.add(im);

        Paragraph title1 = new Paragraph(firstname + " " + lastname + " Cv", FontFactory
                .getFont(FontFactory.HELVETICA, 36, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));

        Chapter chapter1 = new Chapter(title1, 1);

        chapter1.setNumberDepth(0);
        document.add(chapter1);

        document.add(new Paragraph("\n\n"));

        List unorderedList = new List(List.UNORDERED);
        unorderedList.add(new ListItem("Mobile No:" + phonenumber));
        unorderedList.add(new ListItem("Email:" + city));
        unorderedList.add(new ListItem("Address:" + address));
        //    unorderedList.add(new ListItem("End Date:" + enddatee));
        document.add(unorderedList);

        //  document.add(new Paragraph("Address:"+address));
        Paragraph title2 = new Paragraph("Personal Information", FontFactory.getFont(FontFactory.HELVETICA, 24,
                Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));
        title2.setAlignment(Element.ALIGN_CENTER);

        document.add(title2);
        //   document.add(new Paragraph("Date Of Birth:" + dob));

        document.add(new Paragraph("Martial Status:" + martialStatus));
        //   document.add(new Paragraph("Cast:"+cast));
        //   document.add(new Paragraph("Career Objectives:"+careerObjectives));

        Paragraph title3 = new Paragraph("Qualification", FontFactory.getFont(FontFactory.HELVETICA, 24,
                Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));
        title3.setAlignment(Element.ALIGN_CENTER);
        document.add(title3);
        PdfPTable table = new PdfPTable(2); // 3 columns.
        document.add(new Paragraph("\n\n"));
        PdfPCell cell1 = new PdfPCell(new Paragraph("Insituite Name:"));
        PdfPCell cell2 = new PdfPCell(new Paragraph(university));

        PdfPCell cell3 = new PdfPCell(new Paragraph("City:"));
        PdfPCell cell4 = new PdfPCell(new Paragraph(city));

        PdfPCell cell5 = new PdfPCell(new Paragraph("Start Date:"));
        // PdfPCell cell6 = new PdfPCell(new Paragraph(startdatee));

        PdfPCell cell7 = new PdfPCell(new Paragraph("End Date:"));
        //PdfPCell cell8 = new PdfPCell(new Paragraph(enddatee));

        PdfPCell cell71 = new PdfPCell(new Paragraph("Extra Courses:"));
        PdfPCell cell81 = new PdfPCell(new Paragraph(coursesAndQualification));
        table.addCell(cell1);
        table.addCell(cell2);
        table.addCell(cell3);
        table.addCell(cell4);
        table.addCell(cell5);
        //   table.addCell(cell6);
        table.addCell(cell7);
        //   table.addCell(cell8);
        table.addCell(cell71);
        table.addCell(cell81);

        document.add(table);

        //  document.add(new Paragraph("Extra Courses:"+coursesAndQualification));
        //   document.add(new Paragraph("Certificates:"+certificates));
        //
        Paragraph title4 = new Paragraph("Experience", FontFactory.getFont(FontFactory.HELVETICA, 24,
                Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));
        title4.setAlignment(Element.ALIGN_CENTER);
        document.add(title4);
        //      document.add(new Paragraph(""+experience));

        Paragraph title5 = new Paragraph("Skills", FontFactory.getFont(FontFactory.HELVETICA, 24,
                Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));
        title5.setAlignment(Element.ALIGN_CENTER);
        document.add(title5);

        document.add(new Paragraph("Technical Skills:" + techskills));
        //    document.add(new Paragraph("Additional Skills:"+addSkills));
        Paragraph title6 = new Paragraph("References", FontFactory.getFont(FontFactory.HELVETICA, 24,
                Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));
        title6.setAlignment(Element.ALIGN_CENTER);
        document.add(title6);
        document.add(new Paragraph("References:" + references));

        //     Anchor anchor;
        //     anchor = new Anchor(link, FontFactory.getFont(FontFactory.HELVETICA,12, Font.UNDERLINE, new CMYKColor(0, 0,0,255)));
        //    anchor.setReference( link);
        Paragraph paragraph = new Paragraph("Profile Link:");
        //     paragraph.add(anchor);
        document.add(paragraph);
        Paragraph title11 = new Paragraph(
                "                                                 Cv Number:" + newcvid, FontFactory
                        .getFont(FontFactory.HELVETICA, 15, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));

        document.add(new Paragraph("\n\n"));
        document.add(title11);
        try {
            Desktop desktop = Desktop.getDesktop();
            if (desktop.isSupported(Desktop.Action.OPEN)) {
                desktop.open(new File("D:\\PDFFILES\\" + firstname + lastname + ".pdf"));
            } else {
                System.out.println("Open is not supported");
            }
        } catch (IOException exp) {
            exp.printStackTrace();
        }
        document.close();
        file.close();

    } catch (Exception e) {

        e.printStackTrace();
    }
}

From source file:project1.SimplePdf.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:

    int id;//  ww  w.jav a  2s  .  co m
    String name;
    id = Integer.parseInt(txtid.getText());
    name = txtname.getText();

    try {

        OutputStream file = new FileOutputStream(new File("F:\\PDFFILES\\" + id + ".pdf"));

        Document document = new Document();
        PdfWriter.getInstance(document, file);

        document.open();
        //     Image im=Image.getInstance("E:\\PDFFILES\\FUUAST.png");
        //   document.add(new Paragraph(""));
        // document.add(im);
        Paragraph title1 = new Paragraph(name + id,

                FontFactory.getFont(FontFactory.HELVETICA,

                        36, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));

        Chapter chapter1 = new Chapter(title1, 1);

        chapter1.setNumberDepth(0);
        document.add(chapter1);

        document.add(new Paragraph("\n\n\n\n"));
        document.add(new Paragraph("Name: " + name));
        document.add(new Paragraph("Id: " + id));

        try {
            Desktop desktop = Desktop.getDesktop();
            if (desktop.isSupported(Desktop.Action.OPEN)) {
                desktop.open(new File("D:\\PDFFILES\\" + id + ".pdf"));
            } else {
                System.out.println("Open is not supported");
            }
        } catch (IOException exp) {
            exp.printStackTrace();
        }
        document.close();
        file.close();

    } catch (Exception e) {

        e.printStackTrace();
    }

}

From source file:ro.nextreports.engine.exporter.PdfExporter.java

License:Apache License

private void updateFont(Map<String, Object> style, Font fnt) {
    if (style.containsKey(StyleFormatConstants.FONT_FAMILY_KEY)) {
        String val = (String) style.get(StyleFormatConstants.FONT_FAMILY_KEY);
        fnt.setFamily(val);
    }//  w  w w.ja va  2 s . c  om
    if (style.containsKey(StyleFormatConstants.FONT_SIZE)) {
        Float val = (Float) style.get(StyleFormatConstants.FONT_SIZE);
        fnt.setSize(val);
    }
    if (style.containsKey(StyleFormatConstants.FONT_COLOR)) {
        Color val = (Color) style.get(StyleFormatConstants.FONT_COLOR);
        fnt.setColor(new BaseColor(val));
    }
    if (style.containsKey(StyleFormatConstants.FONT_STYLE_KEY)) {
        if (StyleFormatConstants.FONT_STYLE_NORMAL.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
            fnt.setStyle(Font.NORMAL);
        }
        if (StyleFormatConstants.FONT_STYLE_BOLD.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
            fnt.setStyle(Font.BOLD);
        }
        if (StyleFormatConstants.FONT_STYLE_ITALIC.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
            fnt.setStyle(Font.ITALIC);
        }
        if (StyleFormatConstants.FONT_STYLE_BOLDITALIC.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
            fnt.setStyle(Font.BOLDITALIC);
        }
    }
}