Example usage for com.itextpdf.text Chapter Chapter

List of usage examples for com.itextpdf.text Chapter Chapter

Introduction

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

Prototype

public Chapter(String title, int number) 

Source Link

Document

Constructs a new Chapter.

Usage

From source file:org.sharegov.cirm.utils.PDFViewReport.java

License:Apache License

public void errorReport(OutputStream out) {
    if (DBG)/*from ww w  . j  ava2  s  .  c  o m*/
        System.out.println("Start: PDF errorReport");
    try {
        Date date = new Date();
        setTime(formatDate(date, true, false));
        Document doc = new Document(PageSize.A4);
        doc.setMargins(9, 9, doc.topMargin(), doc.bottomMargin());
        PdfWriter writer = PdfWriter.getInstance(doc, out);
        TableHeader th = new TableHeader();
        writer.setPageEvent(th);
        doc.open();

        Chapter chapter = new Chapter(new Paragraph(), 1);
        chapter.setNumberDepth(0);
        addSection(chapter).add(new Phrase(" "));
        addSection(chapter).add(new Phrase(" "));
        addSection(chapter).add(new Phrase(genericErrorMsg));
        doc.add(chapter);
        doc.close();
    } catch (DocumentException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
    if (DBG)
        System.out.println("Done: PDF errorReport");
}

From source file:org.tvd.thptty.management.util.Report.java

private void addContent(Document document) throws DocumentException {
    Anchor anchor = new Anchor("First Chapter", catFont);
    anchor.setName("First Chapter");

    // Second parameter is the number of the chapter
    Chapter catPart = new Chapter(new Paragraph(anchor), 1);

    Paragraph subPara = new Paragraph("Subcategory 1", subFont);
    Section subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("Hello"));

    subPara = new Paragraph("Subcategory 2", subFont);
    subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("Paragraph 1"));
    subCatPart.add(new Paragraph("Paragraph 2"));
    subCatPart.add(new Paragraph("Paragraph 3"));

    // Add a list
    createList(subCatPart);//from   w w w  .ja v  a2s .  c  o m
    Paragraph paragraph = new Paragraph();
    addEmptyLine(paragraph, 5);

    paragraph.setFont(smallBold);
    // Add a table
    paragraph.add(createTable(subCatPart));
    subCatPart.add(paragraph);

    // Now add all this to the document
    document.add(catPart);

    // Next section
    anchor = new Anchor("Second Chapter", catFont);
    anchor.setName("Second Chapter");

    // Second parameter is the number of the chapter
    catPart = new Chapter(new Paragraph(anchor), 1);

    subPara = new Paragraph("Subcategory", subFont);
    subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("This is a very important message"));

    // Now add all this to the document
    document.add(catPart);

}

From source file:others.pdfWriter.java

private static void addContent(Document document) throws DocumentException {
    Anchor anchor = new Anchor("First Chapter", catFont);
    anchor.setName("First Chapter");

    // Second parameter is the number of the chapter
    Chapter catPart = new Chapter(new Paragraph(anchor), 1);

    Paragraph subPara = new Paragraph("Subcategory 1", subFont);
    Section subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("Hello"));

    subPara = new Paragraph("Subcategory 2", subFont);
    subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("Paragraph 1"));
    subCatPart.add(new Paragraph("Paragraph 2"));
    subCatPart.add(new Paragraph("Paragraph 3"));

    // add a list
    createList(subCatPart);/*from w  ww. j av  a2  s . c om*/
    Paragraph paragraph = new Paragraph();
    addEmptyLine(paragraph, 5);
    subCatPart.add(paragraph);

    // add a table
    //    createTableExercicios(subCatPart);

    // now add all this to the document
    document.add(catPart);

    // Next section
    anchor = new Anchor("Second Chapter", catFont);
    anchor.setName("Second Chapter");

    // Second parameter is the number of the chapter
    catPart = new Chapter(new Paragraph(anchor), 1);

    subPara = new Paragraph("Subcategory", subFont);
    subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("This is a very important message"));

    // now add all this to the document
    document.add(catPart);

}

From source file:our.isaacmayur.expensemanager.GenerateReport.java

private static void addContent(Document document) throws DocumentException {

    Anchor anchor = new Anchor("Expense Report", catFont);
    anchor.setName("Expense Report");

    // Second parameter is the number of the chapter
    Chapter catPart = new Chapter(new Paragraph(anchor), 1);

    Paragraph paragraph = new Paragraph();
    paragraph.add(new Paragraph("Report generated on " + new Date(), smallBold));

    addEmptyLine(paragraph, 3);/*ww  w  .ja  v a  2  s  .  co  m*/

    catPart.add(paragraph);
    // Paragraph subPara = new Paragraph("Expense Table 1", subFont);
    // Section subCatPart = catPart.addSection(subPara);

    // subCatPart.add(new Paragraph("Expense"));

    // subPara = new Paragraph("Subcategory 2", subFont);
    // subCatPart = catPart.addSection(subPara);
    // subCatPart.add(new Paragraph("Paragraph 1"));
    // subCatPart.add(new Paragraph("Paragraph 2"));
    // subCatPart.add(new Paragraph("Paragraph 3"));
    //
    // add a list
    // createList(subCatPart);
    // Paragraph paragraph = new Paragraph();
    // addEmptyLine(paragraph, 5);
    // subCatPart.add(paragraph);

    // add a table

    createTable(catPart);

    // now add all this to the document
    // document.add(catPart);

    // Next section
    // anchor = new Anchor("Second Chapter", catFont);
    // anchor.setName("Second Chapter");

    // Second parameter is the number of the chapter
    // catPart = new Chapter(new Paragraph(anchor), 1);

    // subPara = new Paragraph("Subcategory", subFont);
    // subCatPart = catPart.addSection(subPara);
    // subCatPart.add(new Paragraph("This is a very important message"));

    // now add all this to the document
    document.add(catPart);

    Log.e("meta", "content");

}

From source file:pdf.PDFdescriptiva.java

private static void agregarContenido(Document document, String titulo, String[][] arreglo, Integer N,
        String[] variables) throws DocumentException {

    agregarTabla(document, titulo, arreglo);

    Anchor anchor = new Anchor("Datos", catFont);
    anchor.setName("Datos");
    Chapter catPart = new Chapter(new Paragraph(anchor), 1);

    Paragraph subPara = new Paragraph("Variables", subFont);
    Section subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("N: " + N));
    subCatPart.add(new Paragraph("Maximo: " + variables[0]));
    subCatPart.add(new Paragraph("Minimo: " + variables[1]));
    subCatPart.add(new Paragraph("Rango: " + variables[2]));
    subCatPart.add(new Paragraph("Intervalos: " + variables[3]));
    subCatPart.add(new Paragraph("Amplitud: " + variables[4]));
    subCatPart.add(new Paragraph("Rango Ampliado: " + variables[5]));
    subCatPart.add(new Paragraph("Dif Rangos: " + variables[6]));
    subCatPart.add(new Paragraph("LIPI: " + variables[7]));
    subCatPart.add(new Paragraph("LSUI: " + variables[8]));
    subCatPart.add(new Paragraph("Desv Media: " + variables[9]));
    subCatPart.add(new Paragraph("Varianza: " + variables[10]));
    subCatPart.add(new Paragraph("Desv Estandar: " + variables[11]));
    subCatPart.add(new Paragraph("Media: " + variables[12]));
    subCatPart.add(new Paragraph("Mediana: " + variables[13]));
    subCatPart.add(new Paragraph("Moda: " + variables[14]));

    document.add(catPart);//w ww .j  av a  2  s .c o m
}

From source file:pdf.PDFmultiple.java

private static void agregarContenido(Document document, String titulo, String[][] arreglo, Integer N, Double b0,
        Double b1, Double b2, Double Se, Double[] prediccion) throws DocumentException {

    agregarTabla(document, titulo, arreglo);

    Anchor anchor = new Anchor("Datos", catFont);
    anchor.setName("Datos");
    Chapter catPart = new Chapter(new Paragraph(anchor), 1);

    Paragraph subPara = new Paragraph("Variables", subFont);
    Section subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("N: " + N));
    subCatPart.add(new Paragraph("K: 2"));
    subCatPart.add(new Paragraph("b0: " + b0));
    subCatPart.add(new Paragraph("b1: " + b1));
    subCatPart.add(new Paragraph("b2: " + b2));
    subCatPart.add(new Paragraph("Se: " + Se));
    Paragraph espacio = new Paragraph();
    addEmptyLine(espacio, 1);/*from   w  ww.ja v a  2  s  .com*/
    subCatPart.add(espacio);
    subPara = new Paragraph("Predicciones", subFont);
    subCatPart = catPart.addSection(subPara);
    if (prediccion[0] != null && prediccion[1] != null && prediccion[2] != null && prediccion[3] != null
            && prediccion[4] != null && prediccion[5] != null) {
        subCatPart.add(new Paragraph("X1: " + prediccion[0]));
        subCatPart.add(new Paragraph("X2: " + prediccion[1]));
        subCatPart.add(new Paragraph("Efectividad: " + prediccion[2]));
        addEmptyLine(espacio, 1);
        subCatPart.add(espacio);
        tablaPrediccion(subCatPart, prediccion[3], prediccion[4], prediccion[5]);
    } else {
        subCatPart.add(new Paragraph("No se realiz ninguna prediccion."));
    }

    document.add(catPart);
}

From source file:pdf.PDFsimple.java

private static void agregarContenido(Document document, String titulo, String[][] arreglo, Integer N, Double b0,
        Double b1, Double Se, Double dx, Double dy, Double dxy, Double r, Double[] prediccion)
        throws DocumentException {

    agregarTabla(document, titulo, arreglo);

    Anchor anchor = new Anchor("Datos", catFont);
    anchor.setName("Datos");
    Chapter catPart = new Chapter(new Paragraph(anchor), 1);
    //comentario// ww w  .java  2s.c  o m
    Paragraph subPara = new Paragraph("Variables", subFont);
    Section subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("N: " + N));
    subCatPart.add(new Paragraph("K: 1"));
    subCatPart.add(new Paragraph("b0: " + b0));
    subCatPart.add(new Paragraph("b1: " + b1));
    subCatPart.add(new Paragraph("Se: " + Se));
    subCatPart.add(new Paragraph("DX: " + dx));
    subCatPart.add(new Paragraph("DY: " + dy));
    subCatPart.add(new Paragraph("DXY: " + dxy));
    subCatPart.add(new Paragraph("R: " + r));
    Paragraph espacio = new Paragraph();
    addEmptyLine(espacio, 1);
    subCatPart.add(espacio);
    subPara = new Paragraph("Predicciones", subFont);
    subCatPart = catPart.addSection(subPara);
    if (prediccion[0] != null && prediccion[1] != null && prediccion[2] != null && prediccion[3] != null
            && prediccion[4] != null) {
        subCatPart.add(new Paragraph("X: " + prediccion[0]));
        subCatPart.add(new Paragraph("Efectividad: " + prediccion[1]));
        addEmptyLine(espacio, 1);
        subCatPart.add(espacio);
        tablaPrediccion(subCatPart, prediccion[2], prediccion[3], prediccion[4]);
    } else {
        subCatPart.add(new Paragraph("No se realiz ninguna prediccion."));
    }

    document.add(catPart);
}

From source file:pdf.PdfUtility.java

private void addData(Document document) {
    List<? extends Achievement> allData = ServiceLocator.findLifetimeService().getAchievements(userId,
            language);/*from   ww  w  . j a v a2s .co  m*/
    Collections.sort(allData, comparator);

    Chapter info = new Chapter(getSectionTitle(getTranslation("Achievements", language)), 0);
    info.setNumberDepth(0);
    info.setTriggerNewPage(false);

    boolean first = true;
    for (Achievement a : allData) {
        if (isInRange(a)) {
            achievements.add(a);
            Paragraph current = addTableEntry(a);
            if (first) {
                current.setSpacingBefore(5f);
            }
            info.addSection(current, 0);
        }
    }
    //info.add(Chunk.NEWLINE);
    try {
        document.add(info);
    } catch (DocumentException ex) {
        Logger.getLogger(PdfUtility.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:pdfgen.pdf_generation_try5.java

public void addContent(Document document) throws DocumentException {
    Anchor anchor = new Anchor("Chapter 1: used for various paragraphs", catFont);
    anchor.setName("First Chapter");

    // Second parameter is the number of the chapter
    Chapter catPart = new Chapter(new Paragraph(anchor), 1);

    Paragraph subPara = new Paragraph("Subcategory 1", subFont);
    Section subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("Hello"));

    subPara = new Paragraph("Subcategory 2", subFont);
    subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("Paragraph 1"));
    subCatPart.add(new Paragraph("Paragraph 2"));
    subCatPart.add(new Paragraph("Paragraph 3"));

    // add a list
    createList(subCatPart);/* w  w  w  . ja v a 2  s  .c  o  m*/
    Paragraph paragraph = new Paragraph();
    addEmptyLine(paragraph, 5);
    subCatPart.add(paragraph);

    // add a table
    createTable(subCatPart);

    // now add all this to the document
    document.add(catPart);

    // Next section
    anchor = new Anchor("Second Chapter : only for checking", catFont);
    anchor.setName("Second Chapter");

    // Second parameter is the number of the chapter
    catPart = new Chapter(new Paragraph(anchor), 1);

    subPara = new Paragraph("Subcategory", subFont);
    subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("This is a very important message"));

    // now add all this to the document
    document.add(catPart);

}

From source file:project1.GENERALCV.java

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

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

    address = txtAddress.getText();

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

    String link = txtLink.getText();

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

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

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

    references = txtreference.getText();

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

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

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

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

        showRecords();

    } catch (Exception e) {

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

    }

    Statement statement;

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

        statement = con.createStatement();

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

        while (rs.next()) {

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

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

    int newcvid = ss;

    try {

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

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

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

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

        Chapter chapter1 = new Chapter(title1, 1);

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

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

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

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

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

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

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

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

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

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

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

        document.add(table);

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

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

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

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

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

    } catch (Exception e) {

        e.printStackTrace();
    }
}