org.af.commons.io.pdf
Class PDFHelper

java.lang.Object
  extended by org.af.commons.io.pdf.PDFHelper

public class PDFHelper
extends Object

This class contains static methods for creating PDF files with iText.


Field Summary
static com.lowagie.text.Font font
           
static com.lowagie.text.Font fontb
           
static com.lowagie.text.Font fonth
           
 
Constructor Summary
PDFHelper()
           
 
Method Summary
static com.lowagie.text.pdf.PdfPTable createTable(List<List<Object>> xtable, List<String> header)
          Creates a PdfPTable.
static void enable4Borders(com.lowagie.text.Cell cell)
          Sets the four borders of a cell to 0.5f.
static com.lowagie.text.Image getImage(com.lowagie.text.pdf.PdfWriter writer, File file)
          Returns a com.lowagie.text.Image from a image or PDF file.
static com.lowagie.text.Image getPdfImage(com.lowagie.text.pdf.PdfWriter writer, File file)
          Returns a com.lowagie.text.Image from the first page of a PDF file.
static boolean isPDF(File file)
          Determines whether a given file is a PDF file by extension.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

font

public static com.lowagie.text.Font font

fontb

public static com.lowagie.text.Font fontb

fonth

public static com.lowagie.text.Font fonth
Constructor Detail

PDFHelper

public PDFHelper()
Method Detail

getImage

public static com.lowagie.text.Image getImage(com.lowagie.text.pdf.PdfWriter writer,
                                              File file)
                                       throws IOException,
                                              com.lowagie.text.BadElementException
Returns a com.lowagie.text.Image from a image or PDF file. In the second case the first page of the PDF file is returned as image.

Parameters:
writer - PdfWriter
file - file to read
Returns:
Image created from the file
Throws:
IOException
com.lowagie.text.BadElementException

getPdfImage

public static com.lowagie.text.Image getPdfImage(com.lowagie.text.pdf.PdfWriter writer,
                                                 File file)
                                          throws IOException,
                                                 com.lowagie.text.BadElementException
Returns a com.lowagie.text.Image from the first page of a PDF file.

Parameters:
writer - PdfWriter
file - file to read
Returns:
Image created from the file
Throws:
IOException
com.lowagie.text.BadElementException

isPDF

public static boolean isPDF(File file)
Determines whether a given file is a PDF file by extension. [Alternatively we could test whether the first 4 byte are "%PDF-".]

Parameters:
file - file to check
Returns:
Has the given file the extension ".pdf"? (case insensitive)

createTable

public static com.lowagie.text.pdf.PdfPTable createTable(List<List<Object>> xtable,
                                                         List<String> header)
                                                  throws com.lowagie.text.BadElementException,
                                                         IOException
Creates a PdfPTable.

Parameters:
xtable - xtable.get(i) represents the i-th row of the table
header - column headers for the table
Returns:
PdfPTable created from the arguments
Throws:
com.lowagie.text.BadElementException
IOException

enable4Borders

public static void enable4Borders(com.lowagie.text.Cell cell)
Sets the four borders of a cell to 0.5f.

Parameters:
cell - Cell which borders are set.