Example usage for com.lowagie.text ElementTags CHUNK

List of usage examples for com.lowagie.text ElementTags CHUNK

Introduction

In this page you can find the example usage for com.lowagie.text ElementTags CHUNK.

Prototype

String CHUNK

To view the source code for com.lowagie.text ElementTags CHUNK.

Click Source Link

Document

the chunk tag

Usage

From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java

License:Open Source License

private int createPasswordLetterContent(DocumentPrintContext dpc) throws ContentCreationException {
    IWBundle iwb = getIWApplicationContext().getIWMainApplication()
            .getBundle(is.idega.idegaweb.egov.message.business.MessageConstants.IW_BUNDLE_IDENTIFIER);
    System.out.println("Default locale: "
            + getIWApplicationContext().getApplicationSettings().getDefaultLocale().toString());
    String sAddrString = "";
    PdfContentByte cb = dpc.getPdfWriter().getDirectContent();
    Document document = dpc.getDocument();
    Locale locale = dpc.getLocale();
    PrintMessage msg = dpc.getMessage();
    // String mail_zip = iwb.getProperty("commune.mail_zip");
    // String mail_name = iwb.getProperty("commune.mail_name");

    try {//from  w  w w.java 2  s.  co  m
        sAddrString = getAddressString(dpc.getMessage().getOwner());
    } catch (Exception nouser) {
        handleNoAddressUser();
        System.err.println(nouser.getMessage());
        // nouser.printStackTrace();
        return ADDRESS_ERROR;
    }
    try {
        if (addTemplateHeader()) {
            ColumnText ct = new ColumnText(cb);
            float margin = getPointsFromMM(14);
            float lly = getPointsFromMM(297 - 22);
            float ury = lly + 60f;
            float urx = 595f - margin - 60f - 5f;
            float llx = 110f + margin;
            Phrase Ph0 = new Phrase(sAddrString, new Font(Font.HELVETICA, 12, Font.BOLD));
            ct.setSimpleColumn(Ph0, llx, lly, urx, ury, 15, Element.ALIGN_LEFT);
            ct.go();

            document.add(new Paragraph("\n\n\n\n\n\n\n"));
        }

        {

            User owner = msg.getOwner();
            HashMap tagmap = new CommuneUserTagMap(getIWApplicationContext(), owner);
            tagmap.putAll(getMessageTagMap(msg, locale));

            XmlPeer date = new XmlPeer(ElementTags.CHUNK, "date");
            date.setContent(new IWTimestamp().getDateString("dd.MM.yyyy"));
            tagmap.put(date.getAlias(), date);
            System.out.println("Date tag: " + date.getTag());

            String letterUrl = getXMLLetterUrl(iwb, locale, "password_letter.xml");
            if (msg.getBody().indexOf("|") > 0) {
                StringTokenizer tokenizer = new StringTokenizer(msg.getBody(), "|");
                XmlPeer peer = new XmlPeer(ElementTags.ITEXT, "letter");
                tagmap.put(peer.getAlias(), peer);

                if (tokenizer.hasMoreTokens()) {
                    peer = new XmlPeer(ElementTags.CHUNK, "username");
                    peer.setContent(tokenizer.nextToken());
                    tagmap.put(peer.getAlias(), peer);
                }
                if (tokenizer.hasMoreTokens()) {
                    peer = new XmlPeer(ElementTags.CHUNK, "password");
                    peer.setContent(tokenizer.nextToken());
                    tagmap.put(peer.getAlias(), peer);
                }

            }
            javax.xml.parsers.SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
            SAXmyHandler handler = new SAXmyHandler(document, tagmap);
            handler.setControlOpenClose(false);

            parser.parse(letterUrl, handler);
        }
    } catch (Exception e) {
        throw new ContentCreationException(e);
    }

    return 0;
}

From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java

License:Open Source License

public HashMap getMessageTagMap(PrintMessage msg, Locale locale) {
    HashMap tagmap = new HashMap();
    DateFormat df;/*from w w w.j  a  v a  2 s  .  c  o  m*/
    if (locale != null) {
        df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
    } else {
        df = DateFormat.getDateInstance(DateFormat.SHORT);
    }

    XmlPeer peer = new XmlPeer(ElementTags.CHUNK, "msgsubject");
    peer.setContent(msg.getSubject());
    tagmap.put(peer.getAlias(), peer);

    peer = new XmlPeer(ElementTags.CHUNK, "msgbody");
    peer.setContent(msg.getBody());
    tagmap.put(peer.getAlias(), peer);

    peer = new XmlPeer(ElementTags.CHUNK, "msgcreated");
    peer.setContent(df.format(msg.getCreated()));
    tagmap.put(peer.getAlias(), peer);

    peer = new XmlPeer(ElementTags.CHUNK, "msgid");
    peer.setContent(msg.getPrimaryKey().toString());
    tagmap.put(peer.getAlias(), peer);

    peer = new XmlPeer(ElementTags.CHUNK, "msgstatus");
    peer.setContent(msg.getCaseStatus().toString());
    tagmap.put(peer.getAlias(), peer);

    peer = new XmlPeer(ElementTags.CHUNK, "msgcode");
    peer.setContent(msg.getCaseCode().toString());
    tagmap.put(peer.getAlias(), peer);

    return tagmap;
}

From source file:org.apache.maven.doxia.module.itext.ITextSink.java

License:Apache License

/** {@inheritDoc} */
public void body() {
    if (writeStart) {
        writeStartElement(ElementTags.ITEXT);
        writeAddAttribute(ElementTags.TITLE, header.getTitle());
        writeAddAttribute(ElementTags.AUTHOR, header.getAuthors());
        writeAddAttribute(ElementTags.CREATIONDATE, header.getDate());
        writeAddAttribute(ElementTags.SUBJECT, header.getTitle());
        writeAddAttribute(ElementTags.KEYWORDS, "");
        writeAddAttribute(ElementTags.PRODUCER, "Generated with Doxia by " + System.getProperty("user.name"));
        writeAddAttribute(ElementTags.PAGE_SIZE, ITextUtil.getPageSize(ITextUtil.getDefaultPageSize()));

        writeStartElement(ElementTags.CHAPTER);
        writeAddAttribute(ElementTags.NUMBERDEPTH, numberDepth);
        writeAddAttribute(ElementTags.DEPTH, depth);
        writeAddAttribute(ElementTags.INDENT, "0.0");

        writeStartElement(ElementTags.TITLE);
        writeAddAttribute(ElementTags.LEADING, DEFAULT_CHAPTER_TITLE_LEADING);
        writeAddAttribute(ElementTags.FONT, ITextFont.DEFAULT_FONT_NAME);
        writeAddAttribute(ElementTags.SIZE, ITextFont.getSectionFontSize(0));
        writeAddAttribute(ElementTags.STYLE, ITextFont.BOLD);
        writeAddAttribute(ElementTags.BLUE, ITextFont.DEFAULT_FONT_COLOR_BLUE);
        writeAddAttribute(ElementTags.GREEN, ITextFont.DEFAULT_FONT_COLOR_GREEN);
        writeAddAttribute(ElementTags.RED, ITextFont.DEFAULT_FONT_COLOR_RED);
        writeAddAttribute(ElementTags.ALIGN, ElementTags.ALIGN_CENTER);

        //            startChunk( ITextFont.DEFAULT_FONT_NAME, ITextFont.getSectionFontSize( 0 ),
        //                    ITextFont.BOLD, ITextFont.DEFAULT_FONT_COLOR_BLUE, ITextFont.DEFAULT_FONT_COLOR_GREEN,
        //                    ITextFont.DEFAULT_FONT_COLOR_RED, "top" );

        writeStartElement(ElementTags.CHUNK);
        writeAddAttribute(ElementTags.FONT, ITextFont.DEFAULT_FONT_NAME);
        writeAddAttribute(ElementTags.SIZE, ITextFont.getSectionFontSize(0));
        writeAddAttribute(ElementTags.STYLE, ITextFont.BOLD);
        writeAddAttribute(ElementTags.BLUE, ITextFont.DEFAULT_FONT_COLOR_BLUE);
        writeAddAttribute(ElementTags.GREEN, ITextFont.DEFAULT_FONT_COLOR_GREEN);
        writeAddAttribute(ElementTags.RED, ITextFont.DEFAULT_FONT_COLOR_RED);
        //            writeAddAttribute( ElementTags.LOCALDESTINATION, "top" );

        write(header.getTitle());//from w  w w  .ja  v a  2  s  .c  o m

        writeEndElement(); // ElementTags.CHUNK

        writeEndElement(); // ElementTags.TITLE
    }

    actionContext.setAction(SinkActionContext.BODY);
}

From source file:org.apache.maven.doxia.module.itext.ITextSink.java

License:Apache License

/** {@inheritDoc} */
public void list() {
    writeStartElement(ElementTags.CHUNK);
    writeAddAttribute(ElementTags.FONT, font.getFontName());
    writeAddAttribute(ElementTags.SIZE, font.getFontSize());
    writeAddAttribute(ElementTags.STYLE, font.getFontStyle());
    writeAddAttribute(ElementTags.BLUE, font.getFontColorBlue());
    writeAddAttribute(ElementTags.GREEN, font.getFontColorGreen());
    writeAddAttribute(ElementTags.RED, font.getFontColorRed());

    writeStartElement(ElementTags.LIST);
    writeAddAttribute(ElementTags.NUMBERED, Boolean.FALSE.toString());
    writeAddAttribute(ElementTags.SYMBOLINDENT, "15");

    actionContext.setAction(SinkActionContext.LIST);
}

From source file:org.apache.maven.doxia.module.itext.ITextSink.java

License:Apache License

/** {@inheritDoc} */
public void numberedList(int numbering) {
    writeStartElement(ElementTags.CHUNK);
    writeAddAttribute(ElementTags.FONT, font.getFontName());
    writeAddAttribute(ElementTags.SIZE, font.getFontSize());
    writeAddAttribute(ElementTags.STYLE, font.getFontStyle());
    writeAddAttribute(ElementTags.BLUE, font.getFontColorBlue());
    writeAddAttribute(ElementTags.GREEN, font.getFontColorGreen());
    writeAddAttribute(ElementTags.RED, font.getFontColorRed());

    writeStartElement(ElementTags.LIST);
    writeAddAttribute(ElementTags.NUMBERED, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.SYMBOLINDENT, "20");

    switch (numbering) {
    case Sink.NUMBERING_UPPER_ALPHA:
        writeAddAttribute(ElementTags.LETTERED, Boolean.TRUE.toString());
        writeAddAttribute(ElementTags.FIRST, 'A');
        break;/*www.  ja v a  2  s  . c  om*/

    case Sink.NUMBERING_LOWER_ALPHA:
        writeAddAttribute(ElementTags.LETTERED, Boolean.TRUE.toString());
        writeAddAttribute(ElementTags.FIRST, 'a');
        break;

    // TODO Doesn't work
    case Sink.NUMBERING_UPPER_ROMAN:
        writeAddAttribute(ElementTags.LETTERED, Boolean.TRUE.toString());
        writeAddAttribute(ElementTags.FIRST, 'I');
        break;

    case Sink.NUMBERING_LOWER_ROMAN:
        writeAddAttribute(ElementTags.LETTERED, Boolean.TRUE.toString());
        writeAddAttribute(ElementTags.FIRST, 'i');
        break;

    case Sink.NUMBERING_DECIMAL:
    default:
        writeAddAttribute(ElementTags.LETTERED, Boolean.FALSE.toString());
    }

    actionContext.setAction(SinkActionContext.NUMBERED_LIST);
}

From source file:org.apache.maven.doxia.module.itext.ITextSink.java

License:Apache License

/** {@inheritDoc} */
public void definedTerm() {
    font.setSize(ITextFont.DEFAULT_FONT_SIZE + 2);
    bold();//from w  w  w  . ja  v a  2  s. c  om

    writeStartElement(ElementTags.CHUNK);
    writeAddAttribute(ElementTags.FONT, font.getFontName());
    writeAddAttribute(ElementTags.SIZE, font.getFontSize());
    writeAddAttribute(ElementTags.STYLE, font.getFontStyle());
    writeAddAttribute(ElementTags.BLUE, font.getFontColorBlue());
    writeAddAttribute(ElementTags.GREEN, font.getFontColorGreen());
    writeAddAttribute(ElementTags.RED, font.getFontColorRed());

    actionContext.setAction(SinkActionContext.DEFINED_TERM);
}

From source file:org.apache.maven.doxia.module.itext.ITextSink.java

License:Apache License

/** {@inheritDoc} */
public void definition() {
    writeStartElement(ElementTags.CHUNK);
    writeAddAttribute(ElementTags.FONT, font.getFontName());
    writeAddAttribute(ElementTags.SIZE, font.getFontSize());
    writeAddAttribute(ElementTags.STYLE, font.getFontStyle());
    writeAddAttribute(ElementTags.BLUE, font.getFontColorBlue());
    writeAddAttribute(ElementTags.GREEN, font.getFontColorGreen());
    writeAddAttribute(ElementTags.RED, font.getFontColorRed());

    writeStartElement(ElementTags.CHUNK);
    writeAddAttribute(ElementTags.FONT, font.getFontName());
    writeAddAttribute(ElementTags.SIZE, font.getFontSize());
    writeAddAttribute(ElementTags.STYLE, font.getFontStyle());
    writeAddAttribute(ElementTags.BLUE, font.getFontColorBlue());
    writeAddAttribute(ElementTags.GREEN, font.getFontColorGreen());
    writeAddAttribute(ElementTags.RED, font.getFontColorRed());

    // We need to add a non break space first to display empty string
    write("\u00A0" + StringUtils.repeat(" ", 16), false, false);

    writeEndElement(); // ElementTags.CHUNK

    actionContext.setAction(SinkActionContext.DEFINITION);
}

From source file:org.apache.maven.doxia.module.itext.ITextSink.java

License:Apache License

/** {@inheritDoc} */
public void table() {
    writeStartElement(ElementTags.CHUNK);
    writeAddAttribute(ElementTags.FONT, font.getFontName());
    writeAddAttribute(ElementTags.SIZE, font.getFontSize());
    writeAddAttribute(ElementTags.STYLE, font.getFontStyle());
    writeAddAttribute(ElementTags.BLUE, font.getFontColorBlue());
    writeAddAttribute(ElementTags.GREEN, font.getFontColorGreen());
    writeAddAttribute(ElementTags.RED, font.getFontColorRed());

    writeStartElement(ElementTags.TABLE);
    writeAddAttribute(ElementTags.LEFT, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.RIGHT, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.TOP, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.BOTTOM, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.ALIGN, ElementTags.ALIGN_CENTER);
    writeAddAttribute(ElementTags.WIDTH, "100.0%");
    writeAddAttribute(ElementTags.TABLEFITSPAGE, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.CELLSFITPAGE, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.CELLPADDING, "10");
    //writeAddAttribute( ElementTags.COLUMNS, "2" );

    actionContext.setAction(SinkActionContext.TABLE);
}

From source file:org.apache.maven.doxia.module.itext.ITextSink.java

License:Apache License

/** {@inheritDoc} */
public void verbatim(boolean boxed) {
    // Always boxed
    writeStartElement(ElementTags.CHUNK);
    writeAddAttribute(ElementTags.FONT, font.getFontName());
    writeAddAttribute(ElementTags.SIZE, font.getFontSize());
    writeAddAttribute(ElementTags.STYLE, font.getFontStyle());
    writeAddAttribute(ElementTags.BLUE, font.getFontColorBlue());
    writeAddAttribute(ElementTags.GREEN, font.getFontColorGreen());
    writeAddAttribute(ElementTags.RED, font.getFontColorRed());

    writeStartElement(ElementTags.TABLE);
    writeAddAttribute(ElementTags.COLUMNS, "1");
    writeAddAttribute(ElementTags.LEFT, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.RIGHT, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.TOP, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.BOTTOM, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.ALIGN, ElementTags.ALIGN_CENTER);
    writeAddAttribute(ElementTags.TABLEFITSPAGE, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.CELLSFITPAGE, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.CELLPADDING, "10");
    writeAddAttribute(ElementTags.WIDTH, "100.0%");

    writeStartElement(ElementTags.ROW);// ww  w . j a va2s . c  om

    writeStartElement(ElementTags.CELL);
    writeAddAttribute(ElementTags.LEFT, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.RIGHT, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.TOP, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.BOTTOM, Boolean.TRUE.toString());

    actionContext.setAction(SinkActionContext.VERBATIM);
}

From source file:org.apache.maven.doxia.module.itext.ITextSink.java

License:Apache License

/** {@inheritDoc} */
public void figure() {
    figureDefined = true;/*from w w w .j ava2  s  .c o  m*/

    writeStartElement(ElementTags.CHUNK);
    writeAddAttribute(ElementTags.FONT, font.getFontName());
    writeAddAttribute(ElementTags.SIZE, font.getFontSize());
    writeAddAttribute(ElementTags.STYLE, font.getFontStyle());
    writeAddAttribute(ElementTags.BLUE, font.getFontColorBlue());
    writeAddAttribute(ElementTags.GREEN, font.getFontColorGreen());
    writeAddAttribute(ElementTags.RED, font.getFontColorRed());

    writeStartElement(ElementTags.IMAGE);

    actionContext.setAction(SinkActionContext.FIGURE);
}