Example usage for com.lowagie.text Font ITALIC

List of usage examples for com.lowagie.text Font ITALIC

Introduction

In this page you can find the example usage for com.lowagie.text Font ITALIC.

Prototype

int ITALIC

To view the source code for com.lowagie.text Font ITALIC.

Click Source Link

Document

this is a possible style.

Usage

From source file:classroom.filmfestival_b.Movies12.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {

    // step 1/*from   www  .  j a va  2s . c o m*/
    Document document = new Document();
    try {
        // step 2
        OutputStream os = new FileOutputStream(RESULT);
        PdfWriter.getInstance(document, os);
        // step 3
        document.open();
        // step 4
        Session session = (Session) MySessionFactory.currentSession();
        Query q = session.createQuery("from FilmTitle order by title");
        java.util.List<FilmTitle> results = q.list();

        PdfPTable table = new PdfPTable(2);
        table.setWidths(new float[] { 1, 5 });
        File f;
        Image img;
        Paragraph p;
        Chunk c;
        Font bold = new Font(Font.HELVETICA, 12, Font.BOLD);
        Font italic = new Font(Font.HELVETICA, 12, Font.ITALIC);
        for (FilmTitle movie : results) {
            f = new File("resources/classroom/filmposters/" + movie.getFilmId() + ".jpg");
            if (f.exists()) {
                img = Image.getInstance(f.getPath());
                table.addCell(img);
            } else {
                table.addCell("");
            }
            p = new Paragraph(20);
            c = new Chunk(movie.getTitle(), bold);
            c.setAnchor("http://cinema.lowagie.com/titel.php?id=" + movie.getFilmId());
            p.add(c);
            c = new Chunk(" (" + movie.getYear() + ") ", italic);
            p.add(c);
            c = new Chunk("IMDB");
            c.setAnchor("http://www.imdb.com/title/tt" + movie.getImdb());
            p.add(c);
            table.addCell(p);
        }
        document.add(table);
        // step 5
        document.close();
    } catch (IOException e) {
        LOGGER.error("IOException: ", e);
    } catch (DocumentException e) {
        LOGGER.error("DocumentException: ", e);
    }
}

From source file:classroom.filmfestival_b.Movies13.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {

    // step 1//ww  w. ja  v a2  s  . co  m
    Document document = new Document();
    try {
        // step 2
        OutputStream os = new FileOutputStream(RESULT);
        PdfWriter.getInstance(document, os);
        // step 3
        document.open();
        // step 4
        Session session = (Session) MySessionFactory.currentSession();
        Query q = session.createQuery("from FilmTitle order by title");
        java.util.List<FilmTitle> results = q.list();

        PdfPTable table = new PdfPTable(2);
        table.setWidths(new float[] { 1, 5 });
        File f;
        Paragraph p;
        Chunk c;
        PdfPCell cell;
        Font bold = new Font(Font.HELVETICA, 12, Font.BOLD);
        Font italic = new Font(Font.HELVETICA, 12, Font.ITALIC);
        for (FilmTitle movie : results) {
            f = new File("resources/classroom/filmposters/" + movie.getFilmId() + ".jpg");
            if (f.exists()) {
                cell = new PdfPCell(Image.getInstance(f.getPath()), true);
                cell.setPadding(2);
            } else {
                cell = new PdfPCell();
            }
            table.addCell(cell);
            p = new Paragraph(20);
            c = new Chunk(movie.getTitle(), bold);
            c.setAnchor("http://cinema.lowagie.com/titel.php?id=" + movie.getFilmId());
            p.add(c);
            c = new Chunk(" (" + movie.getYear() + ") ", italic);
            p.add(c);
            c = new Chunk("IMDB");
            c.setAnchor("http://www.imdb.com/title/tt" + movie.getImdb());
            p.add(c);
            cell = new PdfPCell();
            cell.setUseAscender(true);
            cell.setUseDescender(true);
            cell.addElement(p);
            Set<DirectorName> directors = movie.getDirectorNames();
            List list = new List();
            for (DirectorName director : directors) {
                list.add(director.getName());
            }
            cell.addElement(list);
            table.addCell(cell);
        }
        document.add(table);
        // step 5
        document.close();
    } catch (IOException e) {
        LOGGER.error("IOException: ", e);
    } catch (DocumentException e) {
        LOGGER.error("DocumentException: ", e);
    }
}

From source file:classroom.filmfestival_b.Movies14.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {

    // step 1/*from w w  w  .  j  a  v a2 s  .c om*/
    Document document = new Document();
    try {
        // step 2
        OutputStream os = new FileOutputStream(RESULT);
        PdfWriter.getInstance(document, os);
        // step 3
        document.open();
        // step 4
        Session session = (Session) MySessionFactory.currentSession();
        Query q = session.createQuery("from FilmTitle order by title");
        java.util.List<FilmTitle> results = q.list();

        PdfPTable table = new PdfPTable(2);
        table.setWidths(new float[] { 1, 5 });
        File f;
        Paragraph p;
        Chunk c;
        PdfPCell cell = new PdfPCell();
        Font bold = new Font(Font.HELVETICA, 12, Font.BOLD);
        Font italic = new Font(Font.HELVETICA, 12, Font.ITALIC);
        p = new Paragraph("FILMFESTIVAL", bold);
        p.setAlignment(Element.ALIGN_CENTER);
        cell.addElement(p);
        cell.setColspan(2);
        cell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell();
        cell.setFixedHeight(20);
        cell.setColspan(2);
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setCellEvent(new Movies14().new PageCell());
        table.addCell(cell);
        table.setHeaderRows(2);
        table.setFooterRows(1);
        for (FilmTitle movie : results) {
            f = new File("resources/classroom/filmposters/" + movie.getFilmId() + ".jpg");
            if (f.exists()) {
                cell = new PdfPCell(Image.getInstance(f.getPath()), true);
                cell.setPadding(2);
            } else {
                cell = new PdfPCell();
            }
            table.addCell(cell);
            p = new Paragraph(20);
            c = new Chunk(movie.getTitle(), bold);
            c.setAnchor("http://cinema.lowagie.com/titel.php?id=" + movie.getFilmId());
            p.add(c);
            c = new Chunk(" (" + movie.getYear() + ") ", italic);
            p.add(c);
            c = new Chunk("IMDB");
            c.setAnchor("http://www.imdb.com/title/tt" + movie.getImdb());
            p.add(c);
            cell = new PdfPCell();
            cell.setUseAscender(true);
            cell.setUseDescender(true);
            cell.addElement(p);
            Set<DirectorName> directors = movie.getDirectorNames();
            List list = new List();
            for (DirectorName director : directors) {
                list.add(director.getName());
            }
            cell.addElement(list);
            table.addCell(cell);
        }
        document.add(table);
        // step 5
        document.close();
    } catch (IOException e) {
        LOGGER.error("IOException: ", e);
    } catch (DocumentException e) {
        LOGGER.error("DocumentException: ", e);
    }
}

From source file:classroom.filmfestival_b.Movies15.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {

    // step 1/*  w ww . j a v a2 s  .c o  m*/
    Document document = new Document();
    try {
        // step 2
        OutputStream os = new FileOutputStream(RESULT);
        PdfWriter writer = PdfWriter.getInstance(document, os);
        // step 3
        document.open();
        // step 4
        Session session = (Session) MySessionFactory.currentSession();
        Query q = session.createQuery("from FilmTitle order by title");
        java.util.List<FilmTitle> results = q.list();

        PdfPTable table = new PdfPTable(2);
        table.setComplete(false);
        table.setWidths(new float[] { 1, 5 });
        File f;
        Paragraph p;
        Chunk c;
        PdfPCell cell = new PdfPCell();
        Font bold = new Font(Font.HELVETICA, 12, Font.BOLD);
        Font italic = new Font(Font.HELVETICA, 12, Font.ITALIC);
        p = new Paragraph("FILMFESTIVAL", bold);
        p.setAlignment(Element.ALIGN_CENTER);
        cell.addElement(p);
        cell.setColspan(2);
        cell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell();
        cell.setFixedHeight(20);
        cell.setColspan(2);
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setCellEvent(new Movies14().new PageCell());
        table.addCell(cell);
        table.setHeaderRows(2);
        table.setFooterRows(1);
        int counter = 10;
        for (FilmTitle movie : results) {
            f = new File("resources/classroom/filmposters/" + movie.getFilmId() + ".jpg");
            if (f.exists()) {
                cell = new PdfPCell(Image.getInstance(f.getPath()), true);
                cell.setPadding(2);
            } else {
                cell = new PdfPCell();
            }
            table.addCell(cell);
            p = new Paragraph(20);
            c = new Chunk(movie.getTitle(), bold);
            c.setAnchor("http://cinema.lowagie.com/titel.php?id=" + movie.getFilmId());
            p.add(c);
            c = new Chunk(" (" + movie.getYear() + ") ", italic);
            p.add(c);
            c = new Chunk("IMDB");
            c.setAnchor("http://www.imdb.com/title/tt" + movie.getImdb());
            p.add(c);
            cell = new PdfPCell();
            cell.setUseAscender(true);
            cell.setUseDescender(true);
            cell.addElement(p);
            Set<DirectorName> directors = movie.getDirectorNames();
            List list = new List();
            for (DirectorName director : directors) {
                list.add(director.getName());
            }
            cell.addElement(list);
            table.addCell(cell);
            if (counter % 10 == 0) {
                document.add(table);
            }
            System.out.println(writer.getPageNumber());
            counter++;
        }
        table.setComplete(true);
        document.add(table);
        // step 5
        document.close();
    } catch (IOException e) {
        LOGGER.error("IOException: ", e);
    } catch (DocumentException e) {
        LOGGER.error("DocumentException: ", e);
    }
}

From source file:com.amphisoft.epub2pdf.content.TextFactory.java

License:Open Source License

void modifyFontInPlace(Font font, StyleSpecText styleSpec) {
    int style = font.getStyle();
    if (styleSpec.isBold()) {
        style |= Font.BOLD;/*from   w  ww.  ja v  a 2s .  c  o  m*/
    }
    if (styleSpec.isItalic()) {
        style |= Font.ITALIC;
    }
    font.setStyle(style);
}

From source file:com.amphisoft.epub2pdf.content.XhtmlHandler.java

License:Open Source License

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) {
    /*//from  ww  w .j  a va 2 s.  c  om
    if("ol".equals(qName) || "ul".equals(qName) || "li".equals(qName)) {
       System.err.print(qName + " ");
    }
     */
    currentSaxElemId = saxElemIdCounter;

    Map<String, String> attrMap = new HashMap<String, String>();
    // parse attributes
    for (int ai = 0; ai < attributes.getLength(); ai++) {
        attrMap.put(attributes.getQName(ai), attributes.getValue(ai));
    }
    String idAttr = attrMap.get("id");
    if (idAttr == null) {
        idAttr = "";
    }
    String className = attrMap.get("class");
    if (className == null) {
        className = "";
    }
    SaxElement sE = new SaxElement(qName, saxElemIdCounter++, className, idAttr, currentITextStyle);
    //printlnerr("startElement: " + sE.toString());
    saxElementStack.push(sE);

    try {
        if (attrMap.get("class") != null) {
            String[] elemClasses = attrMap.get("class").split(" ");

            for (String eClass : elemClasses) {

                StyleSpecText classTextStyles = styleMap.getTextStyleSpecFor(qName, eClass);
                if (classTextStyles != null) {
                    sE.applyTextStyles(classTextStyles);
                }

            }
        }
        if (attrMap.get("style") != null) {
            // TODO this needs more thought, and careful tracking of which tags are still open, etc.
            //String styleSource = attrMap.get("style");
            //CssStyleMap styleTagStyles = cssParser.getStylesFromStyleTag(styleSource);
            // ...
        }
        if (sE.textStyles == null) {
            try {
                int stackSize = saxElementStack.size();
                if (stackSize > 1) {
                    SaxElement enclosingElement = saxElementStack.elementAt(stackSize - 2);
                    StyleSpecText enclosingSST = enclosingElement.textStyles;
                    if (enclosingSST != null)
                        sE.applyTextStyles(enclosingSST);
                }
            } catch (Exception e) {
            }
        }

        StyleSpecText currentTextStyles = sE.textStyles;
        if (currentTextStyles != null) {
            if (currentTextStyles.isBold()) {
                currentITextStyle |= Font.BOLD;
            }
            if (currentTextStyles.isItalic()) {
                currentITextStyle |= Font.ITALIC;
            }
        }

        //System.err.println("PUSH -> " + saxElementStack);

        previousTag = currentTag;
        currentTag = qName;
        if (document.isOpen()) {
            if (XhtmlTags.NEWLINE.equals(qName)) {
                if (stack.size() > 0) {
                    TextElementArray currentTEA = (TextElementArray) stack.peek();
                    currentTEA.add(Chunk.NEWLINE);
                } else if (specialParagraph != null) {
                    specialParagraph.add(Chunk.NEWLINE);
                }
            }

            updateStack();

            String xmlElementId = attrMap.get("id");

            if (XhtmlTags.ANCHOR.equals(qName)) {
                //concession to nonconformists...
                if (xmlElementId == null) {
                    xmlElementId = attrMap.get("name");
                }
                Anchor anchor = textFactory.newAnchor();
                String ref = attrMap.get(XhtmlTags.REFERENCE);

                if (ref != null) {
                    int aNameStartIdx = ref.lastIndexOf("#") + 1;
                    ref = ref.substring(aNameStartIdx);
                    anchor.setReference(ref);
                }
                if (xmlElementId != null) {
                    anchor.setName(xmlElementId);
                }
                pushToStack(anchor);
            } else {
                if (xmlElementId != null) {
                    //flushStack();
                    Anchor dest = textFactory.newAnchor();
                    dest.setName(xmlElementId);
                    pushToStack(dest);
                    //flushStack();
                }
                for (int i = 0; i < 6; i++) {
                    if (XhtmlTags.H[i].equals(qName)) {
                        flushStack();
                        freshParagraph = true;
                        currentITextStyle |= Font.BOLD;
                        specialParagraph = textFactory.newHeadline(i + 1);
                        return;
                    }
                }
                if ("blockquote".equals(qName)) {
                    flushStack();
                    freshParagraph = true;
                    Paragraph p = textFactory.newParagraph();
                    p.setIndentationLeft(50);
                    p.setIndentationRight(20);
                    p.setAlignment(defaultAlignment);
                    pushToStack(p);
                } else if (XhtmlTags.PARAGRAPH.equals(qName)) {
                    flushStack();
                    freshParagraph = true;
                    Paragraph p = textFactory.newParagraph();
                    pushToStack(p);
                } else if (XhtmlTags.DIV.equals(qName)) {
                    if (stack.size() > 0 && stack.peek().getChunks().size() > 0) {
                        flushStack();
                    }
                    if (stack.size() == 0) {
                        Paragraph brandNewParagraph = textFactory.newParagraph();
                        pushToStack(brandNewParagraph);
                        freshParagraph = true;
                    }
                } else if (XhtmlTags.PRE.equals(qName)) {
                    flushStack();
                    freshParagraph = true;
                    Paragraph p = textFactory.newParagraphPre();
                    pushToStack(p);
                } else if (XhtmlTags.ORDEREDLIST.equals(qName)) {
                    flushStack();
                    List oList = new List(List.ORDERED, 10);
                    pushToStack(oList);
                } else if (XhtmlTags.UNORDEREDLIST.equals(qName)) {
                    flushStack();
                    List uList = new List(List.UNORDERED, 10);
                    pushToStack(uList);
                } else if (XhtmlTags.LISTITEM.equals(qName)) {
                    freshParagraph = true;
                    ListItem listItem = new ListItem();
                    pushToStack(listItem);
                } else if (XhtmlTags.IMAGE.equals(qName)) {
                    handleImage(attributes);
                } else if (qName != null && qName.endsWith("image")) {
                    handleSvgImage(attributes);
                } else if (XhtmlTags.LINK.equals(qName)) {
                    // if it's a stylesheet, parse it & update current-style
                    if ("stylesheet".equals(attrMap.get("rel")) && "text/css".equals(attrMap.get("type"))
                            && attrMap.get("href") != null) {
                        String cssHref = xhtmlDir.getAbsoluteFile().toURI().toString() + attrMap.get("href");
                        CssStyleMap stylesFromLink = cssParser.getStylesFromFileURI(cssHref);
                        if (stylesFromLink != null) {
                            styleMap.updateWith(stylesFromLink);
                        }
                    }
                } else if (XhtmlTags.STYLE.equals(qName)) {
                    inStyleTag = true;
                } else if (XhtmlTags.EM.equals(qName) || "I".equals(qName.toUpperCase())) {
                    currentITextStyle |= Font.ITALIC;
                } else if (XhtmlTags.STRONG.equals(currentTag) || "B".equals(qName.toUpperCase())) {
                    currentITextStyle |= Font.BOLD;
                }

            }

        } else if (XhtmlTags.BODY.equals(qName)) {
            document.open();
            freshParagraph = true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    //printlnerr("leaving startElement " + localName + "; stack: " + stackStatus());
}

From source file:com.aryjr.nheengatu.util.TagsManager.java

License:Open Source License

public void doI() {
    ((GraphicsState) states.get(states.size() - 1)).getFont().setStyle(Font.ITALIC);
}

From source file:com.bibisco.export.ITextExporter.java

License:GNU General Public License

@Override
public void addText(String pStrText, TextFormatting pTextFormatting) {

    mLog.debug("Start addText(): " + pStrText);

    Font lFont = new Font();
    lFont.setFamily(mFont.getFamilyname());
    lFont.setSize(mFont.getSize());//w w  w.  j  a v a 2  s. c o m

    int lIntStyle = 0;
    if (pTextFormatting.bold) {
        lIntStyle = lIntStyle | Font.BOLD;
    }
    if (pTextFormatting.italic) {
        lIntStyle = lIntStyle | Font.ITALIC;
    }
    if (pTextFormatting.underline) {
        lIntStyle = lIntStyle | Font.UNDERLINE;
    }
    if (pTextFormatting.strike) {
        lIntStyle = lIntStyle | Font.STRIKETHRU;
    }
    lFont.setStyle(lIntStyle);

    Chunk lChunk = new Chunk(pStrText, lFont);

    if (mListItem != null) {
        mListItem.add(lChunk);
    } else if (mParagraph != null) {
        mParagraph.add(lChunk);
    }

    mLog.debug("End addText()");
}

From source file:com.bibisco.export.ITextExporter.java

License:GNU General Public License

@Override
public void startSection(String pStrSectionTitle) {

    Font lFont = new Font();
    lFont.setFamily(mFont.getFamilyname());
    lFont.setSize(mFont.getSize());/*from   w  ww  .  ja  va2  s.c o m*/
    lFont.setStyle(Font.ITALIC);

    Anchor anchor = new Anchor(pStrSectionTitle, lFont);
    anchor.setName(pStrSectionTitle);

    mSection = mChapter.addSection(new Paragraph(anchor));
}

From source file:com.centurylink.mdw.designer.pages.ExportHelper.java

License:Apache License

private Object generateElementHtml(Element element, int depth, Font font) {
    String tag = element.getName();
    Object myself;/*www. jav a2  s .co m*/
    Object av;
    if (element instanceof HTMLDocument.RunElement) {
        HTMLDocument.RunElement re = (HTMLDocument.RunElement) element;
        int start = re.getStartOffset();
        int end = re.getEndOffset();
        try {
            String content = re.getDocument().getText(start, end - start);
            HtmlAttr htmlattr = printAttributesHtml(re);
            av = re.getAttribute(CSS.Attribute.FONT_SIZE);
            String fontsize = av == null ? null : av.toString();
            av = re.getAttribute(CSS.Attribute.FONT_FAMILY);
            String fontfamily = av == null ? null : av.toString();
            av = re.getAttribute(CSS.Attribute.COLOR);
            String fontcolor = av == null ? null : av.toString();
            if (fontcolor != null || fontsize != null || fontfamily != null) {
                if (fontfamily == null)
                    fontfamily = font.getFamilyname();
                if (fontsize != null && fontsize.endsWith("pt"))
                    fontsize = fontsize.substring(0, fontsize.indexOf("pt"));
                float size = fontsize == null ? font.getSize() : (Float.parseFloat(fontsize) + 8);
                int style = font.getStyle();
                Color color;
                if (fontcolor != null) {
                    color = Color.decode(fontcolor);
                } else
                    color = font.getColor();
                font = FontFactory.getFont(fontfamily, size, style, color);
            } else if (htmlattr.bold || htmlattr.italic) {
                String family = font.getFamilyname();
                float size = font.getSize();
                Color color = font.getColor();
                if (htmlattr.bold && htmlattr.italic)
                    font = FontFactory.getFont(family, size, Font.BOLDITALIC, color);
                else if (htmlattr.italic)
                    font = FontFactory.getFont(family, size, Font.ITALIC, color);
                else if (htmlattr.bold)
                    font = FontFactory.getFont(family, size, Font.BOLD);
            }
            myself = new Chunk(content, font);
        } catch (BadLocationException e) {
            e.printStackTrace();
            myself = null;
        }
    } else if (element instanceof HTMLDocument.BlockElement) {
        HTMLDocument.BlockElement be = (HTMLDocument.BlockElement) element;
        HtmlAttr htmlattr = printAttributesHtml(be);
        if (htmlattr.bold) {
            System.out.println("+++BOLD!!!");
        }
        av = be.getAttribute(javax.swing.text.html.HTML.Attribute.ALIGN);
        String align = av == null ? null : av.toString();
        if (htmlattr.bold || htmlattr.italic) {
            String family = font.getFamilyname();
            float size = font.getSize();
            Color color = font.getColor();
            if (htmlattr.bold && htmlattr.italic)
                font = FontFactory.getFont(family, size, Font.BOLDITALIC, color);
            else if (htmlattr.italic)
                font = FontFactory.getFont(family, size, Font.ITALIC, color);
            else if (htmlattr.bold)
                font = FontFactory.getFont(family, size, Font.BOLD, Color.blue);
        }
        if (tag.equalsIgnoreCase("html")) {
            myself = generateElementChildrenHtml(element, depth + 1, font);
        } else if (tag.equalsIgnoreCase("head")) {
            myself = null;
        } else if (tag.equalsIgnoreCase("body")) {
            myself = generateElementChildrenHtml(element, depth + 1, font);
        } else if (tag.equalsIgnoreCase("p") || tag.equalsIgnoreCase("p-implied")) {
            List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont);
            Paragraph paragraph = new Paragraph();
            paragraph.setFirstLineIndent(0F);
            for (Object child : children) {
                if (child instanceof Chunk) {
                    Chunk chunk = (Chunk) child;
                    /*if (!chunk.getContent().equals("\n"))*/ paragraph.add(chunk);
                } else
                    paragraph.add(child);
            }
            if (align != null)
                paragraph.setAlignment(align);
            myself = paragraph;
        } else if (tag.equalsIgnoreCase("h1") || tag.equalsIgnoreCase("h2") || tag.equalsIgnoreCase("h3")) {
            List<Object> children = generateElementChildrenHtml(element, depth + 1, subSectionFont);
            Paragraph title = new Paragraph();
            for (Object child : children) {
                title.add(child);
            }
            myself = new TempSectionPdf(title);
        } else if (tag.equalsIgnoreCase("ul")) {
            com.lowagie.text.List list = new com.lowagie.text.List(false, false, 20.0f);
            list.setIndentationLeft(25.0f);
            List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont);
            for (Object child : children) {
                list.add(child);
            }
            myself = list;
        } else if (tag.equalsIgnoreCase("ol")) {
            com.lowagie.text.List list = new com.lowagie.text.List(true, false, 20.0f);
            list.setIndentationLeft(25.0f);
            List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont);
            for (Object child : children) {
                list.add(child);
            }
            myself = list;
        } else if (tag.equalsIgnoreCase("li")) {
            ListItem li = new ListItem();
            li.setSpacingAfter(0.0f);
            List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont);
            for (Object child : children) {
                li.add(child);
            }
            myself = li;
        } else if (tag.equalsIgnoreCase("table")) {
            List<Object> rows = generateElementChildrenHtml(element, depth + 1, normalFont);
            try {
                int ncols = 0;
                for (Object row : rows) {
                    if (row instanceof List<?>) {
                        int n = ((List<?>) row).size();
                        if (n > ncols)
                            ncols = n;
                    }
                }
                Table table = new Table(2);
                table.setBorderWidth(1);
                table.setBorderColor(new Color(0, 128, 128));
                table.setPadding(1.0f);
                table.setSpacing(0.5f);
                Cell c = new Cell("header");
                c.setHeader(true);
                c.setColspan(ncols);
                table.addCell(c);
                table.endHeaders();
                for (Object row : rows) {
                    if (row instanceof List<?>) {
                        for (Object cell : (List<?>) row) {
                            if (cell instanceof Cell)
                                table.addCell((Cell) cell);
                        }
                    }
                }
                myself = table;
            } catch (BadElementException e) {
                e.printStackTrace();
                myself = null;
            }
        } else if (tag.equalsIgnoreCase("tr")) {
            List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont);
            myself = children;
        } else if (tag.equalsIgnoreCase("td")) {
            Cell cell = new Cell();
            List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont);
            for (Object child : children) {
                cell.add(child);
            }
            myself = cell;
        } else if (tag.equalsIgnoreCase("div")) {
            List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont);
            Paragraph paragraph = new Paragraph();
            paragraph.setFirstLineIndent(0F);
            for (Object child : children) {
                paragraph.add(child);
            }
            if (align != null)
                paragraph.setAlignment(align);
            myself = paragraph;
        } else {
            System.err.println("Unknown element " + element.getName());
            myself = null;
        }
    } else {
        myself = null; // could be BidiElement - not sure what it is
    }
    return myself;
}