Example usage for com.lowagie.text Chunk setSplitCharacter

List of usage examples for com.lowagie.text Chunk setSplitCharacter

Introduction

In this page you can find the example usage for com.lowagie.text Chunk setSplitCharacter.

Prototype


public Chunk setSplitCharacter(SplitCharacter splitCharacter) 

Source Link

Document

Sets the split characters.

Usage

From source file:com.dlya.facturews.DlyaPdfExporter2.java

License:Open Source License

/**
 *
 *///from www. j a  v a  2s  . c  o m
protected Chunk getChunk(Map<Attribute, Object> attributes, String text, Locale locale) {
    // underline and strikethrough are set on the chunk below
    Font font = getFont(attributes, locale, false);

    Chunk chunk = new Chunk(text, font);

    if (hasUnderline(attributes)) {
        // using the same values as sun.font.Fond2D
        chunk.setUnderline(null, 0, 1f / 18, 0, -1f / 12, 0);
    }

    if (hasStrikethrough(attributes)) {
        // using the same thickness as sun.font.Fond2D.
        // the position is calculated in Fond2D based on the ascent, defaulting 
        // to iText default position which depends on the font size
        chunk.setUnderline(null, 0, 1f / 18, 0, 1f / 3, 0);
    }

    Color backcolor = (Color) attributes.get(TextAttribute.BACKGROUND);
    if (backcolor != null) {
        chunk.setBackground(backcolor);
    }

    Object script = attributes.get(TextAttribute.SUPERSCRIPT);
    if (script != null) {
        if (TextAttribute.SUPERSCRIPT_SUPER.equals(script)) {
            chunk.setTextRise(font.getCalculatedSize() / 2);
        } else if (TextAttribute.SUPERSCRIPT_SUB.equals(script)) {
            chunk.setTextRise(-font.getCalculatedSize() / 2);
        }
    }

    if (splitCharacter != null) {
        //TODO use line break offsets if available?
        chunk.setSplitCharacter(splitCharacter);
    }

    return chunk;
}

From source file:net.sf.jasperreports.engine.export.JRPdfExporter.java

License:LGPL

/**
 *
 *///  w  w  w. j  ava 2 s.  c o  m
protected Chunk getChunk(Map attributes, String text) {
    Font font = getFont(attributes);

    Chunk chunk = new Chunk(text, font);

    Color backcolor = (Color) attributes.get(TextAttribute.BACKGROUND);
    if (backcolor != null) {
        chunk.setBackground(backcolor);
    }

    Object script = attributes.get(TextAttribute.SUPERSCRIPT);
    if (script != null) {
        if (TextAttribute.SUPERSCRIPT_SUPER.equals(script)) {
            chunk.setTextRise(font.leading(1f) / 2);
        } else if (script != null && TextAttribute.SUPERSCRIPT_SUB.equals(script)) {
            chunk.setTextRise(-font.leading(1f) / 2);
        }
    }

    if (splitCharacter != null) {
        chunk.setSplitCharacter(splitCharacter);
    }

    return chunk;
}