info.informatica.doc.pdf.itext
Class PDFStyleFormatter

java.lang.Object
  extended by info.informatica.doc.pdf.itext.PDFStyleFormatter

public class PDFStyleFormatter
extends Object

Utility class for helping in the format of iText PDF documents based on CSS style sheets.

TODO: work in progress.


Constructor Summary
PDFStyleFormatter(UserAgent<Image> userAgent)
           
 
Method Summary
 Chunk createChunk(CSSInlineBox box)
          Creates a chunk with the text and font specified by the given box.
 Chunk createChunk(CSSInlineBox box, String text)
          Creates a chunk with the text and font specified by the given box.
 Chunk createChunk(DownloadListener<Image> box)
          Creates a chunk with an image.
 Font createFont(CSS2ComputedProperties styledecl)
          Create an iText font from the properties specified in the given style.
 Phrase createPhrase(CSSInlineBox box)
          Creates a Phrase object according to the style of an inline box.
 void formatChunk(CSS2ComputedProperties styledecl, Chunk ch)
          Creates a chunk with the given text and the font specified by the style applying to the given box.
 void formatDocument(CSSBox box, Document pdf)
           
 void formatList(CSSContainerBox box, List list)
           
 void formatListItem(CSSContainerBox box, ListItem item)
           
 void formatParagraph(CSSBox box, Paragraph par)
          Formats the given paragraph according to the style that applies to the given peer element.
 void formatPCell(CSSTableCellBox box, PdfPCell cell)
          Formats a PdfPCell according to the style that applies to the given peer element.
 void formatPTable(CSSContainerBox box, PdfPTable table)
          Formats a PdfPTable according to the style that applies to the given peer element.
 void formatRectangle(CSSBox box, Rectangle rect)
           
 StyleDatabase getStyleDatabase()
          Gets the style database associated to this formatter.
static int translateAlignment(String align)
          Translates the alignment as provided by CSS/XHTML, to alignment as understood by the iText package.
static int translateVerticalAlignment(String align)
          Translates the vertical alignment as provided by CSS/XHTML, to same alignment as understood by the iText package.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PDFStyleFormatter

public PDFStyleFormatter(UserAgent<Image> userAgent)
Method Detail

getStyleDatabase

public StyleDatabase getStyleDatabase()
Gets the style database associated to this formatter.

Returns:
the style database.

createFont

public Font createFont(CSS2ComputedProperties styledecl)
                throws DocumentException
Create an iText font from the properties specified in the given style.

Parameters:
styledecl - the style declaration.
Returns:
the Font specified in the style sheet, or the closest one that could be created.
Throws:
DocumentException

translateAlignment

public static int translateAlignment(String align)
Translates the alignment as provided by CSS/XHTML, to alignment as understood by the iText package.

Parameters:
align - a string with the alignment identifier (left, right, center, justify).
Returns:
the alignment according to com.itextpdf.text.Element.

translateVerticalAlignment

public static int translateVerticalAlignment(String align)
Translates the vertical alignment as provided by CSS/XHTML, to same alignment as understood by the iText package.

Returns:
the vertical alignment according to com.itextpdf.text.Element.

createChunk

public Chunk createChunk(CSSInlineBox box)
Creates a chunk with the text and font specified by the given box.

Parameters:
box - the inline box.
Returns:
the chunk.

createChunk

public Chunk createChunk(CSSInlineBox box,
                         String text)
Creates a chunk with the text and font specified by the given box.

Parameters:
box - the inline box.
Returns:
the chunk.

createChunk

public Chunk createChunk(DownloadListener<Image> box)
Creates a chunk with an image.

Parameters:
box - the box containing an image.
Returns:
the chunk.

formatChunk

public void formatChunk(CSS2ComputedProperties styledecl,
                        Chunk ch)
Creates a chunk with the given text and the font specified by the style applying to the given box.

Parameters:
styledecl - the style applying to the chunk box.
ch - the chunk to format.

createPhrase

public Phrase createPhrase(CSSInlineBox box)
Creates a Phrase object according to the style of an inline box.

Parameters:
box - the inline box.
Returns:
the phrase.

formatDocument

public void formatDocument(CSSBox box,
                           Document pdf)

formatRectangle

public void formatRectangle(CSSBox box,
                            Rectangle rect)

formatParagraph

public void formatParagraph(CSSBox box,
                            Paragraph par)
Formats the given paragraph according to the style that applies to the given peer element.

Parameters:
box - the box to be rendered.
par - the paragraph to be formatted.

formatPTable

public void formatPTable(CSSContainerBox box,
                         PdfPTable table)
Formats a PdfPTable according to the style that applies to the given peer element.

Parameters:
box - the box to be rendered.
table - the table to be formatted.

formatPCell

public void formatPCell(CSSTableCellBox box,
                        PdfPCell cell)
Formats a PdfPCell according to the style that applies to the given peer element.

Parameters:
box - the box to be rendered.
cell - the cell to be formatted.

formatList

public void formatList(CSSContainerBox box,
                       List list)

formatListItem

public void formatListItem(CSSContainerBox box,
                           ListItem item)