platypus.pdf
Class PageSize

java.lang.Object
  extended by platypus.pdf.PageSize

public class PageSize
extends java.lang.Object

All functions relating to setting, getting, and dumping the page size

Author:
alb

Field Summary
private  float height
          page height in points
private  int lineNumber
          line where page size is specified
private  java.util.HashMap<java.lang.String,com.lowagie.text.Rectangle> pageNames
          HashMap that maps strings of page-size names to iText rectangles
private  float width
          page width in points
 
Constructor Summary
PageSize()
          Default constructor simply uses the default values (letter, or 8.5" x 11")
 
Method Summary
 java.lang.String dump()
          Creates a string containing the line # and the values of page size when last set
 float getHeight()
          getter for page height
 float getWidth()
          getter for page width
 void initialize(java.lang.String sizeName)
          Initialize the page size to one of the pre-written shorthand sizes (LTR, LGL, A4, etc.)
private  void loadPageNames()
          Load the page names and the corresponding iText rectangles into a hash table.
 void setCustomPageHeight(java.lang.String newHeight)
          sets page height to a custom amount (not using of the many predefined page sizes)
 void setCustomPageWidth(java.lang.String newWidth)
          sets page width to a custom amount (not using one of the many predefined sizes)
 java.lang.String tooLateError()
          Logs an error when the user tries to change the size of the page after any text has been emitted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

width

private float width
page width in points


height

private float height
page height in points


lineNumber

private int lineNumber
line where page size is specified


pageNames

private java.util.HashMap<java.lang.String,com.lowagie.text.Rectangle> pageNames
HashMap that maps strings of page-size names to iText rectangles

Constructor Detail

PageSize

public PageSize()
Default constructor simply uses the default values (letter, or 8.5" x 11")

Method Detail

getWidth

public float getWidth()
getter for page width

Returns:
width in points

getHeight

public float getHeight()
getter for page height

Returns:
height in points

setCustomPageHeight

public void setCustomPageHeight(java.lang.String newHeight)
                         throws java.lang.IllegalArgumentException
sets page height to a custom amount (not using of the many predefined page sizes)

Parameters:
newHeight - string containing what the user newHeight
Throws:
java.lang.IllegalArgumentException - if invalid page height is specified

setCustomPageWidth

public void setCustomPageWidth(java.lang.String newWidth)
                        throws java.lang.IllegalArgumentException
sets page width to a custom amount (not using one of the many predefined sizes)

Parameters:
newWidth - string containing what the user newWidth
Throws:
java.lang.IllegalArgumentException - if invalid page width is specified

initialize

public void initialize(java.lang.String sizeName)
                throws java.lang.IllegalArgumentException
Initialize the page size to one of the pre-written shorthand sizes (LTR, LGL, A4, etc.)

Parameters:
sizeName - the pre-existing shorthand name for a specific page size
Throws:
java.lang.IllegalArgumentException - if invalid string is passed in.

loadPageNames

private void loadPageNames()
Load the page names and the corresponding iText rectangles into a hash table. for more info on page sizes see: http://en.wikipedia.org/wiki/Paper_size#Loose_sizes for info on ID cards sizes, see: http://en.wikipedia.org/wiki/ISO_7810


dump

public java.lang.String dump()
Creates a string containing the line # and the values of page size when last set

Returns:
formatted string suitable for use in dump TODO: Consider looking thru the pageNames table and dumping the name for the page size Note: if we do this, then loadPageNames() must be called in the constructor.

tooLateError

public java.lang.String tooLateError()
Logs an error when the user tries to change the size of the page after any text has been emitted. Platypus does not support this.

Returns:
a string containing the error message (string used primarily for testing)


Copyright © 2006-7 Pacific Data Works LLC