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:org.smap.sdal.managers.PDFSurveyManager.java

License:Open Source License

private void addValue(Document document, String value, float indent) throws DocumentException {

    Font f = null;/* ww  w .j a  v a  2 s .c o m*/
    String lang;

    if (value != null && value.trim().length() > 0) {
        lang = GeneralUtilityMethods.getLanguage(value);
        f = getFont(lang);

        Paragraph para = new Paragraph("", f);
        para.setIndentationLeft(indent);
        para.add(new Chunk(GeneralUtilityMethods.unesc(value), f));
        document.add(para);
    }
}

From source file:org.smap.sdal.managers.PDFTableManager.java

License:Open Source License

private Paragraph getPara(String value) {

    Paragraph para = new Paragraph("", font);

    if (value != null && value.trim().length() > 0) {
        para.add(new Chunk(GeneralUtilityMethods.unesc(value), font));
    }/*  w ww  .  j  a  v  a2s.  co  m*/

    return para;
}

From source file:org.smap.sdal.managers.PDFTableManager.java

License:Open Source License

private void addKeyValuePair(Document document, String key, String value) throws DocumentException {
    Paragraph para = new Paragraph("", font);

    para.add(new Chunk(GeneralUtilityMethods.unesc(key), fontbold));
    para.add(new Chunk(GeneralUtilityMethods.unesc(value), font));

    document.add(para);/*w w w  .jav a2  s .  c om*/
}

From source file:org.smap.sdal.managers.PDFTableManager.java

License:Open Source License

private void addValue(Document document, String value, float indent) throws DocumentException {

    if (value != null && value.trim().length() > 0) {
        Paragraph para = new Paragraph("", font);
        para.setIndentationLeft(indent);
        para.add(new Chunk(GeneralUtilityMethods.unesc(value), font));
        document.add(para);//from  ww  w.jav  a 2  s .  c om
    }
}

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

@SuppressWarnings("unused")
private void addTitlePage(Document document) throws DocumentException {
    Paragraph preface = new Paragraph();

    // We add one empty line
    addEmptyLine(preface, 1);/*from w w w  .j  a v  a  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("Report generated by: " + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-2$ //$NON-NLS-3$ //$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:org.tvd.thptty.management.report.Report.java

private void addContent(Document document, int kind) throws DocumentException {
    //Anchor anchor = new Anchor(tableTitle, tahomaLargeFont);
    //anchor.setName("Bang Diem");

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

    //Paragraph subPara = new Paragraph(createdBy, tahomaLargeFont);
    Paragraph header = new Paragraph(tableTitle, tahomaLargeFont);
    header.setAlignment(Element.ALIGN_LEFT);
    header.add(new Paragraph(createdBy, tahomaLargeFont));
    addEmptyLine(header, 1);//w w w .  j a  v  a 2 s  .  c  o  m

    //Section subCatPart = catPart.addSection(subPara);

    Paragraph paragraph = new Paragraph();

    // Add a table
    if (kind == 1) {
        paragraph.add(createSubjectPointTable());
    } else if (kind == 2) {
        paragraph.add(createStatisticsStudentPointTable());
    }

    header.add(paragraph);

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

}

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

private void addTitlePage(Document document) throws DocumentException {
    Paragraph preface = new Paragraph();
    preface.setFont(smallBold);//from w  w  w.  ja  v  a  2  s. c  o m

    // We add one empty line
    addEmptyLine(preface, 1);

    // Lets write a big header
    preface.add(new Paragraph("Title of Dng the document", catFont));
    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-2$ //$NON-NLS-3$ //$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: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  ww w .j  a  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:org.zaproxy.zap.extension.alertReport.AlertReportExportPDF.java

License:Apache License

private static void addTitlePage(Document document, ExtensionAlertReportExport extensionExport)
        throws DocumentException {

    document.addHeader("Header1", "Header2");

    Paragraph preface = new Paragraph();
    // We add one empty line
    addEmptyLine(preface, 3);//  www .j  a v  a 2 s .c  o m
    // add logo first page
    addImage(preface, extensionExport.getParams().getLogoFileName(), 40f);

    addEmptyLine(preface, 4);
    // Lets write a big header
    Paragraph paragraph = new Paragraph(extensionExport.getParams().getTitleReport(), titleFont);
    paragraph.setAlignment(Paragraph.ALIGN_CENTER);
    preface.add(paragraph);

    addEmptyLine(preface, 3);
    paragraph = new Paragraph(extensionExport.getParams().getCustomerName(), catFont);
    paragraph.setAlignment(Paragraph.ALIGN_CENTER);
    preface.add(paragraph);

    addEmptyLine(preface, 15);

    preface.add(new Paragraph(
            extensionExport.getMessages().getString("alertreport.export.message.export.pdf.confidential"),
            smallBold));
    preface.add(new Paragraph(extensionExport.getParams().getConfidentialText(), litleFont));

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

From source file:org.zaproxy.zap.extension.alertReport.AlertReportExportPDF.java

License:Apache License

/**
 * Add image a Paragraph//from   w ww.ja v  a2  s .  c o m
 * 
 * @param paragraph
 * @param image
 * @param path
 * @throws BadElementException
 */
private static void addImage(Paragraph paragraph, String imagePath, float scalePercent)
        throws BadElementException {
    Image image1;
    try {
        if (!imagePath.isEmpty()) {
            image1 = Image.getInstance(imagePath);
            if (scalePercent != 0)
                image1.scalePercent(40f);
            image1.setAlignment(Image.ALIGN_CENTER);
            paragraph.add(image1);
        }
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }

}