Example usage for com.itextpdf.text Paragraph getChunks

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

Introduction

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

Prototype

public java.util.List<Chunk> getChunks() 

Source Link

Document

Gets all the chunks in this element.

Usage

From source file:com.masscustsoft.service.ToPdf.java

License:Open Source License

private void applyFont(Paragraph p, Map it)
        throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (it.get("pushFontSize") != null) {
        Stack<Integer> stack = (Stack) ThreadHelper.get("_fontSizeStack_");
        if (stack == null) {
            stack = new Stack();
            ThreadHelper.set("_fontSizeStack_", stack);
        }/*from  www.  ja va  2  s . c o m*/
        int cur = (Integer) ThreadHelper.get("_defaultFontSize_");
        int size = MapUtil.getInt(it, "pushFontSize", 6);
        stack.push(cur);
        ThreadHelper.set("_defaultFontSize_", size);
    }
    if (it.get("popFontSize") != null) {
        Stack<Integer> stack = (Stack) ThreadHelper.get("_fontSizeStack_");
        if (stack != null && stack.size() > 0) {
            ThreadHelper.set("_defaultFontSize_", stack.pop());
        }
    }
    MapUtil.setIfFloat(it, "leading", p);
    MapUtil.setIfFloat(it, "firstLineIndent", p);
    MapUtil.setIfFloat(it, "indentationLeft", p);
    MapUtil.setIfFloat(it, "indentationRight", p);
    MapUtil.setIfFloat(it, "spacingAfter", p);
    MapUtil.setIfFloat(it, "spacingBefore", p);
    p.setAlignment(getAlignment(it, "alignment"));
    for (Object a : p.getChunks()) {
        if (a instanceof Chunk) {
            Chunk ch = (Chunk) a;
            applyFont(ch, it);
        }
    }
}