info.informatica.doc.pdf.itext
Class PDFStyleDatabase

java.lang.Object
  extended by info.informatica.doc.style.css.AbstractStyleDatabase
      extended by info.informatica.doc.pdf.itext.PDFStyleDatabase
All Implemented Interfaces:
StyleDatabase

public class PDFStyleDatabase
extends AbstractStyleDatabase

PDF/iText Style database.

Author:
Carlos Amengual (amengual at informatica.info)

Field Summary
protected  com.itextpdf.text.Rectangle pageSize
           
 
Fields inherited from class info.informatica.doc.style.css.AbstractStyleDatabase
DEFAULT_GENERIC_FONT_FAMILY, DEFAULT_INITIAL_COLOR
 
Constructor Summary
PDFStyleDatabase()
          Creates a style database for a PDF of A4 size.
PDFStyleDatabase(com.itextpdf.text.Rectangle pageSize)
           
 
Method Summary
protected  float cmToPixels(float cm)
          Converts from centimeters to pixels.
 String getDefaultGenericFontFamily(String genericFamily)
          Gets the name of the default font used when a generic font family (serif, sans-serif, monospace, cursive, fantasy) is specified.
 float getDocumentHeight()
          Gets the height of the document (or screen viewport) in the natural unit for the device.
 float getDocumentWidth()
          Gets the width of the document (or screen viewport) in the natural unit for the device.
 int getFontSizeFromIdentifier(String familyName, String fontSizeIdentifier)
          Gets the font size from the given size identifier (small, medium, etc.), expressed in typographic points.
 short getFontSizeUnit()
           
 short getNaturalUnit()
          Gets the identifier of the device's natural unit.
 float getWidthSize(String widthIdentifier)
          Gets the size corresponging to the given identifier (thin, thick, medium).
 boolean isFontFamilyAvailable(String fontFamily)
          Checks if a font family is available.
protected  float pxTocm(int px)
          Converts from pixels to centimeters.
 void setPageSize(com.itextpdf.text.Rectangle pageSize)
          Sets the page size for this PDF.
 
Methods inherited from class info.informatica.doc.style.css.AbstractStyleDatabase
floatValueConversion, floatValueConversion, getDefaultGenericFontFamily, getExSizeInPt, getInitialColor, getScrollbarWidth, setInitialColor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pageSize

protected com.itextpdf.text.Rectangle pageSize
Constructor Detail

PDFStyleDatabase

public PDFStyleDatabase()
Creates a style database for a PDF of A4 size.


PDFStyleDatabase

public PDFStyleDatabase(com.itextpdf.text.Rectangle pageSize)
Method Detail

setPageSize

public void setPageSize(com.itextpdf.text.Rectangle pageSize)
Sets the page size for this PDF.

Parameters:
pageSize - the page size.

getDefaultGenericFontFamily

public String getDefaultGenericFontFamily(String genericFamily)
Description copied from interface: StyleDatabase
Gets the name of the default font used when a generic font family (serif, sans-serif, monospace, cursive, fantasy) is specified.

Parameters:
genericFamily - the name of the logical font.
Returns:
the name of the real font to which the generic name is mapped to, or null if none.

isFontFamilyAvailable

public boolean isFontFamilyAvailable(String fontFamily)
Description copied from interface: StyleDatabase
Checks if a font family is available.

Parameters:
fontFamily - the font family name.
Returns:
true if the font is available, false otherwise.

getFontSizeFromIdentifier

public int getFontSizeFromIdentifier(String familyName,
                                     String fontSizeIdentifier)
                              throws DOMException
Description copied from interface: StyleDatabase
Gets the font size from the given size identifier (small, medium, etc.), expressed in typographic points.

Parameters:
familyName - the font family name.
fontSizeIdentifier - the font size identifier.
Returns:
the font size.
Throws:
DOMException

getDocumentHeight

public float getDocumentHeight()
Description copied from interface: StyleDatabase
Gets the height of the document (or screen viewport) in the natural unit for the device.

Returns:
the height of the document.

getFontSizeUnit

public short getFontSizeUnit()

getNaturalUnit

public short getNaturalUnit()
Description copied from interface: StyleDatabase
Gets the identifier of the device's natural unit.

Returns:
the unit identifier as in CSSPrimitiveValue.

getDocumentWidth

public float getDocumentWidth()
Description copied from interface: StyleDatabase
Gets the width of the document (or screen viewport) in the natural unit for the device.

Returns:
the width of the document.

getWidthSize

public float getWidthSize(String widthIdentifier)
                   throws DOMException
Description copied from interface: StyleDatabase
Gets the size corresponging to the given identifier (thin, thick, medium).

Parameters:
widthIdentifier - the CSS width identifier.
Returns:
the size.
Throws:
DOMException

cmToPixels

protected float cmToPixels(float cm)
Description copied from class: AbstractStyleDatabase
Converts from centimeters to pixels.

Specified by:
cmToPixels in class AbstractStyleDatabase
Parameters:
cm - the value, in centimeters, to be converted.
Returns:
the value, expressed in pixels.

pxTocm

protected float pxTocm(int px)
Description copied from class: AbstractStyleDatabase
Converts from pixels to centimeters.

Specified by:
pxTocm in class AbstractStyleDatabase
Parameters:
px - the value, in pixels, to be converted.
Returns:
the value, expressed in centimeters.


Copyright © 2011 informatica.info. All Rights Reserved.