public class PDFTool
extends java.lang.Object
PDF toolbox
Modifier and Type | Class and Description |
---|---|
class |
PDFTool.PDFEvent
PDF events, manage specific header and footer
|
static interface |
PDFTool.PDFInterface |
Modifier and Type | Field and Description |
---|---|
static com.lowagie.text.Font |
BOLD |
static com.lowagie.text.pdf.PdfPCell |
CELL_BLACK |
static com.lowagie.text.pdf.PdfPCell |
CELL_GRAY |
static com.lowagie.text.pdf.PdfPCell |
CELL_WHITE |
static com.lowagie.text.Font |
CODE |
static com.lowagie.text.Paragraph |
EMPTY |
static java.lang.String |
EURO |
static com.lowagie.text.Font |
HEADER |
static java.awt.Color |
IMAGE_COLOR |
static float |
IMAGE_SCALE |
static com.lowagie.text.Font |
MEDIUM |
static com.lowagie.text.Font |
MONO |
static com.lowagie.text.Font |
NORMAL |
static com.lowagie.text.Font |
SCRIPT
Deprecated.
|
static com.lowagie.text.Font |
SMALL |
static com.lowagie.text.Font |
TINY |
static com.lowagie.text.Font |
TITLE0 |
static com.lowagie.text.Font |
TITLE1 |
static com.lowagie.text.Font |
TITLE2 |
Constructor and Description |
---|
PDFTool() |
Modifier and Type | Method and Description |
---|---|
static com.lowagie.text.Chapter |
addChapter(com.lowagie.text.Document d,
java.lang.String title,
PDFTool.PDFEvent event,
boolean isOpen) |
static com.lowagie.text.Paragraph |
addHTMLParagraph(java.lang.String htmlString) |
static com.lowagie.text.Section |
addSection(com.lowagie.text.Document d,
com.lowagie.text.Chapter chapter,
java.lang.String title,
PDFTool.PDFEvent event,
boolean isOpen) |
static com.lowagie.text.Section |
addSection(com.lowagie.text.Document d,
com.lowagie.text.Section section,
java.lang.String title,
PDFTool.PDFEvent event,
boolean isOpen) |
static com.lowagie.text.Document |
build(PDFTool.PDFInterface pdf,
java.lang.String pdfPath,
boolean replace) |
static com.lowagie.text.Document |
build(com.lowagie.text.Rectangle pageSize,
PDFTool.PDFInterface pdf,
java.lang.String pdfPath,
boolean replace)
Build a simple PDF document
|
static com.lowagie.text.Document |
build(com.lowagie.text.Rectangle pageSize,
PDFTool.PDFInterface pdf,
java.lang.String pdfPath,
boolean replace,
PDFTool.PDFEvent event,
int tocPage,
int tocDepth)
Build a PDF document
|
static void |
close(com.lowagie.text.Document d)
Close a document
|
static byte[] |
concat(byte[] in1,
byte[] in2) |
static void |
concat(java.io.File out,
java.io.File in1,
java.io.File in2) |
static void |
concat(java.io.OutputStream os,
java.io.InputStream is1,
java.io.InputStream is2) |
static void |
concat(java.lang.String out,
java.lang.String in1,
java.lang.String in2) |
static com.lowagie.text.pdf.PdfPCell |
getCell(java.lang.String text)
Build a Table cell
|
static com.lowagie.text.pdf.PdfPCell |
getCell(java.lang.String text,
com.lowagie.text.Font font,
int align,
boolean border,
java.awt.Color color)
Build a Table cell
|
static com.lowagie.text.pdf.PdfPCell |
getCellImage(java.lang.String path,
java.awt.Color bkg) |
static com.lowagie.text.pdf.PdfPCell |
getColoredCell(java.awt.Color color,
boolean border)
Build an empty colored cell
|
static com.lowagie.text.pdf.PdfPCell |
getDecalCell(java.lang.String text,
com.lowagie.text.Font font,
int align,
boolean border,
java.awt.Color color)
Build decaled cell on the right
|
static PDFTool.PDFEvent |
getDocEvent(boolean pagine,
int margin,
byte[] headerImg,
byte[] footerImg)
Build a document event handler
|
static PDFTool.PDFEvent |
getDocEvent(boolean pagine,
int margin,
java.lang.String headerImg,
java.lang.String footerImg)
Build a document event handler
|
static com.lowagie.text.pdf.PdfPCell |
getHeaderCell(java.lang.String text,
java.awt.Color color)
Build a header cell
|
static com.lowagie.text.pdf.PdfPCell |
getHeaderCell(java.lang.String text,
int align,
java.awt.Color color)
Build a header cell
|
static com.lowagie.text.pdf.PdfPCell |
getHeaderCellVertical(java.lang.String text,
java.awt.Color color)
Build a header cell with vertical text
|
static com.lowagie.text.Image |
getImage(byte[] data)
Get an image from specified byte array data
|
static com.lowagie.text.Image |
getImage(java.lang.String path)
Get an image from specified file path
|
static com.lowagie.text.Image |
getImageFromDBDoc(Grant g,
DocumentDB doc)
Get image from from DBDoc image
|
static com.lowagie.text.Image |
getImageFromDBDoc(Grant g,
java.lang.String docId)
Get image from DBDoc image
|
static com.lowagie.text.Image |
getImageFromResource(Grant g,
java.lang.String resourceCode)
Get image from disposition resource image
|
static com.lowagie.text.Image |
getImageFromResource(Grant g,
java.lang.String resourceCode,
java.lang.String objectName,
java.lang.String objectId)
Get image from resource image
|
static com.lowagie.text.Image |
getImageFromResource(ObjectDB obj,
java.lang.String resourceCode)
Get image from object resource image
|
static com.lowagie.text.Image |
getImageFromResource(com.simplicite.objects.System.ObjectExternal ext,
java.lang.String resourceCode)
Get image from external object resource image
|
static com.lowagie.text.Image |
getImageFromStaticContent(Grant g,
java.lang.String relativePath)
Get image from static content
|
static com.lowagie.text.Image |
getImageFromStaticResource(java.lang.String path)
Get image from static resource
|
static com.lowagie.text.Paragraph |
getLovParagraph(ObjectField f) |
static com.lowagie.text.pdf.PdfPTable |
getTable(int[] cols,
boolean header)
Build a PDF table
|
static com.lowagie.text.pdf.PdfPTable |
getTable(int[] cols,
boolean header,
int spacingBefore,
int spacingAfter)
Build a PDF table
|
static com.lowagie.text.pdf.PdfPTable |
getTable(int nbcols,
boolean header)
Build a PDF table
|
static java.lang.String |
getValue(ObjectDB o,
ObjectField f,
boolean lovCode) |
static com.lowagie.text.pdf.PdfPTable |
insertFieldArea(com.lowagie.text.Document d,
ObjectDB o,
FieldArea fa,
java.awt.Color bkg,
boolean lovCode,
boolean emptyValues)
Insert a field area as a table of 2 columns
|
static void |
insertForm(com.lowagie.text.Document d,
ObjectDB o,
java.awt.Color bkg,
boolean lovCode)
Insert object form in PDF (flow of field areas)
|
static void |
insertForm(com.lowagie.text.Document d,
ObjectDB o,
java.awt.Color bkg,
boolean lovCode,
boolean emptyValues)
Insert object form in PDF (flow of field areas)
|
static void |
insertImage(com.lowagie.text.Document d,
com.lowagie.text.Image img,
boolean canRotate,
int align)
Insert one image into the document
|
static void |
insertList(com.lowagie.text.Document d,
ObjectDB o,
boolean splitOption,
boolean splitBoolean,
boolean splitLongText,
boolean lov,
java.awt.Color headColor,
boolean lovCode)
Generic method to serialize one object current list
in distinct PDF tables : Mandatories, Options, Booleans, Long text/HTML, images
|
static void |
insertList(com.lowagie.text.Document d,
ObjectDB o,
java.util.Vector<ObjectField> cols,
java.util.Vector<ObjectField> options,
java.util.Vector<ObjectField> bools,
java.util.Vector<ObjectField> larges,
boolean lov,
java.awt.Color headColor,
boolean lovCode) |
static void |
main(java.lang.String[] args) |
static com.lowagie.text.Document |
open(java.io.OutputStream out)
Open a new PDF document A4 with output stream
|
static com.lowagie.text.Document |
open(java.io.OutputStream out,
PDFTool.PDFEvent event)
Open a new PDF document A4 with output stream
|
static com.lowagie.text.Document |
open(com.lowagie.text.Rectangle pageSize,
java.io.OutputStream out,
PDFTool.PDFEvent event)
Open a new PDF document with output stream
|
static com.lowagie.text.Document |
open(com.lowagie.text.Rectangle pageSize,
java.lang.String pdfPath,
boolean replace,
PDFTool.PDFEvent event)
Open a new PDF document with file output
|
static void |
stamp(java.io.InputStream in,
java.io.OutputStream out,
byte[] image,
float posX,
float posY)
Stamp an existing PDF with an image on each pages
|
public static com.lowagie.text.Font TITLE0
public static com.lowagie.text.Font TITLE1
public static com.lowagie.text.Font TITLE2
public static com.lowagie.text.Font HEADER
public static com.lowagie.text.Font BOLD
public static com.lowagie.text.Font NORMAL
public static com.lowagie.text.Font MONO
public static com.lowagie.text.Font MEDIUM
public static com.lowagie.text.Font SMALL
public static com.lowagie.text.Font CODE
public static com.lowagie.text.Font TINY
@Deprecated public static com.lowagie.text.Font SCRIPT
public static com.lowagie.text.Paragraph EMPTY
public static com.lowagie.text.pdf.PdfPCell CELL_WHITE
public static com.lowagie.text.pdf.PdfPCell CELL_GRAY
public static com.lowagie.text.pdf.PdfPCell CELL_BLACK
public static java.awt.Color IMAGE_COLOR
public static final java.lang.String EURO
public static final float IMAGE_SCALE
public static com.lowagie.text.Document build(PDFTool.PDFInterface pdf, java.lang.String pdfPath, boolean replace)
public static com.lowagie.text.Document build(com.lowagie.text.Rectangle pageSize, PDFTool.PDFInterface pdf, java.lang.String pdfPath, boolean replace)
pageSize
- such as PageSize.A4 or PageSize.A4.rotate()pdf
- Interface to implement the contentpdfPath
- File pathreplace
- True to delete any older doc, False to stop if already existspublic static com.lowagie.text.Document build(com.lowagie.text.Rectangle pageSize, PDFTool.PDFInterface pdf, java.lang.String pdfPath, boolean replace, PDFTool.PDFEvent event, int tocPage, int tocDepth)
pageSize
- such as PageSize.A4 or PageSize.A4.rotate()pdf
- Interface to implement the contentpdfPath
- File pathreplace
- True to delete any older doc, False to stop if already existsevent
- Doc event (may be null)tocPage
- Insert a table of content in the given page, 0 = no TOCtocDepth
- Table of content depth (chapter=1, section=2, sub-section=3...)public static com.lowagie.text.Document open(com.lowagie.text.Rectangle pageSize, java.lang.String pdfPath, boolean replace, PDFTool.PDFEvent event)
Open a new PDF document with file output
pdfPath
- File pathreplace
- True to delete any older doc, False to stop if already existsevent
- Doc event (may be null)public static final com.lowagie.text.Document open(java.io.OutputStream out)
Open a new PDF document A4 with output stream
out
- Output stream (can be HTTP response output stream of file output stream)public static final com.lowagie.text.Document open(java.io.OutputStream out, PDFTool.PDFEvent event)
Open a new PDF document A4 with output stream
out
- Output stream (can be HTTP response output stream of file output stream)event
- Doc event (may be null)public static com.lowagie.text.Document open(com.lowagie.text.Rectangle pageSize, java.io.OutputStream out, PDFTool.PDFEvent event)
Open a new PDF document with output stream
pageSize
- such as PageSize.A4 or PageSize.A4.rotate()out
- Output stream (can be HTTP response output stream of file output stream)event
- Doc event (may be null)public static void close(com.lowagie.text.Document d)
Close a document
d
- Opened documentpublic static final void stamp(java.io.InputStream in, java.io.OutputStream out, byte[] image, float posX, float posY) throws java.lang.Exception
Stamp an existing PDF with an image on each pages
in
- Input stream of source PDFout
- Output stream of destination PDFimage
- Image dataposX
- Absolute position XposY
- Absolute position Yjava.lang.Exception
public static PDFTool.PDFEvent getDocEvent(boolean pagine, int margin, java.lang.String headerImg, java.lang.String footerImg)
pagine
- True to display the page numbers on page bottommargin
- Border margin in pixelsheaderImg
- Path to the header imagefooterImg
- Path to the footer imagepublic static PDFTool.PDFEvent getDocEvent(boolean pagine, int margin, byte[] headerImg, byte[] footerImg)
pagine
- True to display the page numbers on page bottommargin
- Border margin in pixelsheaderImg
- Header image datafooterImg
- Footer image datapublic static com.lowagie.text.Chapter addChapter(com.lowagie.text.Document d, java.lang.String title, PDFTool.PDFEvent event, boolean isOpen) throws com.lowagie.text.DocumentException
com.lowagie.text.DocumentException
public static com.lowagie.text.Section addSection(com.lowagie.text.Document d, com.lowagie.text.Chapter chapter, java.lang.String title, PDFTool.PDFEvent event, boolean isOpen) throws com.lowagie.text.DocumentException
com.lowagie.text.DocumentException
public static com.lowagie.text.Section addSection(com.lowagie.text.Document d, com.lowagie.text.Section section, java.lang.String title, PDFTool.PDFEvent event, boolean isOpen) throws com.lowagie.text.DocumentException
com.lowagie.text.DocumentException
public static com.lowagie.text.pdf.PdfPCell getCell(java.lang.String text)
Build a Table cell
text
- Simple textpublic static com.lowagie.text.pdf.PdfPCell getCell(java.lang.String text, com.lowagie.text.Font font, int align, boolean border, java.awt.Color color)
Build a Table cell
text
- Simple textfont
- Font to usealign
- Alignmentborder
- True to draw the bordercolor
- Background colorpublic static com.lowagie.text.pdf.PdfPCell getHeaderCell(java.lang.String text, int align, java.awt.Color color)
Build a header cell
text
- header textalign
- cell alignmentpublic static com.lowagie.text.pdf.PdfPCell getHeaderCell(java.lang.String text, java.awt.Color color)
Build a header cell
text
- Textpublic static com.lowagie.text.pdf.PdfPCell getHeaderCellVertical(java.lang.String text, java.awt.Color color)
Build a header cell with vertical text
text
- Textpublic static com.lowagie.text.pdf.PdfPCell getColoredCell(java.awt.Color color, boolean border)
Build an empty colored cell
color
- Background colorborder
- True to draw the borderpublic static com.lowagie.text.pdf.PdfPCell getDecalCell(java.lang.String text, com.lowagie.text.Font font, int align, boolean border, java.awt.Color color)
Build decaled cell on the right
public static com.lowagie.text.pdf.PdfPTable getTable(int[] cols, boolean header, int spacingBefore, int spacingAfter) throws com.lowagie.text.DocumentException
Build a PDF table
cols
- Table of column sizes or percents; table size = nbr of columnscom.lowagie.text.DocumentException
public static com.lowagie.text.pdf.PdfPTable getTable(int[] cols, boolean header) throws com.lowagie.text.DocumentException
Build a PDF table
cols
- Table of columns size in percents; table size = nbr of columnsheader
- True to display a header linecom.lowagie.text.DocumentException
public static com.lowagie.text.pdf.PdfPTable getTable(int nbcols, boolean header) throws com.lowagie.text.DocumentException
Build a PDF table
nbcols
- Nb of columnsheader
- True to display a header linecom.lowagie.text.DocumentException
public static void insertList(com.lowagie.text.Document d, ObjectDB o, boolean splitOption, boolean splitBoolean, boolean splitLongText, boolean lov, java.awt.Color headColor, boolean lovCode) throws com.lowagie.text.DocumentException
d
- Documento
- ObjectsplitOption
- Put the optional fields after the main tablesplitBoolean
- Put the boolean fields after the main tablesplitLongText
- Put the large fields after the main tablelov
- True to insert the lists of values after allcom.lowagie.text.DocumentException
public static void insertList(com.lowagie.text.Document d, ObjectDB o, java.util.Vector<ObjectField> cols, java.util.Vector<ObjectField> options, java.util.Vector<ObjectField> bools, java.util.Vector<ObjectField> larges, boolean lov, java.awt.Color headColor, boolean lovCode) throws com.lowagie.text.DocumentException
com.lowagie.text.DocumentException
public static java.lang.String getValue(ObjectDB o, ObjectField f, boolean lovCode)
public static com.lowagie.text.pdf.PdfPCell getCellImage(java.lang.String path, java.awt.Color bkg) throws java.lang.Exception
java.lang.Exception
public static com.lowagie.text.Paragraph getLovParagraph(ObjectField f)
public static com.lowagie.text.Paragraph addHTMLParagraph(java.lang.String htmlString)
public static void insertForm(com.lowagie.text.Document d, ObjectDB o, java.awt.Color bkg, boolean lovCode, boolean emptyValues) throws com.lowagie.text.DocumentException
d
- Documento
- Objectbkg
- Field name backgroundlovCode
- Display LOV code or labelemptyValues
- true to display empty valuescom.lowagie.text.DocumentException
public static void insertForm(com.lowagie.text.Document d, ObjectDB o, java.awt.Color bkg, boolean lovCode) throws com.lowagie.text.DocumentException
d
- Documento
- Objectbkg
- Field name backgroundlovCode
- Display LOV code or labelcom.lowagie.text.DocumentException
public static com.lowagie.text.pdf.PdfPTable insertFieldArea(com.lowagie.text.Document d, ObjectDB o, FieldArea fa, java.awt.Color bkg, boolean lovCode, boolean emptyValues) throws com.lowagie.text.DocumentException
d
- Document (optional)o
- Objectfa
- Field areabkg
- Field name backgroundlovCode
- Display LOV code or labelemptyValues
- true to display empty valuescom.lowagie.text.DocumentException
public static com.lowagie.text.Image getImageFromDBDoc(Grant g, java.lang.String docId)
g
- GrantdocId
- Image document IDpublic static com.lowagie.text.Image getImageFromDBDoc(Grant g, DocumentDB doc)
g
- Grantdoc
- Image documentpublic static com.lowagie.text.Image getImageFromResource(Grant g, java.lang.String resourceCode)
g
- GrantresourceCode
- Resource codepublic static com.lowagie.text.Image getImageFromResource(ObjectDB obj, java.lang.String resourceCode)
obj
- ObjectresourceCode
- Resource codepublic static com.lowagie.text.Image getImageFromResource(com.simplicite.objects.System.ObjectExternal ext, java.lang.String resourceCode)
ext
- External objectresourceCode
- Resource codepublic static com.lowagie.text.Image getImageFromResource(Grant g, java.lang.String resourceCode, java.lang.String objectName, java.lang.String objectId)
g
- GrantresourceCode
- Resource codeobjectName
- Object name (typically Disposition, ObjectInternal or ObjectExternal)objectId
- Object IDpublic static com.lowagie.text.Image getImageFromStaticResource(java.lang.String path)
path
- Static image resource pathpublic static com.lowagie.text.Image getImageFromStaticContent(Grant g, java.lang.String relativePath)
g
- GrantrelativePath
- Static content image relative pathpublic static com.lowagie.text.Image getImage(java.lang.String path)
path
- Absolute path to image filepublic static com.lowagie.text.Image getImage(byte[] data)
data
- Image datapublic static void insertImage(com.lowagie.text.Document d, com.lowagie.text.Image img, boolean canRotate, int align)
d
- PDF documentimg
- ImagecanRotate
- True to rotate the image when larger than doc widthalign
- Image alignment ex: Image.MIDDLEpublic static void concat(java.lang.String out, java.lang.String in1, java.lang.String in2) throws java.lang.Exception
java.lang.Exception
public static void concat(java.io.File out, java.io.File in1, java.io.File in2) throws java.lang.Exception
java.lang.Exception
public static byte[] concat(byte[] in1, byte[] in2) throws java.lang.Exception
java.lang.Exception
public static void concat(java.io.OutputStream os, java.io.InputStream is1, java.io.InputStream is2) throws java.lang.Exception
java.lang.Exception
public static void main(java.lang.String[] args)
Copyright (c)2006-2014 Simplicite Software. All Rights Reserved.