Example usage for com.itextpdf.text Font UNDERLINE

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

Introduction

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

Prototype

int UNDERLINE

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

Click Source Link

Document

this is a possible style.

Usage

From source file:PROCESOS.ImprimirPDF.java

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("application/pdf");
    String precio_unitario = request.getParameter("precio");

    String id_vale = request.getParameter("codigo");

    //  if(request.getParameter("codigo")!=null){
    OutputStream salida = response.getOutputStream();
    try {// w  ww  . j  a  v  a  2 s.  com

        try {

            DTO.ClaseTransaccion clase = new ClaseTransaccion();
            clase = consulta.Transaccion();
            Document documento = new Document(PageSize.A4, 36, 36, 45, 20);
            PdfWriter pw = PdfWriter.getInstance(documento, salida);
            documento.open();
            Paragraph parrafo1 = new Paragraph();
            Font font_titulo = new Font(Font.FontFamily.HELVETICA, 16, Font.UNDERLINE, BaseColor.BLACK);
            parrafo1.add(new Phrase("TecnoBencina, COMPROBANTE", font_titulo));
            parrafo1.setAlignment(Element.ALIGN_CENTER);
            parrafo1.add(new Phrase(Chunk.NEWLINE));
            parrafo1.add(new Phrase(Chunk.NEWLINE));
            documento.add(parrafo1);

            Paragraph parrafo2 = new Paragraph();
            Font font_titulo_p2 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK);

            if (id_vale.length() > 0) {
                parrafo2.add(new Phrase("Comprobante de transaccion : codigo del vale : " + id_vale,
                        font_titulo_p2));
            } else {
                parrafo2.add(new Phrase("Comprobante de transaccion ", font_titulo_p2));
            }

            parrafo2.setAlignment(Element.ALIGN_JUSTIFIED);
            parrafo2.add(new Phrase(Chunk.NEWLINE));
            parrafo2.add(new Phrase(Chunk.NEWLINE));
            parrafo2.add(new Phrase(Chunk.NEWLINE));
            documento.add(parrafo2);

            PdfPTable tabla = new PdfPTable(9);
            PdfPCell celda1 = new PdfPCell(new Paragraph("ID transaccion ",
                    FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda2 = new PdfPCell(
                    new Paragraph("Estado ", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda3 = new PdfPCell(new Paragraph("ID de surtidor",
                    FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda4 = new PdfPCell(
                    new Paragraph("Litros", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda5 = new PdfPCell(
                    new Paragraph("Monto", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda6 = new PdfPCell(
                    new Paragraph("Fecha", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda7 = new PdfPCell(
                    new Paragraph("ID pago", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda8 = new PdfPCell(new Paragraph("Precio unitario",
                    FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));

            tabla.addCell(celda1);
            tabla.addCell(celda2);
            tabla.addCell(celda3);
            tabla.addCell(celda4);
            tabla.addCell(celda5);
            tabla.addCell(celda6);
            tabla.addCell(celda7);
            tabla.addCell(celda8);

            tabla.addCell(String.valueOf(clase.getId_transaccion()));
            tabla.addCell(clase.getEstado());
            tabla.addCell(String.valueOf(clase.getId_transaccion()));
            tabla.addCell(String.valueOf(clase.getLitros()));
            tabla.addCell(String.valueOf(clase.getMonto()));
            tabla.addCell(String.valueOf(clase.getFecha()));
            tabla.addCell(String.valueOf(clase.getId_pago()));
            tabla.addCell(precio_unitario);

            documento.add(tabla);
            documento.addAuthor("TecnoBencina");
            documento.addTitle("Comprobante");
            documento.addLanguage("Espaol");
            documento.add(new Paragraph(new Phrase(Chunk.NEWLINE)));
            documento.add(new Paragraph(new Phrase(Chunk.NEWLINE)));

            documento.add(new Paragraph(new Phrase(Chunk.NEWLINE)));
            documento.add(new Paragraph(new Phrase(Chunk.NEWLINE)));
            documento.add(new Paragraph("texto....", font_titulo_p2));
            documento.close();
        } catch (Exception s) {
            s.getMessage();
        }

    } catch (Exception s) {
        System.out.println("" + s.getMessage());
    } finally {
        salida.close();
    }
    // }
}

From source file:qcas.QuizResultsController.java

public void exportToPdf() throws IOException, DocumentException {

    String s = "";
    for (int i = 0; i < this.userAnswers.size(); i++) {
        s += "Question ".toUpperCase() + (i + 1) + ": " + "\t Your Answer: ".toUpperCase()
                + this.userAnswers.get(i) + "\t Correct Answer: ".toUpperCase() + this.userAnswerCheck.get(i)
                + "\n\n";
    }//from  www .  j av  a2s .  c  om

    WritableImage image = QuizResultsDashboardPane.snapshot(new SnapshotParameters(), null);

    File file = new File("Student Report.png");

    ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", file);

    Document document = new Document();
    String input = "Student Report.png"; // .gif and .jpg are ok too!
    String output = "Student Report.pdf";
    try {
        FileOutputStream fos = new FileOutputStream(output);
        PdfWriter writer = PdfWriter.getInstance(document, fos);
        writer.open();
        document.open();
        ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();

        ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", byteOutput);

        com.itextpdf.text.Image graph;
        graph = com.itextpdf.text.Image.getInstance(byteOutput.toByteArray());
        graph.scaleToFit(500, 500);
        document.add((com.itextpdf.text.Element) graph);
        Font f = new Font(FontFamily.TIMES_ROMAN, 10.0f, Font.UNDERLINE, BaseColor.BLACK);
        Paragraph p = new Paragraph(s, f);
        document.add(p);

        document.close();
        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    QuizResultsDashboardPane.setVisible(true);

}

From source file:ResumeBuilder.resumeGenerator.java

void createResume() throws IOException {
    Document resume = new Document();
    try {/*  w  w w .  ja v  a2s . c  o m*/

        PdfWriter.getInstance(resume, new FileOutputStream("resume.pdf"));
        resume.open();
        LineSeparator line;
        line = new LineSeparator();
        Font f = new Font();
        resume.add(Chunk.NEWLINE);
        String space = "";
        Font font2 = new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD | Font.UNDERLINE);
        resume.add(new Paragraph("RESUME", font2));
        Paragraph name = new Paragraph((String) details.get("Name"));
        name.setAlignment(Paragraph.ALIGN_LEFT);
        resume.add(name);
        Paragraph email = new Paragraph((String) details.get("Email"));
        email.setAlignment(Paragraph.ALIGN_RIGHT);
        resume.add(email);
        Paragraph contact = new Paragraph((String) details.get("ContactNumber"));
        contact.setAlignment(Paragraph.ALIGN_RIGHT);
        resume.add(contact);
        resume.add(Chunk.NEWLINE);
        resume.add(line);
        resume.add(Chunk.NEWLINE);
        Font font1 = new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD | Font.UNDERLINE);
        resume.add(new Chunk("Qulaification ", font1));
        resume.add(Chunk.NEWLINE);
        PdfPTable table = new PdfPTable(3);
        PdfPCell cell1 = new PdfPCell(new Paragraph("College"));
        PdfPCell cell2 = new PdfPCell(new Paragraph("Percentage"));
        PdfPCell cell3 = new PdfPCell(new Paragraph("Date"));
        PdfPCell cell4;
        cell4 = new PdfPCell(new Paragraph((String) details.get("SchoolX")));
        resume.add(cell4);
        resume.add(Chunk.NEWLINE);
        PdfPCell cell5 = new PdfPCell(new Paragraph((String) details.get("PercentageX")));
        resume.add(cell5);
        PdfPCell cell6;
        cell6 = new PdfPCell(new Paragraph((String) details.get("Date X")));
        resume.add(cell6);
        PdfPCell cell7;
        cell7 = new PdfPCell(new Paragraph((String) details.get("SchoolXII")));
        resume.add(cell7);
        resume.add(Chunk.NEWLINE);
        PdfPCell cell8 = new PdfPCell(new Paragraph((String) details.get("PercentageXII")));
        resume.add(cell8);
        PdfPCell cell9;
        cell9 = new PdfPCell(new Paragraph((String) details.get("Date XII")));
        resume.add(cell9);
        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(cell9);
        resume.add(table);
        resume.add(Chunk.NEWLINE);
        Font font3;
        font3 = new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD | Font.UNDERLINE);
        resume.add(new Chunk("Graduation and PostGraduation ", font1));
        //resume.add(Chunk.NEWLINE);
        PdfPTable table1;
        table1 = new PdfPTable(4);
        PdfPCell cell10 = new PdfPCell(new Paragraph(" College"));
        PdfPCell cell11 = new PdfPCell(new Paragraph("University"));
        PdfPCell cell12 = new PdfPCell(new Paragraph("CGPA"));
        PdfPCell cell13 = new PdfPCell(new Paragraph("DATE"));
        PdfPCell cell14;
        cell14 = new PdfPCell(new Paragraph((String) details.get("GraduationCollege")));
        resume.add(cell14);
        resume.add(Chunk.NEWLINE);
        PdfPCell cell15 = new PdfPCell(new Paragraph((String) details.get("GraduateUniversity")));
        resume.add(cell15);
        resume.add(Chunk.NEWLINE);
        PdfPCell cell16 = new PdfPCell(new Paragraph((String) details.get("GraduationCGPA")));
        resume.add(cell16);
        PdfPCell cell17;
        cell17 = new PdfPCell(new Paragraph((String) details.get("Graduation date")));
        resume.add(cell7);
        PdfPCell cell18;
        cell18 = new PdfPCell(new Paragraph((String) details.get("PostGraduationCollege")));
        resume.add(cell8);
        resume.add(Chunk.NEWLINE);
        PdfPCell cell19;
        cell19 = new PdfPCell(new Paragraph((String) details.get("PostGraduateUniversity")));
        resume.add(cell19);
        PdfPCell cell20;
        cell20 = new PdfPCell(new Paragraph((String) details.get("PostGraduateCGPA")));
        resume.add(cell20);
        PdfPCell cell21;
        cell21 = new PdfPCell(new Paragraph((String) details.get("Post Graduation date")));
        resume.add(cell21);
        table1.addCell(cell10);
        table1.addCell(cell11);
        table1.addCell(cell12);
        table1.addCell(cell13);
        table1.addCell(cell14);
        table1.addCell(cell15);
        table1.addCell(cell16);
        table1.addCell(cell17);
        table1.addCell(cell18);
        table1.addCell(cell19);
        table1.addCell(cell20);
        table1.addCell(cell21);
        resume.add(table1);
        Font font4;
        font4 = new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD | Font.UNDERLINE);
        resume.add(new Chunk("Skills", font1));
        resume.add(Chunk.NEWLINE);
        resume.add(Chunk.NEWLINE);
        Paragraph name1;
        name1 = new Paragraph((String) details.get("Skills"));
        name1.setIndentationLeft(50);
        resume.add(name1);
        Font font5;
        font5 = new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD | Font.UNDERLINE);
        resume.add(new Chunk("Projects", font1));
        resume.add(Chunk.NEWLINE);
        Paragraph name2;
        name2 = new Paragraph((String) details.get("ProjectName1"));
        name2.setIndentationLeft(50);
        resume.add(name2);
        resume.add(Chunk.NEWLINE);
        Paragraph name3;
        name3 = new Paragraph((String) details.get("projectDescription1"));
        name3.setIndentationLeft(50);
        resume.add(name3);
        resume.add(Chunk.NEWLINE);
        Paragraph name4;
        name4 = new Paragraph((String) details.get("ProjectName2"));
        name4.setIndentationLeft(50);
        resume.add(name4);
        resume.add(Chunk.NEWLINE);
        Paragraph name5;
        name5 = new Paragraph((String) details.get("projectDescription2"));
        name5.setIndentationLeft(50);
        resume.add(name5);
        resume.add(Chunk.NEWLINE);
        Paragraph name6;
        name6 = new Paragraph((String) details.get("ProjectName3"));
        name6.setIndentationLeft(50);
        resume.add(name6);
        Paragraph name7;
        name7 = new Paragraph((String) details.get("projectDescription3"));
        name7.setIndentationLeft(50);
        resume.add(name7);
        resume.add(Chunk.NEWLINE);
        Paragraph name8;
        name8 = new Paragraph((String) details.get("ProjectName4"));
        name8.setIndentationLeft(50);
        resume.add(name8);
        Paragraph name9;
        name9 = new Paragraph((String) details.get("projectDescription4"));
        name9.setIndentationLeft(50);
        resume.add(name9);
        resume.close();

    } catch (DocumentException | FileNotFoundException e) {
        System.out.println(e.getMessage());
    }
    File file = new File("resume.pdf");
    Desktop.getDesktop().open(file);

}