Example usage for com.itextpdf.text Paragraph getContent

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

Introduction

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

Prototype

public String getContent() 

Source Link

Document

Returns the content as a String object.

Usage

From source file:com.athena.chameleon.engine.core.PDFCommonEventHelper.java

License:Apache License

/**
 * chapter write  //  ww  w  .j  a va2 s.  co m
 */
public void onChapter(PdfWriter writer, Document document, float position, Paragraph title) {

    titles.add(
            getTocParagraph(title.getContent(), writer.getPageNumber(), 0, document.left(), document.right()));

}

From source file:com.athena.chameleon.engine.core.PDFCommonEventHelper.java

License:Apache License

/**
 * Section write  /*from w w w. j  av  a2 s.  c o  m*/
 */
public void onSection(PdfWriter writer, Document document, float position, int depth, Paragraph title) {
    title = getTocParagraph(title.getContent(), writer.getPageNumber(), depth, document.left(),
            document.right());
    title.setIndentationLeft(12 * depth);
    titles.add(title);
}

From source file:edu.harvard.mcz.precapture.ui.ContainerLabel.java

License:Open Source License

/**
 * /*from  w  w w . java  2s .  c  o  m*/
 * @return a PDF paragraph cell containing a text encoding of the fields in this set.
 */
public PdfPCell toPDFCell(LabelDefinitionType printDefinition) {
    PdfPCell cell = new PdfPCell();
    ;
    if (printDefinition.getTextOrentation().toString().toLowerCase()
            .equals(TextOrentationType.VERTICAL.toString().toLowerCase())) {
        log.debug("Print orientation of text is Vertical");
        cell.setRotation(90);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
    }
    cell.setBorderColor(BaseColor.LIGHT_GRAY);
    cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
    cell.disableBorderSide(PdfPCell.RIGHT);
    cell.setPaddingLeft(3);
    cell.setNoWrap(false);

    int leading = (int) (fields.get(0).getField().getFontSize() + printDefinition.getFontDelta()) - 1;
    Paragraph higher = new Paragraph(leading, "", new Font(Font.FontFamily.TIMES_ROMAN,
            fields.get(0).getField().getFontSize() + printDefinition.getFontDelta(), Font.NORMAL));
    higher.setSpacingBefore(0);
    higher.setSpacingAfter(0);
    boolean added = false;
    boolean hasContent = false;
    for (int i = 0; i < fields.size(); i++) {
        log.debug(i);
        if (fields.get(i).getField().isNewLine() || (i == fields.size() - 1)) {
            if (!higher.isEmpty()) {
                log.debug(higher.getContent());
                cell.addElement(higher);
            }
            leading = (int) (fields.get(i).getField().getFontSize() + printDefinition.getFontDelta()) - 1;
            higher = new Paragraph(leading, "", new Font(Font.FontFamily.TIMES_ROMAN,
                    fields.get(i).getField().getFontSize() + printDefinition.getFontDelta(), Font.NORMAL));
            higher.setSpacingBefore(0);
            higher.setSpacingAfter(0);
            added = false;
            hasContent = false;
        }
        log.debug(fields.get(i).getTextField().getText().trim());
        Chunk chunk = new Chunk(fields.get(i).getTextField().getText().trim());
        if (fields.get(i).getField().isUseItalic()) {
            chunk.setFont(new Font(Font.FontFamily.TIMES_ROMAN,
                    fields.get(i).getField().getFontSize() + printDefinition.getFontDelta(), Font.ITALIC));
        } else {
            chunk.setFont(new Font(Font.FontFamily.TIMES_ROMAN,
                    fields.get(i).getField().getFontSize() + printDefinition.getFontDelta(), Font.NORMAL));
        }
        if (!chunk.isEmpty()) {
            hasContent = true;
            higher.add(chunk);
            log.debug(fields.get(i).getField().getSuffix());
            if (fields.get(i).getField().getSuffix() != null
                    && fields.get(i).getField().getSuffix().length() > 0) {
                higher.add(new Chunk(fields.get(i).getField().getSuffix()));
            }
            if (fields.get(i).getTextField().getText().trim().length() > 0) {
                // add a trailing space as a separator if there was something to separate.
                higher.add(new Chunk(" "));
            }
        }
    }
    if (!added) {
        log.debug(higher.getContent());
        cell.addElement(higher);
    }
    String extraText = PreCaptureSingleton.getInstance().getProperties().getProperties()
            .getProperty(PreCaptureProperties.KEY_EXTRAHUMANTEXT);
    if (extraText != null && extraText.length() > 0) {
        log.debug(extraText);
        cell.addElement(new Chunk(extraText));
    }

    return cell;
}

From source file:ke.co.tawi.babblesms.server.utils.export.PdfUtil.java

License:Open Source License

/**
 * Initialize one of the headers, based on the chapter title;
 * reset the page number.//from  ww w.  j  a v a 2  s. co  m
 * @see com.itextpdf.text.pdf.PdfPageEventHelper#onChapter(
 *      com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document, float,
 *      com.itextpdf.text.Paragraph)
 */
@Override
public void onChapter(PdfWriter writer, Document document, float paragraphPosition, Paragraph title) {
    header[1] = new Phrase(title.getContent());
    pagenumber = 1;
}