class SAXmyHtmlHandler extends SAXiTextHandler<HtmlPeer> {
// SAXmyHandler

    /**
     * These are the properties of the body section.
     */
    private final Properties bodyAttributes = new Properties();

    /**
     * This is the status of the table border.
     */
    private boolean tableBorder = false;

    /**
     * Constructs a new SAXiTextHandler that will translate all the events triggered by the parser to actions on the
     * <CODE>Document</CODE>-object.
     *
     * @param document this is the document on which events must be triggered
     */
    public SAXmyHtmlHandler(DocListener document) {
        this(document, new HtmlTagMap());
    }

    /**
     * Constructs a new SAXiTextHandler that will translate all the events triggered by the parser to actions on the
     * <CODE>Document</CODE>-object.
     *
     * @param document this is the document on which events must be triggered
     * @param htmlTags a tagmap translating HTML tags to iText tags
     */
    public SAXmyHtmlHandler(DocListener document, HtmlTagMap htmlTags) {
        this(document, htmlTags, null);
    }

    public SAXmyHtmlHandler(DocListener document, HtmlTagMap htmlTags, BaseFont bf) {
        super(document, htmlTags, bf);
    }

    /**
     * Constructs a new SAXiTextHandler that will translate all the events triggered by the parser to actions on the
     * <CODE>Document</CODE>-object.
     *
     * @param document this is the document on which events must be triggered
     * @param bf       the base class for the supported fonts
     */
    public SAXmyHtmlHandler(DocListener document, BaseFont bf) {
        this(document, new HtmlTagMap(), bf);
    }

    /**
     * This method gets called when a start tag is encountered.
     *
     * @param uri       the Uniform Resource Identifier
     * @param localName the local name (without prefix), or the empty string if Namespace processing is not being
     *                  performed.
     * @param name      the name of the tag that is encountered
     * @param attrs     the list of attributes
     */
    @Override
    public void startElement(String uri, String localName, String name, Attributes attrs) {<FILL_FUNCTION_BODY>}

    /**
     * This method gets called when an end tag is encountered.
     *
     * @param uri       the Uniform Resource Identifier
     * @param localName the local name (without prefix), or the empty string if Namespace processing is not being
     *                  performed.
     * @param name      the name of the tag that ends
     */
    @Override
    public void endElement(String uri, String localName, String name) {
        String lowerCaseName = name.toLowerCase();
        if (ElementTags.PARAGRAPH.equals(lowerCaseName)) {
            try {
                document.add(stack.pop());
                return;
            } catch (DocumentException e) {
                throw new ExceptionConverter(e);
            }
        }
        if (HtmlTagMap.isHead(lowerCaseName)) {
            // we do nothing
            return;
        }
        if (HtmlTagMap.isTitle(lowerCaseName)) {
            if (currentChunk != null) {
                bodyAttributes.put(ElementTags.TITLE, currentChunk.getContent());
                currentChunk = null;
            }
            return;
        }
        if (HtmlTagMap.isMeta(lowerCaseName)) {
            // we do nothing
            return;
        }
        if (HtmlTagMap.isLink(lowerCaseName)) {
            // we do nothing
            return;
        }
        if (HtmlTagMap.isBody(lowerCaseName)) {
            // we do nothing
            return;
        }
        if (myTags.containsKey(lowerCaseName)) {
            HtmlPeer peer = myTags.get(lowerCaseName);
            if (ElementTags.TABLE.equals(peer.getTag())) {
                tableBorder = false;
            }
            super.handleEndingTags(peer.getTag());
            return;
        }
        // super.handleEndingTags is replaced with handleEndingTags
        // suggestion by Ken Auer
        handleEndingTags(lowerCaseName);
    }
}

        // super.handleStartingTags is replaced with handleStartingTags
        // suggestion by Vu Ngoc Tan/Hop
        String lowerCaseName = name.toLowerCase();
        if (HtmlTagMap.isHtml(lowerCaseName)) {
            // we do nothing
            return;
        }
        if (HtmlTagMap.isHead(lowerCaseName)) {
            // we do nothing
            return;
        }
        if (HtmlTagMap.isTitle(lowerCaseName)) {
            // we do nothing
            return;
        }
        if (HtmlTagMap.isMeta(lowerCaseName)) {
            // we look if we can change the body attributes
            String meta = null;
            String content = null;
            if (attrs != null) {
                for (int i = 0; i < attrs.getLength(); i++) {
                    String attribute = attrs.getQName(i);
                    if (attribute.equalsIgnoreCase(HtmlTags.CONTENT)) {
                        content = attrs.getValue(i);
                    } else if (attribute.equalsIgnoreCase(HtmlTags.NAME)) {
                        meta = attrs.getValue(i);
                    }
                }
            }
            if (meta != null && content != null) {
                bodyAttributes.put(meta, content);
            }
            return;
        }
        if (HtmlTagMap.isLink(lowerCaseName)) {
            // we do nothing for the moment, in a later version we could extract
            // the style sheet
            return;
        }
        if (HtmlTagMap.isBody(lowerCaseName)) {
            // maybe we could extract some info about the document: color,
            // margins,...
            // but that's for a later version...
            HtmlPeer peer = new HtmlPeer(ElementTags.ITEXT, lowerCaseName);
            peer.addAlias(ElementTags.TOP, HtmlTags.TOPMARGIN);
            peer.addAlias(ElementTags.BOTTOM, HtmlTags.BOTTOMMARGIN);
            peer.addAlias(ElementTags.RIGHT, HtmlTags.RIGHTMARGIN);
            peer.addAlias(ElementTags.LEFT, HtmlTags.LEFTMARGIN);
            bodyAttributes.putAll(peer.getAttributes(attrs));
            handleStartingTags(peer.getTag(), bodyAttributes);
            return;
        }
        if (myTags.containsKey(lowerCaseName)) {
            HtmlPeer peer = myTags.get(lowerCaseName);
            if (ElementTags.TABLE.equals(peer.getTag()) || ElementTags.CELL.equals(peer.getTag())) {
                Properties p = peer.getAttributes(attrs);
                String value;
                if (ElementTags.TABLE.equals(peer.getTag())
                        && (value = p.getProperty(ElementTags.BORDERWIDTH)) != null) {
                    if (Float.parseFloat(value + "f") > 0) {
                        tableBorder = true;
                    }
                }
                if (tableBorder) {
                    p.put(ElementTags.LEFT, String.valueOf(true));
                    p.put(ElementTags.RIGHT, String.valueOf(true));
                    p.put(ElementTags.TOP, String.valueOf(true));
                    p.put(ElementTags.BOTTOM, String.valueOf(true));
                }
                handleStartingTags(peer.getTag(), p);
                return;
            }
            handleStartingTags(peer.getTag(), peer.getAttributes(attrs));
            return;
        }
        Properties attributes = new Properties();
        if (attrs != null) {
            for (int i = 0; i < attrs.getLength(); i++) {
                String attribute = attrs.getQName(i).toLowerCase();
                attributes.setProperty(attribute, attrs.getValue(i).toLowerCase());
            }
        }
        handleStartingTags(lowerCaseName, attributes);
    
<methods>public void <init>(com.lowagie.text.DocListener) ,public void <init>(com.lowagie.text.DocListener, Map<java.lang.String,com.lowagie.text.html.HtmlPeer>, com.lowagie.text.pdf.BaseFont) ,public void <init>(com.lowagie.text.DocListener, Map<java.lang.String,com.lowagie.text.html.HtmlPeer>) ,public void characters(char[], int, int) ,public void endElement(java.lang.String, java.lang.String, java.lang.String) ,public void handleEndingTags(java.lang.String) ,public void handleStartingTags(java.lang.String, java.util.Properties) ,public void ignorableWhitespace(char[], int, int) ,public void setBaseFont(com.lowagie.text.pdf.BaseFont) ,public void setControlOpenClose(boolean) ,public void startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) <variables>private com.lowagie.text.pdf.BaseFont bf,private float bottomMargin,protected int chapters,private boolean controlOpenClose,protected com.lowagie.text.Chunk currentChunk,protected com.lowagie.text.DocListener document,protected boolean ignore,private float leftMargin,protected Map<java.lang.String,com.lowagie.text.html.HtmlPeer> myTags,private float rightMargin,protected Stack<com.lowagie.text.Element> stack,private float topMargin