Example usage for com.itextpdf.text Font ITALIC

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

Introduction

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

Prototype

int ITALIC

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

Click Source Link

Document

this is a possible style.

Usage

From source file:opticalworkshopmonitoringsystem.CenteringAndEdgingView.java

License:Open Source License

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    //code for the forating of the pdf report.

    try {//from   w w w.  j  a va2 s  .  co  m
        Document document = new Document();
        JFileChooser fc = new JFileChooser();
        fc.showOpenDialog(null);

        PdfWriter.getInstance(document, new FileOutputStream(fc.getSelectedFile().getAbsolutePath()));
        document.open();

        Font courierFontItalic = new Font(Font.FontFamily.COURIER, 10, Font.ITALIC);
        Font courierFontUnderline = new Font(Font.FontFamily.COURIER, 10, Font.UNDERLINE);
        Font tr = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        Font timesRomanUnderline = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.UNDERLINE);
        Font helvetica = new Font(Font.FontFamily.HELVETICA, 14, Font.UNDERLINE);

        document.add(new Paragraph(
                "                         Centering And Edging Division                            ",
                timesRomanUnderline));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel1.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField1.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel2.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField2.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel3.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField3.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel4.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField4.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel5.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField5.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel6.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField6.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel7.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField7.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel8.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField8.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel9.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField9.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel10.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField10.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel11.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField11.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel12.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField12.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel13.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField13.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "      Prepared by                                   Checked by                                       Approved by                  "));

        document.close();
        JOptionPane.showMessageDialog(null, "report generated successfully");
    } catch (DocumentException ex) {
        Logger.getLogger(CenteringAndEdgingView.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(CenteringAndEdgingView.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:opticalworkshopmonitoringsystem.GrindingDivisionView.java

License:Open Source License

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    try {//from w w w  . j  a v a2 s.c  om
        Document document = new Document();
        JFileChooser fc = new JFileChooser();
        fc.showOpenDialog(null);

        PdfWriter.getInstance(document, new FileOutputStream(fc.getSelectedFile().getAbsolutePath()));
        document.open();

        Font courierFontItalic = new Font(Font.FontFamily.COURIER, 10, Font.ITALIC);
        Font courierFontUnderline = new Font(Font.FontFamily.COURIER, 10, Font.UNDERLINE);
        Font tr = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        Font timesRomanUnderline = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.UNDERLINE);
        Font helvetica = new Font(Font.FontFamily.HELVETICA, 14, Font.UNDERLINE);

        document.add(new Paragraph(
                "                                 Grinding Division                                         ",
                timesRomanUnderline));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel2.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField2.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel3.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField3.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel1.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField1.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel4.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField4.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel5.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField23.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel6.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField24.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel7.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField25.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel8.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField26.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Slicing Operation                        ", helvetica));

        document.add(new Paragraph(jLabel9.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField27.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel11.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField28.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel10.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField29.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel23.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField30.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel24.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField31.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Trepening Operation                        ", helvetica));

        document.add(new Paragraph(jLabel15.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField19.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel17.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField20.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel28.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField21.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel29.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField22.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel30.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField32.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Curve Generation Operation                        ", helvetica));

        document.add(new Paragraph(jLabel12.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField5.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel13.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField6.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel14.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField7.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel25.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField16.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel26.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField17.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel27.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField18.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(
                new Paragraph("          Grinding and Smoothing Operation                        ", helvetica));

        document.add(new Paragraph(jLabel38.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField43.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel39.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField44.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel40.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField45.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel41.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField46.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel42.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField47.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel43.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField48.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel44.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField49.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Inspection Details                        ", helvetica));

        document.add(new Chunk("                                                      Specified"));
        document.add(new Chunk("                                            Measured"));
        document.add(new Paragraph(jLabel16.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField8.getText()));
        document.add(
                new Chunk("                                                      " + jTextField12.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel18.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField9.getText()));
        document.add(
                new Chunk("                                                      " + jTextField15.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel19.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField10.getText()));
        document.add(
                new Chunk("                                                        " + jTextField13.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Angles                        ", helvetica));

        document.add(new Paragraph(jLabel32.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField11.getText()));
        document.add(
                new Chunk("                                                        " + jTextField14.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel33.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField33.getText()));
        document.add(
                new Chunk("                                                      " + jTextField38.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel34.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField34.getText()));
        document.add(
                new Chunk("                                                      " + jTextField39.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel35.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField35.getText()));
        document.add(
                new Chunk("                                                        " + jTextField40.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel36.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField37.getText()));
        document.add(
                new Chunk("                                                        " + jTextField41.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel37.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField36.getText()));
        document.add(
                new Chunk("                                                        " + jTextField42.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel45.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField50.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel46.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField51.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel47.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField52.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel48.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField53.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "      Prepared by                                   Checked by                                       Approved by                  "));

        document.close();
        JOptionPane.showMessageDialog(null, "report generated successfully");
    } catch (DocumentException ex) {
        Logger.getLogger(GrindingDivisionView.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(GrindingDivisionView.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:opticalworkshopmonitoringsystem.PolishingDivisionView.java

License:Open Source License

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed

    try {//  ww w .  j ava  2s  . co m
        // TODO add your handling code here:

        Document document = new Document();
        JFileChooser fc = new JFileChooser();
        fc.showOpenDialog(null);

        PdfWriter.getInstance(document, new FileOutputStream(fc.getSelectedFile().getAbsolutePath()));
        document.open();

        Font courierFontItalic = new Font(Font.FontFamily.COURIER, 10, Font.ITALIC);
        Font courierFontUnderline = new Font(Font.FontFamily.COURIER, 10, Font.UNDERLINE);
        Font tr = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        Font timesRomanUnderline = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.UNDERLINE);
        Font helvetica = new Font(Font.FontFamily.HELVETICA, 14, Font.UNDERLINE);

        document.add(new Paragraph(
                "                                 Polishing Division                                         ",
                timesRomanUnderline));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel1.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField1.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel2.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField2.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel3.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField3.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Polisher Details                        ", helvetica));

        document.add(new Paragraph(jLabel4.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField4.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel5.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField5.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel6.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField6.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel7.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField7.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel8.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField8.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel9.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField9.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(
                new Paragraph("          Polishing Material(Processing)                        ", helvetica));

        document.add(new Paragraph(jLabel10.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField10.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel11.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField11.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel12.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField12.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel13.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField13.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel14.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField14.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Polishing Iteration                        ", helvetica));

        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel17.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField18.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel18.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField19.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Final Inspection                        ", helvetica));

        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel23.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField23.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel24.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField24.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel25.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField25.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel26.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField26.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel27.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField27.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "      Prepared by                                   Checked by                                       Approved by                  "));

        document.close();
        JOptionPane.showMessageDialog(null, "report generated successfully");
    } catch (DocumentException ex) {
        Logger.getLogger(PolishingDivisionView.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(PolishingDivisionView.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:org.ganttproject.impex.htmlpdf.itext.ThemeImpl.java

License:GNU General Public License

private Font getSansItalic(float size) {
    return myFontCache.getFont(getFontName(), getCharset(), Font.ITALIC, size);
}

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);/* w  w w.j  a  va  2  s  .  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.javad.pdf.fonts.PdfFontBean.java

License:Apache License

public boolean isItalic() {
    return (style & Font.ITALIC) > 0;
}

From source file:org.openmrs.module.laboratorymanagement.db.hibernate.LaboratoryDAOimpl.java

License:Open Source License

public void exportPatientReportToPDF(HttpServletRequest request, HttpServletResponse response,
        Map<ConceptName, List<Object[]>> mappedLabExam, String filename, String title, int patientId)
        throws DocumentException, IOException {

    Document document = new Document();
    Patient patient = Context.getPatientService().getPatient(patientId);
    // List<PatientBill> patientBills =
    // (List<PatientBill>)request.getAttribute("reportedPatientBillsPrint");

    /*/*  ww  w .j a va 2s .co  m*/
     * PatientBill pb = null;
     * 
     * pb = Context.getService(BillingService.class).getPatientBill(
     * Integer.parseInt(request.getParameter("patientBills")));
     */
    /*
     * String filename = pb.getBeneficiary().getPatient().getPersonName()
     * .toString().replace(" ", "_"); filename =
     * pb.getBeneficiary().getPolicyIdNumber().replace(" ", "_") + "_" +
     * filename + ".pdf";
     */
    response.setContentType("application/pdf");
    response.setHeader("Content-Disposition", "report"); // file name

    PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
    writer.setBoxSize("art", new Rectangle(0, 0, 2382, 3369));
    writer.setBoxSize("art", PageSize.A4);

    HeaderFooterMgt event = new HeaderFooterMgt();
    writer.setPageEvent(event);

    document.open();
    document.setPageSize(PageSize.A4);
    // document.setPageSize(new Rectangle(0, 0, 2382, 3369));

    document.addAuthor(Context.getAuthenticatedUser().getPersonName().toString());// the name of the author

    FontSelector fontTitle = new FontSelector();
    fontTitle.addFont(new Font(FontFamily.COURIER, 10.0f, Font.ITALIC));

    // Report title
    Chunk chk = new Chunk("Printed on : " + (new SimpleDateFormat("dd-MMM-yyyy").format(new Date())));
    chk.setFont(new Font(FontFamily.COURIER, 10.0f, Font.BOLD));
    Paragraph todayDate = new Paragraph();
    todayDate.setAlignment(Element.ALIGN_RIGHT);
    todayDate.add(chk);
    document.add(todayDate);
    document.add(fontTitle.process("REPUBLIQUE DU RWANDA\n"));
    document.add(fontTitle.process("POLICE NATIONALE\n"));
    document.add(fontTitle.process("KACYIRU POLICE HOSPITAL\n"));
    document.add(fontTitle.process("B.P. 6183 KIGALI\n"));
    document.add(fontTitle.process("Tl : 584897\n"));
    document.add(fontTitle.process("E-mail : medical@police.gov.rw"));
    // End Report title

    document.add(new Paragraph("\n"));
    chk = new Chunk("Laboratory results");
    chk.setFont(new Font(FontFamily.COURIER, 10.0f, Font.BOLD));
    chk.setUnderline(0.2f, -2f);
    Paragraph pa = new Paragraph();
    pa.add(chk);
    pa.setAlignment(Element.ALIGN_CENTER);
    document.add(pa);
    document.add(new Paragraph("\n"));

    document.add(fontTitle.process("Family Name: " + patient.getFamilyName() + "\n"));
    document.add(fontTitle.process("Given name: " + patient.getGivenName() + "\n"));
    document.add(fontTitle.process("Age: " + patient.getAge() + "\n"));

    // title row
    FontSelector fontTitleSelector = new FontSelector();
    fontTitleSelector.addFont(new Font(FontFamily.COURIER, 9, Font.ITALIC));
    // Table of identification;
    PdfPTable table = null;
    table = new PdfPTable(2);
    table.setWidthPercentage(100f);

    // tableHeader.addCell(table);

    // document.add(tableHeader);

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

    // Table of lab report items;
    float[] colsWidth = { 6f, 3f, 6f };
    table = new PdfPTable(colsWidth);
    table.setWidthPercentage(100f);
    BaseColor bckGroundTitle = new BaseColor(170, 170, 170);
    BaseColor bckGroundTitl = new BaseColor(Color.yellow);

    // table Header
    PdfPCell cell = new PdfPCell(fontTitleSelector.process("Exam"));

    cell.setBackgroundColor(bckGroundTitle);

    table.addCell(cell);

    cell = new PdfPCell(fontTitleSelector.process("Result"));
    cell.setBackgroundColor(bckGroundTitle);

    table.addCell(cell);

    cell = new PdfPCell(fontTitleSelector.process("Normal Range"));
    cell.setBackgroundColor(bckGroundTitle);
    table.addCell(cell);
    /*
     * cell = new PdfPCell(fontTitleSelector.process("Date "));
     * cell.setBackgroundColor(bckGroundTitle); table.addCell(cell);
     */

    // normal row
    FontSelector fontselector = new FontSelector();
    fontselector.addFont(new Font(FontFamily.COURIER, 8, Font.NORMAL));

    // empty row
    FontSelector fontTotals = new FontSelector();
    fontTotals.addFont(new Font(FontFamily.COURIER, 9, Font.BOLD));

    // ===========================================================
    for (ConceptName cptName : mappedLabExam.keySet()) {

        cell = new PdfPCell(fontTitleSelector.process("" + cptName));
        cell.setBackgroundColor(bckGroundTitl);

        table.addCell(cell);
        cell = new PdfPCell(fontTitleSelector.process(""));
        table.addCell(cell);
        cell = new PdfPCell(fontTitleSelector.process(""));
        table.addCell(cell);

        List<Object[]> labExamHistory = mappedLabExam.get(cptName);
        for (Object[] labExam : labExamHistory) {
            // table Header
            // Object[] labe = listOflabtest.get(i);
            Obs ob = (Obs) labExam[0];
            cell = new PdfPCell(fontTitleSelector.process("" + ob.getConcept().getName()));

            table.addCell(cell);
            if (ob.getConcept().getDatatype().isNumeric()) {
                cell = new PdfPCell(fontTitleSelector.process("" + ob.getValueNumeric()));
                table.addCell(cell);

            }

            if (ob.getConcept().getDatatype().isCoded()) {
                cell = new PdfPCell(fontTitleSelector.process("" + ob.getValueCoded().getName()));
                table.addCell(cell);

            }

            if (ob.getConcept().getDatatype().isText()) {
                cell = new PdfPCell(fontTitleSelector.process("" + ob.getValueText()));
                table.addCell(cell);

            }

            cell = new PdfPCell(fontTitleSelector.process("" + (labExam[1] != null ? labExam[1] : "-")));
            table.addCell(cell);

            fontselector.addFont(new Font(FontFamily.COURIER, 8, Font.NORMAL));

            // empty row
            // FontSelector fontTotals = new FontSelector();
            fontTotals.addFont(new Font(FontFamily.COURIER, 9, Font.BOLD));

        }

    }

    cell = new PdfPCell(fontTitleSelector.process("Names, Signature et Stamp of Lab Chief\n"
            //+ Context.getAuthenticatedUser().getPersonName()));
            + Context.getUserService().getUser(140).getPersonName()));

    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);
    // ================================================================
    table.addCell(cell);

    document.add(table);

    // Table of signatures;
    table = new PdfPTable(2);
    table.setWidthPercentage(100f);

    cell = new PdfPCell(fontTitleSelector.process(" "));

    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);

    cell = new PdfPCell(fontTitleSelector.process(
            "Names, Signature and  Stamp of Provider\n" + Context.getAuthenticatedUser().getPersonName()));
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);
    document.add(table);
    document.close();

    document.close();
}

From source file:PDF.PDFTrackGenerator.java

License:Open Source License

/**
 * Metda generateTrackPDFA4 sli na samotn vygenerovanie PDF dokumentu trasy na formt A4.
 * @param lineWeight - hrbka ?iary trasy na mape
 * @param color - farba ?iary trasy na mape
 * @param width - rka mapy/*from  w w w .ja v  a  2s . c  o m*/
 * @param height - vka mapy
 * @param scale - klovacia kontanta mapy (n x rozlenie mapy)
 * @param startDate - dtum a ?as prvho bodu trasy
 * @param endDate - dtum a ?as poslednho bodu trasy
 * @param activity - aktivita trasy
 * @param user - pouvate (majite) trasy
 */
public void generateTrackPDFA4(int lineWeight, String color, int width, int height, int scale, String startDate,
        String endDate, String activity, String user) {
    try {
        Document doc = new Document();
        PdfWriter.getInstance(doc, new FileOutputStream(path + fileName + ".pdf"));
        doc.open();

        Font nadpisFont = new Font(Font.FontFamily.HELVETICA, 25, Font.BOLD);

        Font detailyFont = new Font(Font.FontFamily.HELVETICA, 9, Font.NORMAL);

        Paragraph nadpisPar = new Paragraph();

        nadpisPar.setAlignment(Element.ALIGN_CENTER);

        Phrase nadpis = new Phrase(fileName, nadpisFont);

        nadpisPar.add(nadpis);

        nadpisPar.add("");

        doc.add(nadpisPar);
        doc.add(Chunk.NEWLINE);

        PdfPTable tabulka = new PdfPTable(2);
        tabulka.setWidthPercentage(100);
        float[] columnWidth = { 6f, 4f };
        tabulka.setWidths(columnWidth);

        StaticMapResolver res = new StaticMapResolver(loader);

        String mapUrl = res.getStaticMapTrackURLWithMultimedia(lineWeight, color, width, height, scale);

        Image img = Image.getInstance(new URL(mapUrl));
        //img.scalePercent(50);
        PdfPCell riadokSObr = new PdfPCell(img, true);
        riadokSObr.setBorder(Rectangle.NO_BORDER);
        riadokSObr.setPaddingBottom(10f);
        PdfPCell riadokSText = new PdfPCell(new Phrase("Description: " + loader.getTrackDescription()
                + "\n\n\nTrack activity: " + activity.substring(4) + "\n\n\nStart place: "
                + loader.getStartAddress() + "\n\n\nEnd Place: " + loader.getEndAddress()
                + "\n\n\nTrack length: " + loader.getLength() + " km\n\n\nMin elevation: "
                + loader.getMinElevation() + " m\n\n\nMax elevation: " + loader.getMaxElevation()
                + " m\n\n\nHeight difference: " + loader.getHeightDiff() + " m\n\n\nStart: " + startDate
                + "\n\n\nEnd: " + endDate + "\n\n\nDuration: " + loader.getDuration(), detailyFont));
        riadokSText.setBorder(Rectangle.NO_BORDER);
        riadokSText.setPaddingLeft(20f);
        riadokSText.setPaddingTop(5f);
        riadokSText.setPaddingBottom(10f);
        tabulka.addCell(riadokSObr);
        tabulka.addCell(riadokSText);

        doc.add(tabulka);
        //doc.add(new Phrase("\n", detailyFont));

        PdfPTable obrTabulka = new PdfPTable(3);
        obrTabulka.setWidthPercentage(100);

        ArrayList<String> goodFiles = new ArrayList<String>();
        for (int i = 0; i < loader.getMultimediaFiles().size(); i++) {
            if (!loader.getMultimediaFiles().get(i).getPath().startsWith("YTB")) {
                String extension = loader.getMultimediaFiles().get(i).getPath().substring(
                        loader.getMultimediaFiles().get(i).getPath().lastIndexOf("."),
                        loader.getMultimediaFiles().get(i).getPath().length());
                String newPath = loader.getMultimediaFiles().get(i).getPath().substring(0,
                        loader.getMultimediaFiles().get(i).getPath().lastIndexOf(".")) + "_THUMB" + extension;
                goodFiles.add(newPath);
            }
        }

        if (!goodFiles.isEmpty()) {
            int freeCount = 9;
            if (goodFiles.size() <= 9) {
                for (int i = 0; i < goodFiles.size(); i++) {
                    Image tempImg = Image.getInstance(goodFiles.get(i));
                    tempImg.scalePercent(10f);
                    PdfPCell tempCell = new PdfPCell(tempImg, true);
                    tempCell.setPadding(3f);
                    //tempCell.setPaddingTop(5f);
                    tempCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    tempCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tempCell.setFixedHeight(130f);
                    tempCell.setBackgroundColor(BaseColor.BLACK);
                    tempCell.setBorderColor(BaseColor.WHITE);
                    tempCell.setBorderWidth(4f);
                    //tempCell.setBorder(Rectangle.NO_BORDER);
                    obrTabulka.addCell(tempCell);
                }
                for (int i = 0; i < 9 - goodFiles.size(); i++) {
                    PdfPCell tempCell = new PdfPCell();
                    tempCell.setBorder(Rectangle.NO_BORDER);
                    obrTabulka.addCell(tempCell);
                }
            } else if (goodFiles.size() <= 18) {
                for (int i = 0; i < 9; i++) {
                    Image tempImg = Image.getInstance(goodFiles.get(i));
                    tempImg.scalePercent(10f);
                    PdfPCell tempCell = new PdfPCell(tempImg, true);
                    tempCell.setPadding(3f);
                    //tempCell.setPaddingTop(5f);
                    tempCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    tempCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tempCell.setFixedHeight(130f);
                    tempCell.setBackgroundColor(BaseColor.BLACK);
                    tempCell.setBorderColor(BaseColor.WHITE);
                    tempCell.setBorderWidth(4f);
                    //tempCell.setBorder(Rectangle.NO_BORDER);
                    obrTabulka.addCell(tempCell);
                }
            } else {
                for (int i = 0; i < (goodFiles.size() % 9); i++) {
                    goodFiles.remove(goodFiles.size() - 1 - i);
                }

                int counting = (goodFiles.size() / 9);

                for (int i = 0; i < goodFiles.size(); i = i + counting) {
                    Image tempImg = Image.getInstance(goodFiles.get(i));
                    tempImg.scalePercent(10f);
                    PdfPCell tempCell = new PdfPCell(tempImg, true);
                    tempCell.setPadding(3f);
                    //tempCell.setPaddingTop(5f);
                    tempCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    tempCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tempCell.setFixedHeight(130f);
                    tempCell.setBackgroundColor(BaseColor.BLACK);
                    tempCell.setBorderColor(BaseColor.WHITE);
                    tempCell.setBorderWidth(4f);
                    //tempCell.setBorder(Rectangle.NO_BORDER);
                    obrTabulka.addCell(tempCell);
                    freeCount--;
                }
                for (int i = 0; i < freeCount; i++) {
                    PdfPCell tempCell = new PdfPCell();
                    tempCell.setBorder(Rectangle.NO_BORDER);
                    obrTabulka.addCell(tempCell);
                }
            }
        }

        doc.add(obrTabulka);

        Font lastFont = new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC);
        Phrase lastText = new Phrase("This PDF document was generated by gTrax app for user " + user, lastFont);
        doc.add(lastText);

        doc.close();
    } catch (Exception ex) {
        FileLogger.getInstance()
                .createNewLog("ERROR: Cannot CREATE PDF for track " + fileName + " for user " + user + " !!!");
        System.out.println("pruser");
    }

}

From source file:presentation.frmReportForm.java

private void btnGenerateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGenerateActionPerformed
    Date dateNow = new Date();
    SimpleDateFormat df = new SimpleDateFormat("dd_MM_yyyy_HH_mm_ss");

    System.out.println(dtcMonthChooser.getMonth());
    System.out.println(dtcYearChooser.getYear());

    if (radInMonth.isSelected()) {
        List<Transfer> transferList = new ArrayList<>();

        transferList = empObj.searchRecordByMonth(dtcMonthChooser.getMonth() + 1, dtcYearChooser.getYear());

        Document document = new Document();
        try {//w w w  .j a v a  2s.  com
            Font fontTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD);

            String fileName = "../EMPtranfermanagement/Report" + " " + df.format(dateNow) + ".pdf";
            PdfWriter.getInstance(document, new FileOutputStream(fileName));

            document.open();

            Image imageLogo = Image
                    .getInstance(this.getClass().getResource("/images/onlinelogomaker-afterscale2.png"));
            imageLogo.setAbsolutePosition(20, 750f);
            document.add(imageLogo);

            Paragraph titlePara = new Paragraph("EMP Transfer Application", fontTitle);
            titlePara.setAlignment(Element.ALIGN_CENTER);
            titlePara.setSpacingAfter(5);
            document.add(titlePara);

            Paragraph creditPara = new Paragraph("Created by Ly Thanh Hai + Nguyen Khanh",
                    FontFactory.getFont(FontFactory.HELVETICA, 10, Font.ITALIC));
            creditPara.setAlignment(Element.ALIGN_CENTER);
            creditPara.setSpacingAfter(10);
            document.add(creditPara);

            Paragraph slashPara = new Paragraph(
                    "Transfer records at " + (dtcMonthChooser.getMonth() + 1) + "/" + dtcYearChooser.getYear(),
                    FontFactory.getFont(FontFactory.HELVETICA, 15, Font.BOLD));
            slashPara.setSpacingAfter(40);
            slashPara.setAlignment(Element.ALIGN_CENTER);
            document.add(slashPara);

            PdfPTable table = new PdfPTable(5);
            table.setWidthPercentage(100);

            Font font = new Font(FontFamily.HELVETICA, 15, Font.BOLD);
            Paragraph paragraphCellHeading = new Paragraph("Report", font);

            PdfPCell cellHeading = new PdfPCell(paragraphCellHeading);
            BaseColor myColor = WebColors.getRGBColor("#41a5c2");
            cellHeading.setColspan(5);
            cellHeading.setBackgroundColor(myColor);
            cellHeading.setFixedHeight(30.3f);
            cellHeading.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellHeading.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellHeading);

            Font fBody = new Font(FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.BLACK);

            PdfPCell cellTitle1 = new PdfPCell(new Phrase("Transfer ID", fBody));
            cellTitle1.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle1);
            PdfPCell cellTitle2 = new PdfPCell(new Phrase("Emp ID", fBody));
            cellTitle2.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle2.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle2);
            PdfPCell cellTitle3 = new PdfPCell(new Phrase("From Project", fBody));
            cellTitle3.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle3.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle3);
            PdfPCell cellTitle4 = new PdfPCell(new Phrase("To Project", fBody));
            cellTitle4.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle4.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle4);
            PdfPCell cellTitleStatus = new PdfPCell(new Phrase("Status", fBody));
            cellTitleStatus.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitleStatus.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitleStatus);

            int cellColorCheck = 1;
            for (Transfer e : transferList) {
                PdfPCell cellBody1 = new PdfPCell(new Phrase(e.getId()));
                PdfPCell cellBody2 = new PdfPCell(new Phrase(e.getEmployeeId()));
                PdfPCell cellBody3 = new PdfPCell(new Phrase(e.getFromProjectId()));
                PdfPCell cellBody4 = new PdfPCell(new Phrase(e.getToProjectId()));
                PdfPCell cellBody5 = new PdfPCell(new Phrase(e.getStatus()));
                if (cellColorCheck % 2 == 1) {
                    cellBody1.setBackgroundColor(BaseColor.ORANGE);
                    cellBody2.setBackgroundColor(BaseColor.ORANGE);
                    cellBody3.setBackgroundColor(BaseColor.ORANGE);
                    cellBody4.setBackgroundColor(BaseColor.ORANGE);
                    cellBody5.setBackgroundColor(BaseColor.ORANGE);
                }
                table.addCell(cellBody1);
                table.addCell(cellBody2);
                table.addCell(cellBody3);
                table.addCell(cellBody4);
                table.addCell(cellBody5);
                cellColorCheck++;
            }

            document.add(table);

            JOptionPane.showMessageDialog(this, "Report saved");

            if (Desktop.isDesktopSupported()) {
                File reportFile = new File(fileName);
                Desktop.getDesktop().open(reportFile);
                ;
            }

            document.close();
        } catch (DocumentException | FileNotFoundException ex) {
            Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    if (radInDateRange.isSelected()) {
        try {
            List<Transfer> transferList = new ArrayList<>();

            java.sql.Date fromDateSql = formatDateForSearching(dtcFromDate.getDate());
            java.sql.Date toDateSql = formatDateForSearching(dtcToDate.getDate());
            transferList = empObj.searchRecordByDate(fromDateSql, toDateSql);

            Document document = new Document();
            try {
                Font fontTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD);

                String fileName = "../EMPtranfermanagement/Report" + " " + df.format(dateNow) + ".pdf";
                PdfWriter.getInstance(document, new FileOutputStream(fileName));

                document.open();

                Image imageLogo = Image
                        .getInstance(this.getClass().getResource("/images/onlinelogomaker-afterscale2.png"));
                imageLogo.setAbsolutePosition(20, 750f);
                document.add(imageLogo);

                Paragraph titlePara = new Paragraph("EMP Transfer Application", fontTitle);
                titlePara.setAlignment(Element.ALIGN_CENTER);
                titlePara.setSpacingAfter(5);
                document.add(titlePara);

                Paragraph creditPara = new Paragraph("Created by Ly Thanh Hai + Nguyen Khanh",
                        FontFactory.getFont(FontFactory.HELVETICA, 10, Font.ITALIC));
                creditPara.setAlignment(Element.ALIGN_CENTER);
                creditPara.setSpacingAfter(10);
                document.add(creditPara);

                SimpleDateFormat df2 = new SimpleDateFormat("dd/MM/yyyy");
                String fromDate = df2.format(dtcFromDate.getDate());
                String toDate = df2.format(dtcToDate.getDate());

                Paragraph slashPara = new Paragraph("Transfer records from " + fromDate + " to " + toDate,
                        FontFactory.getFont(FontFactory.HELVETICA, 15, Font.BOLD));
                slashPara.setSpacingAfter(40);
                slashPara.setAlignment(Element.ALIGN_CENTER);
                document.add(slashPara);

                PdfPTable table = new PdfPTable(5);
                table.setWidthPercentage(100);

                Font font = new Font(FontFamily.HELVETICA, 15, Font.BOLD);
                Paragraph paragraphCellHeading = new Paragraph("Report", font);

                PdfPCell cellHeading = new PdfPCell(paragraphCellHeading);
                BaseColor myColor = WebColors.getRGBColor("#41a5c2");
                cellHeading.setColspan(5);
                cellHeading.setBackgroundColor(myColor);
                cellHeading.setFixedHeight(30.3f);
                cellHeading.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cellHeading.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cellHeading);

                Font fBody = new Font(FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.BLACK);

                PdfPCell cellTitle1 = new PdfPCell(new Phrase("Transfer ID", fBody));
                cellTitle1.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cellTitle1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cellTitle1);
                PdfPCell cellTitle2 = new PdfPCell(new Phrase("Emp ID", fBody));
                cellTitle2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cellTitle2.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cellTitle2);
                PdfPCell cellTitle3 = new PdfPCell(new Phrase("From Project", fBody));
                cellTitle3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cellTitle3.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cellTitle3);
                PdfPCell cellTitle4 = new PdfPCell(new Phrase("To Project", fBody));
                cellTitle4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cellTitle4.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cellTitle4);
                PdfPCell cellTitleStatus = new PdfPCell(new Phrase("Status", fBody));
                cellTitleStatus.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cellTitleStatus.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cellTitleStatus);

                int cellColorCheck = 1;
                for (Transfer e : transferList) {
                    PdfPCell cellBody1 = new PdfPCell(new Phrase(e.getId()));
                    PdfPCell cellBody2 = new PdfPCell(new Phrase(e.getEmployeeId()));
                    PdfPCell cellBody3 = new PdfPCell(new Phrase(e.getFromProjectId()));
                    PdfPCell cellBody4 = new PdfPCell(new Phrase(e.getToProjectId()));
                    PdfPCell cellBody5 = new PdfPCell(new Phrase(e.getStatus()));
                    if (cellColorCheck % 2 == 1) {
                        cellBody1.setBackgroundColor(BaseColor.ORANGE);
                        cellBody2.setBackgroundColor(BaseColor.ORANGE);
                        cellBody3.setBackgroundColor(BaseColor.ORANGE);
                        cellBody4.setBackgroundColor(BaseColor.ORANGE);
                        cellBody5.setBackgroundColor(BaseColor.ORANGE);
                    }
                    table.addCell(cellBody1);
                    table.addCell(cellBody2);
                    table.addCell(cellBody3);
                    table.addCell(cellBody4);
                    table.addCell(cellBody5);
                    cellColorCheck++;
                }

                document.add(table);
                JOptionPane.showMessageDialog(this, "Report saved");

                if (Desktop.isDesktopSupported()) {
                    File reportFile = new File(fileName);
                    Desktop.getDesktop().open(reportFile);
                    ;
                }

                document.close();
            } catch (DocumentException | FileNotFoundException ex) {
                Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (ParseException ex) {
            Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    if (radInProject.isSelected()) {
        String fromProjectId = (String) cbxFromProject.getSelectedItem();
        String toProjectId = (String) cbxToProject.getSelectedItem();
        List<Transfer> transferList = new ArrayList<>();
        String andOr = "";
        if (cbxAndOr.getSelectedItem().equals("And")) {
            andOr = "and";
            transferList = empObj.searchRecordByFromAndToProject(fromProjectId, toProjectId, andOr);
        } else {
            andOr = "or";
            transferList = empObj.searchRecordByFromAndToProject(fromProjectId, toProjectId, andOr);
        }

        Document document = new Document();
        try {
            Font fontTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD);

            String fileName = "../EMPtranfermanagement/Report" + " " + df.format(dateNow) + ".pdf";
            PdfWriter.getInstance(document, new FileOutputStream(fileName));

            document.open();

            Image imageLogo = Image
                    .getInstance(this.getClass().getResource("/images/onlinelogomaker-afterscale2.png"));
            imageLogo.setAbsolutePosition(20, 750f);
            document.add(imageLogo);

            Paragraph titlePara = new Paragraph("EMP Transfer Application", fontTitle);
            titlePara.setAlignment(Element.ALIGN_CENTER);
            titlePara.setSpacingAfter(5);
            document.add(titlePara);

            Paragraph creditPara = new Paragraph("Created by Ly Thanh Hai + Nguyen Khanh",
                    FontFactory.getFont(FontFactory.HELVETICA, 10, Font.ITALIC));
            creditPara.setAlignment(Element.ALIGN_CENTER);
            creditPara.setSpacingAfter(10);
            document.add(creditPara);

            Paragraph slashPara = new Paragraph(
                    "Transfer records from Project ID " + fromProjectId + " " + andOr + " " + toProjectId,
                    FontFactory.getFont(FontFactory.HELVETICA, 15, Font.BOLD));
            slashPara.setSpacingAfter(40);
            slashPara.setAlignment(Element.ALIGN_CENTER);
            document.add(slashPara);

            PdfPTable table = new PdfPTable(5);
            table.setWidthPercentage(100);

            Font font = new Font(FontFamily.HELVETICA, 15, Font.BOLD);
            Paragraph paragraphCellHeading = new Paragraph("Report", font);

            PdfPCell cellHeading = new PdfPCell(paragraphCellHeading);
            BaseColor myColor = WebColors.getRGBColor("#41a5c2");
            cellHeading.setColspan(5);
            cellHeading.setBackgroundColor(myColor);
            cellHeading.setFixedHeight(30.3f);
            cellHeading.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellHeading.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellHeading);

            Font fBody = new Font(FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.BLACK);

            PdfPCell cellTitle1 = new PdfPCell(new Phrase("Transfer ID", fBody));
            cellTitle1.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle1);
            PdfPCell cellTitle2 = new PdfPCell(new Phrase("Emp ID", fBody));
            cellTitle2.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle2.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle2);
            PdfPCell cellTitle3 = new PdfPCell(new Phrase("From Project", fBody));
            cellTitle3.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle3.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle3);
            PdfPCell cellTitle4 = new PdfPCell(new Phrase("To Project", fBody));
            cellTitle4.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle4.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle4);
            PdfPCell cellTitleStatus = new PdfPCell(new Phrase("Status", fBody));
            cellTitleStatus.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitleStatus.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitleStatus);

            int cellColorCheck = 1;
            for (Transfer e : transferList) {
                PdfPCell cellBody1 = new PdfPCell(new Phrase(e.getId()));
                PdfPCell cellBody2 = new PdfPCell(new Phrase(e.getEmployeeId()));
                PdfPCell cellBody3 = new PdfPCell(new Phrase(e.getFromProjectId()));
                PdfPCell cellBody4 = new PdfPCell(new Phrase(e.getToProjectId()));
                PdfPCell cellBody5 = new PdfPCell(new Phrase(e.getStatus()));
                if (cellColorCheck % 2 == 1) {
                    cellBody1.setBackgroundColor(BaseColor.ORANGE);
                    cellBody2.setBackgroundColor(BaseColor.ORANGE);
                    cellBody3.setBackgroundColor(BaseColor.ORANGE);
                    cellBody4.setBackgroundColor(BaseColor.ORANGE);
                    cellBody5.setBackgroundColor(BaseColor.ORANGE);
                }
                table.addCell(cellBody1);
                table.addCell(cellBody2);
                table.addCell(cellBody3);
                table.addCell(cellBody4);
                table.addCell(cellBody5);
                cellColorCheck++;
            }

            document.add(table);
            JOptionPane.showMessageDialog(this, "Report saved");

            if (Desktop.isDesktopSupported()) {
                File reportFile = new File(fileName);
                Desktop.getDesktop().open(reportFile);
                ;
            }

            document.close();
        } catch (DocumentException | FileNotFoundException ex) {
            Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    if (radAllRecord.isSelected()) {
        List<Transfer> transferList = new ArrayList<>();
        transferList = empObj.searchAllRecord();

        Document document = new Document();
        try {
            Font fontTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD);

            String fileName = "../EMPtranfermanagement/Report" + " " + df.format(dateNow) + ".pdf";
            PdfWriter.getInstance(document, new FileOutputStream(fileName));

            document.open();

            Image imageLogo = Image
                    .getInstance(this.getClass().getResource("/images/onlinelogomaker-afterscale2.png"));
            imageLogo.setAbsolutePosition(20, 750f);
            document.add(imageLogo);

            Paragraph titlePara = new Paragraph("EMP Transfer Application", fontTitle);
            titlePara.setAlignment(Element.ALIGN_CENTER);
            titlePara.setSpacingAfter(5);
            document.add(titlePara);

            Paragraph creditPara = new Paragraph("Created by Ly Thanh Hai + Nguyen Khanh",
                    FontFactory.getFont(FontFactory.HELVETICA, 10, Font.ITALIC));
            creditPara.setAlignment(Element.ALIGN_CENTER);
            creditPara.setSpacingAfter(10);
            document.add(creditPara);

            Paragraph slashPara = new Paragraph("All transfer records",
                    FontFactory.getFont(FontFactory.HELVETICA, 15, Font.BOLD));
            slashPara.setSpacingAfter(40);
            slashPara.setAlignment(Element.ALIGN_CENTER);
            document.add(slashPara);

            PdfPTable table = new PdfPTable(5);
            table.setWidthPercentage(100);

            Font font = new Font(FontFamily.HELVETICA, 15, Font.BOLD);
            Paragraph paragraphCellHeading = new Paragraph("Report", font);

            PdfPCell cellHeading = new PdfPCell(paragraphCellHeading);
            BaseColor myColor = WebColors.getRGBColor("#41a5c2");
            cellHeading.setColspan(5);
            cellHeading.setBackgroundColor(myColor);
            cellHeading.setFixedHeight(30.3f);
            cellHeading.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellHeading.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellHeading);

            Font fBody = new Font(FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.BLACK);

            PdfPCell cellTitle1 = new PdfPCell(new Phrase("Transfer ID", fBody));
            cellTitle1.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle1);
            PdfPCell cellTitle2 = new PdfPCell(new Phrase("Emp ID", fBody));
            cellTitle2.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle2.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle2);
            PdfPCell cellTitle3 = new PdfPCell(new Phrase("From Project", fBody));
            cellTitle3.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle3.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle3);
            PdfPCell cellTitle4 = new PdfPCell(new Phrase("To Project", fBody));
            cellTitle4.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle4.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle4);
            PdfPCell cellTitleStatus = new PdfPCell(new Phrase("Status", fBody));
            cellTitleStatus.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitleStatus.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitleStatus);

            int cellColorCheck = 1;
            for (Transfer e : transferList) {
                PdfPCell cellBody1 = new PdfPCell(new Phrase(e.getId()));
                PdfPCell cellBody2 = new PdfPCell(new Phrase(e.getEmployeeId()));
                PdfPCell cellBody3 = new PdfPCell(new Phrase(e.getFromProjectId()));
                PdfPCell cellBody4 = new PdfPCell(new Phrase(e.getToProjectId()));
                PdfPCell cellBody5 = new PdfPCell(new Phrase(e.getStatus()));
                if (cellColorCheck % 2 == 1) {
                    cellBody1.setBackgroundColor(BaseColor.ORANGE);
                    cellBody2.setBackgroundColor(BaseColor.ORANGE);
                    cellBody3.setBackgroundColor(BaseColor.ORANGE);
                    cellBody4.setBackgroundColor(BaseColor.ORANGE);
                    cellBody5.setBackgroundColor(BaseColor.ORANGE);
                }
                table.addCell(cellBody1);
                table.addCell(cellBody2);
                table.addCell(cellBody3);
                table.addCell(cellBody4);
                table.addCell(cellBody5);
                cellColorCheck++;
            }

            document.add(table);
            JOptionPane.showMessageDialog(this, "Report saved");

            if (Desktop.isDesktopSupported()) {
                File reportFile = new File(fileName);
                Desktop.getDesktop().open(reportFile);
                ;
            }

            document.close();
        } catch (DocumentException | FileNotFoundException ex) {
            Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}

From source file:proyectopdf.Pleno.java

public static void main(String a[]) throws FileNotFoundException, DocumentException, IOException {
    String ae;//from ww  w .  j  a  v a  2s  .  c o m
    JFileChooser jfc = new JFileChooser();
    jfc.showOpenDialog(null);
    BufferedReader archivo = new BufferedReader(new FileReader(jfc.getSelectedFile().getPath()));
    FileOutputStream nuevo = new FileOutputStream("hola.pdf");
    Document documento = new Document();
    PdfWriter.getInstance(documento, nuevo);
    documento.open();
    String w;
    while (archivo.ready()) {

        ae = archivo.readLine();

        StringTokenizer tituloI = new StringTokenizer(ae, "{T}{#T}{C}{#C}{P}{#P}{S}{#S}");

        while (tituloI.hasMoreTokens()) {
            String a1 = tituloI.nextToken();
            w = a1;

            documento.add(new Paragraph(a1, FontFactory.getFont("arial", // fuente
                    22, // tamao
                    Font.ITALIC, // estilo
                    BaseColor.BLUE)));
        }

        String a2 = "";

        while (tituloI.hasMoreTokens()) {
            a2 = tituloI.nextToken();
            documento.add(new Paragraph(a2, FontFactory.getFont("arial", // fuente
                    22, // tamao
                    Font.ITALIC, // estilo
                    BaseColor.RED)));
        }

        String a3 = "";
        while (tituloI.hasMoreTokens()) {
            a3 = tituloI.nextToken();
            documento.add(new Paragraph(a3, FontFactory.getFont("arial", // fuente
                    22, // tamao
                    Font.ITALIC, // estilo
                    BaseColor.CYAN)));
        }

        String a4 = "";
        while (tituloI.hasMoreTokens()) {
            a4 = tituloI.nextToken();
            documento.add(new Paragraph(a4, FontFactory.getFont("arial", // fuente
                    22, // tamao
                    Font.ITALIC, // estilo
                    BaseColor.YELLOW)));
        }
        System.out.println(archivo.readLine());
    }
    documento.close();
}