Example usage for com.itextpdf.text Paragraph add

List of usage examples for com.itextpdf.text Paragraph add

Introduction

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

Prototype

@Override
public boolean add(Element o) 

Source Link

Document

Adds an Element to the Paragraph.

Usage

From source file:com.util.Imprimir.java

public static void addTitlePage(Document document) throws DocumentException {
    Paragraph preface = new Paragraph();
    // We add one empty line
    addEmptyLine(preface, 1);//from www .  jav  a2s .c  o m
    // Lets write a big header
    preface.add(new Paragraph("Titulo do documento", catFont));

    addEmptyLine(preface, 1);
    // Will create: Report generated by: _name, _date
    preface.add(new Paragraph("Relatrio criado por: " + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            smallBold));
    addEmptyLine(preface, 3);
    preface.add(new Paragraph("This document describes something which is very important ", smallBold));

    addEmptyLine(preface, 8);

    preface.add(new Paragraph(
            "This document is a preliminary version and not subject to your license agreement or any other agreement with vogella.com ;-).",
            redFont));

    document.add(preface);
    // Start a new page
    document.newPage();
}

From source file:com.wesley.creche.services.pdf.createHrPdf.java

private static void addEmptyLine(Document document, int number) throws DocumentException {
    Paragraph paragraph = new Paragraph();
    for (int i = 0; i < number; i++) {
        paragraph.add(new Paragraph(" "));
        document.add(paragraph);/*w w  w .j  a v a2s . co m*/
    }
}

From source file:com.wesley.creche.services.pdf.createHrPdf.java

private static void addLine(Document document) throws DocumentException {
    Paragraph paragraph = new Paragraph();
    paragraph.add(new Paragraph(
            "-----------------------------------------------------------------------------------"));
    document.add(paragraph);/*from   w  ww  .j ava  2  s  . c o m*/
}

From source file:com.wesley.creche.services.pdf.createHrPdf.java

private static void addTitle(Document document) throws DocumentException {
    Paragraph preface = new Paragraph();
    // We add one empty line
    addEmptyLine(preface, 1);//from   w  ww. j  a  v a2s  .  co m
    // Lets write a big header
    preface.add(new Paragraph("Staff / Human Resources Report", catFont));

    addEmptyLine(preface, 1);

    preface.add(new Paragraph("Report generated on: " + new Date(), smallBold));

    document.add(preface);
}

From source file:com.wesley.creche.services.pdf.createPdf.java

private static void addTitle(Document document) throws DocumentException {
    Paragraph preface = new Paragraph();
    // We add one empty line
    addEmptyLine(preface, 1);//from   w ww.  ja  va2  s  .c o  m
    // Lets write a big header
    preface.add(new Paragraph("Financial Statement", catFont));

    addEmptyLine(preface, 1);

    preface.add(new Paragraph("Report generated on: " + new Date(), smallBold));

    document.add(preface);
}

From source file:com.wesley.creche.services.pdf.createPdf.java

public void writePdfFinancialReport(String name, String startDate, String accStatus, String amountDue)
        throws DocumentException, IOException {

    createFolderIfNotExist();//from   w w  w .j  a v a 2  s  .  co  m
    SQLQueries s = new SQLQueries();

    String lastName = "";

    try {
        lastName = s.getChildSurnameByName(name);
    } catch (SQLException | ClassNotFoundException ex) {
        System.out.println(ex);
    }

    Date date = new Date();
    DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
    String today = df.format(date);
    String fileName = "C:\\creche\\reports\\" + name + today + "_.pdf";

    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(fileName));

    document.open();

    addTitle(document);
    addLine(document);

    document.add(new Paragraph("Name : " + name + " " + lastName, italic));
    addEmptyLine(document, 2);

    Paragraph paragraph = new Paragraph();
    paragraph.add("Start Date :");
    paragraph.setTabSettings(new TabSettings());
    paragraph.add(Chunk.TABBING);
    paragraph.add(new Chunk(startDate));
    document.add(paragraph);

    addEmptyLine(document, 1);
    document.add(new Paragraph("Account Status : " + accStatus));
    addEmptyLine(document, 1);

    document.add(new Paragraph("Total Amount Outstanding : R" + amountDue));
    addEmptyLine(document, 3);

    addLine(document);
    document.add(new Paragraph("For any queries, please contact Administration : 10111"));

    document.close();
}

From source file:com.whippet.pdf.PDFTitlePage.java

public void addTitlePage() throws DocumentException {
    Paragraph preface = new Paragraph();
    // We add one empty line
    PDFUtils.addEmptyLine(preface, 1);//from   ww  w  .  ja v a 2 s  .co m
    // Lets write a big header
    preface.add(new Paragraph("Title of the document", catFont));

    PDFUtils.addEmptyLine(preface, 1);
    // Will create: Report generated by: _name, _date
    preface.add(new Paragraph("Report generated by: " + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            smallBold));
    PDFUtils.addEmptyLine(preface, 3);
    preface.add(new Paragraph("This document describes something which is very important ", smallBold));

    PDFUtils.addEmptyLine(preface, 8);

    preface.add(new Paragraph(
            "This document is a preliminary version and not subject to your license agreement or any other agreement with vogella.com ;-).",
            redFont));

    document.add(preface);
    // Start a new page
    // document.newPage();
}

From source file:com.wipro.srs.service.PrintTicket.java

private void addTitlePage(Document document) throws DocumentException {
    Paragraph preface = new Paragraph();
    // We add one empty line
    addEmptyLine(preface, 1);//from   w w  w .j ava  2 s . c o m
    // Lets write a big header
    preface.add(new Paragraph("Title of the document", catFont));

    addEmptyLine(preface, 1);
    // Will create: Report generated by: _name, _date
    preface.add(new Paragraph("Ticket generated by: " + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            smallBold));
    addEmptyLine(preface, 3);
    preface.add(new Paragraph("This is an autogenerated document", smallBold));

    addEmptyLine(preface, 8);

    preface.add(new Paragraph(
            "This document is a preliminary version and not subject to your license agreement or any other agreement with MaverickShipServices.com ;-).",
            redFont));

    document.add(preface);
    // Start a new page
    document.newPage();
}

From source file:com.workhub.utils.PDFUtils.java

private static void addTitlePage(Document document, String title, List<ElementModel> models, String creator)
        throws DocumentException {
    Paragraph preface = new Paragraph();
    // We add one empty line
    addEmptyLine(preface, 1);//from ww  w  .j a  v a  2  s  .  c  o  m
    // Lets write a big header
    Paragraph titleParag = new Paragraph(title, catFont);
    titleParag.setAlignment(Element.ALIGN_CENTER);
    preface.add(titleParag);

    addEmptyLine(preface, 1);
    // Will create: Report generated by: _name, _date
    // 1. Choix de la langue
    Locale locale = Locale.getDefault();

    /** 2. Construction du DateFormat en choisiant un format :
     * SHORT = 01/01/2002
     * FULL = lundi 1 janvier 2002
     */
    DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.FULL, locale);
    preface.add(new Paragraph("Rapport gnr par: " + creator + ", " + dateFormat.format(new Date()), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            smallBold));
    addEmptyLine(preface, 3);
    preface.add(new Paragraph("Ce document reprend les contenus suivants: ", subFont));

    addEmptyLine(preface, 1);
    Paragraph sommaire = new Paragraph("", smallBold);
    preface.add(sommaire);
    createList(sommaire, models);
    /*preface.add(new Paragraph("This document is a preliminary version and not subject to your license agreement or any other agreement with vogella.com ;-).",
    redFont));
     */

    document.add(preface);
    // Start a new page
    document.newPage();
}

From source file:com.workhub.utils.PDFUtils.java

private static void addContent(Document document, List<ElementModel> models) throws DocumentException {
    for (int i = 0; i < models.size(); i++) {
        ElementModel elementModel = models.get(i);
        Anchor anchor = new Anchor(elementModel.getTitle(), catFont);
        anchor.setName(elementModel.getTitle());
        // Second parameter is the number of the chapter
        Chapter catPart = new Chapter(new Paragraph(anchor), i + 1);

        Paragraph content = new Paragraph();
        catPart.add(content);//from w  ww  .j  a  va 2 s .  c  om
        addEmptyLine(content, 2);

        switch (elementModel.getType()) {
        case Constants.TYPE_ELEMENT_TEXT:
            content.add(new Paragraph(((TextElementModel) elementModel).getContent(), smallBold));

            break;
        case Constants.TYPE_ELEMENT_LINK:
            content.add(new Paragraph(((LinkElementModel) elementModel).getContent(), smallBold));

            break;
        case Constants.TYPE_ELEMENT_PICTURE:
            Image image1;
            try {
                if (((PictureElementModel) elementModel).getContent() != null) {
                    image1 = Image.getInstance(((PictureElementModel) elementModel).getContent());

                    content.add(image1);
                }
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            break;
        case Constants.TYPE_ELEMENT_FILE:
            content.add(new Paragraph(((FileElementModel) elementModel).getTitle(), smallBold));
            break;

        }

        document.add(catPart);
    }

}