Skip navigation links
com.lowagie.text.html

Class HtmlWriter

    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static byte[] BEGINCOMMENT
      This is a possible HTML-tag.
      protected Stack currentfont
      This is the current font of the HTML.
      static byte[] ENDCOMMENT
      This is a possible HTML-tag.
      protected com.lowagie.text.HeaderFooter footer
      This is the textual part of the footer
      protected com.lowagie.text.HeaderFooter header
      This is the textual part of a header
      protected String imagepath
      This is a path for images.
      protected Properties markup
      Store the markup properties of a MarkedObject.
      static String NBSP
      This is a possible HTML-tag.
      protected int pageN
      Stores the page number.
      protected com.lowagie.text.Font standardfont
      This is the standard font of the HTML.
      • Fields inherited from class com.lowagie.text.DocWriter

        closeStream, document, EQUALS, FORWARD, GT, LT, NEWLINE, open, os, pageSize, pause, QUOTE, SPACE, TAB
    • Constructor Summary

      Constructors 
      Modifier Constructor and Description
      protected HtmlWriter(com.lowagie.text.Document doc, OutputStream os)
      Constructs a HtmlWriter.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean add(com.lowagie.text.Element element)
      Signals that an Element was added to the Document.
      boolean add(String string)
      Signals that a String was added to the Document.
      void close()
      Signals that the Document was closed and that no other Elements will be added.
      static HtmlWriter getInstance(com.lowagie.text.Document document, OutputStream os)
      Gets an instance of the HtmlWriter.
      protected void initFooter()
      Adds the header to the top of the Document
      protected void initHeader()
      Adds the header to the top of the Document
      boolean isOtherFont(com.lowagie.text.Font font)
      Checks if a given font is the same as the font that was last used.
      boolean newPage()
      Signals that an new page has to be started.
      void open()
      Signals that the Document has been opened and that Elements can be added.
      void resetImagepath()
      Resets the imagepath.
      void setFooter(com.lowagie.text.HeaderFooter footer)
      Changes the footer of this document.
      void setHeader(com.lowagie.text.HeaderFooter header)
      Changes the header of this document.
      void setImagepath(String imagepath)
      Sets the basepath for images.
      void setStandardFont(com.lowagie.text.Font standardfont)
      Changes the standardfont.
      protected void write(com.lowagie.text.Element element, int indent)
      Writes the HTML representation of an element.
      protected void write(com.lowagie.text.Font font, Properties styleAttributes)
      Writes the representation of a Font.
      protected void writeComment(String comment)
      Writes some comment.
      protected void writeCssProperty(String prop, String value)
      Writes out a CSS property.
      protected void writeHeader(com.lowagie.text.Meta meta)
      Writes a Metatag in the header.
      protected void writeJavaScript(com.lowagie.text.Header header)
      Writes a JavaScript section or, if the markup attribute HtmlTags.URL is set, a JavaScript reference in the header.
      protected void writeLink(com.lowagie.text.Header header)
      Writes a link in the header.
      protected void writeSection(com.lowagie.text.Section section, int indent)
      Writes the HTML representation of a section.
      • Methods inherited from class com.lowagie.text.DocWriter

        addTabs, flush, getISOBytes, isCloseStream, isPaused, pause, resetFooter, resetHeader, resetPageCount, resume, setCloseStream, setMarginMirroring, setMarginMirroringTopBottom, setMargins, setPageCount, setPageSize, write, write, writeEnd, writeEnd, writeMarkupAttributes, writeStart
    • Field Detail

      • BEGINCOMMENT

        public static final byte[] BEGINCOMMENT
        This is a possible HTML-tag.
      • ENDCOMMENT

        public static final byte[] ENDCOMMENT
        This is a possible HTML-tag.
      • currentfont

        protected Stack currentfont
        This is the current font of the HTML.
      • standardfont

        protected com.lowagie.text.Font standardfont
        This is the standard font of the HTML.
      • imagepath

        protected String imagepath
        This is a path for images.
      • pageN

        protected int pageN
        Stores the page number.
      • header

        protected com.lowagie.text.HeaderFooter header
        This is the textual part of a header
      • footer

        protected com.lowagie.text.HeaderFooter footer
        This is the textual part of the footer
      • markup

        protected Properties markup
        Store the markup properties of a MarkedObject.
    • Constructor Detail

      • HtmlWriter

        protected HtmlWriter(com.lowagie.text.Document doc,
                             OutputStream os)
        Constructs a HtmlWriter.
        Parameters:
        doc - The Document that has to be written as HTML
        os - The OutputStream the writer has to write to.
    • Method Detail

      • getInstance

        public static HtmlWriter getInstance(com.lowagie.text.Document document,
                                             OutputStream os)
        Gets an instance of the HtmlWriter.
        Parameters:
        document - The Document that has to be written
        os - The OutputStream the writer has to write to.
        Returns:
        a new HtmlWriter
      • newPage

        public boolean newPage()
        Signals that an new page has to be started.
        Specified by:
        newPage in interface com.lowagie.text.DocListener
        Overrides:
        newPage in class com.lowagie.text.DocWriter
        Returns:
        true if this action succeeded, false if not.
      • add

        public boolean add(com.lowagie.text.Element element)
                    throws com.lowagie.text.DocumentException
        Signals that an Element was added to the Document.
        Specified by:
        add in interface com.lowagie.text.ElementListener
        Overrides:
        add in class com.lowagie.text.DocWriter
        Parameters:
        element - a high level object that has to be translated to HTML
        Returns:
        true if the element was added, false if not.
        Throws:
        com.lowagie.text.DocumentException - when a document isn't open yet, or has been closed
      • open

        public void open()
        Signals that the Document has been opened and that Elements can be added.

        The HEAD-section of the HTML-document is written.

        Specified by:
        open in interface com.lowagie.text.DocListener
        Overrides:
        open in class com.lowagie.text.DocWriter
      • close

        public void close()
        Signals that the Document was closed and that no other Elements will be added.
        Specified by:
        close in interface com.lowagie.text.DocListener
        Overrides:
        close in class com.lowagie.text.DocWriter
      • initHeader

        protected void initHeader()
        Adds the header to the top of the Document
      • initFooter

        protected void initFooter()
        Adds the header to the top of the Document
      • writeHeader

        protected void writeHeader(com.lowagie.text.Meta meta)
                            throws IOException
        Writes a Metatag in the header.
        Parameters:
        meta - the element that has to be written
        Throws:
        IOException
      • writeLink

        protected void writeLink(com.lowagie.text.Header header)
                          throws IOException
        Writes a link in the header.
        Parameters:
        header - the element that has to be written
        Throws:
        IOException
      • writeJavaScript

        protected void writeJavaScript(com.lowagie.text.Header header)
                                throws IOException
        Writes a JavaScript section or, if the markup attribute HtmlTags.URL is set, a JavaScript reference in the header.
        Parameters:
        header - the element that has to be written
        Throws:
        IOException
      • writeComment

        protected void writeComment(String comment)
                             throws IOException
        Writes some comment.

        This method writes some comment.

        Parameters:
        comment - the comment that has to be written
        Throws:
        IOException
      • setStandardFont

        public void setStandardFont(com.lowagie.text.Font standardfont)
        Changes the standardfont.
        Parameters:
        standardfont - The font
      • isOtherFont

        public boolean isOtherFont(com.lowagie.text.Font font)
        Checks if a given font is the same as the font that was last used.
        Parameters:
        font - the font of an object
        Returns:
        true if the font differs
      • setImagepath

        public void setImagepath(String imagepath)
        Sets the basepath for images.

        This is especially useful if you add images using a file, rather than an URL. In PDF there is no problem, since the images are added inline, but in HTML it is sometimes necessary to use a relative path or a special path to some images directory.

        Parameters:
        imagepath - the new imagepath
      • resetImagepath

        public void resetImagepath()
        Resets the imagepath.
      • setHeader

        public void setHeader(com.lowagie.text.HeaderFooter header)
        Changes the header of this document.
        Specified by:
        setHeader in interface com.lowagie.text.DocListener
        Overrides:
        setHeader in class com.lowagie.text.DocWriter
        Parameters:
        header - the new header
      • setFooter

        public void setFooter(com.lowagie.text.HeaderFooter footer)
        Changes the footer of this document.
        Specified by:
        setFooter in interface com.lowagie.text.DocListener
        Overrides:
        setFooter in class com.lowagie.text.DocWriter
        Parameters:
        footer - the new footer
      • add

        public boolean add(String string)
        Signals that a String was added to the Document.
        Parameters:
        string - a String to add to the HTML
        Returns:
        true if the string was added, false if not.
      • write

        protected void write(com.lowagie.text.Element element,
                             int indent)
                      throws IOException
        Writes the HTML representation of an element.
        Parameters:
        element - the element
        indent - the indentation
        Throws:
        IOException
      • writeSection

        protected void writeSection(com.lowagie.text.Section section,
                                    int indent)
                             throws IOException
        Writes the HTML representation of a section.
        Parameters:
        section - the section to write
        indent - the indentation
        Throws:
        IOException
      • write

        protected void write(com.lowagie.text.Font font,
                             Properties styleAttributes)
                      throws IOException
        Writes the representation of a Font.
        Parameters:
        font - a Font
        styleAttributes - the style of the font
        Throws:
        IOException
      • writeCssProperty

        protected void writeCssProperty(String prop,
                                        String value)
                                 throws IOException
        Writes out a CSS property.
        Parameters:
        prop - a CSS property
        value - the value of the CSS property
        Throws:
        IOException

Copyright © 2017. All rights reserved.