|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lowagie.text.Document
com.lowagie.text.pdf.PdfDocument
PdfDocument
is the class that is used by PdfWriter
to translate a Document
into a PDF with different pages.
A PdfDocument
always listens to a Document
and adds the Pdf representation of every Element
that is
added to the Document
.
Document
,
DocListener
,
PdfWriter
Nested Class Summary | |
---|---|
(package private) static class |
PdfDocument.PdfCatalog
PdfCatalog is the PDF Catalog-object. |
static class |
PdfDocument.PdfInfo
PdfInfo is the PDF InfoDictionary. |
Field Summary | |
---|---|
(package private) PdfAcroForm |
acroForm
This is the AcroForm object. |
private PdfDictionary |
additionalActions
|
private int |
alignment
This represents the current alignment of the PDF Elements. |
private ArrayList |
annotations
This is the array containing the references to the annotations. |
protected HashMap |
boxSize
This is the size of the several boxes that will be used in the next page. |
private PdfAction |
currentAction
The current active PdfAction when processing an Anchor . |
private float |
currentHeight
This is the current height of the document. |
private PdfOutline |
currentOutline
This is the current PdfOutline in the hierarchy of outlines. |
private ArrayList |
delayedAnnotations
This is an array containg references to some delayed annotations. |
private ArrayList |
documentJavaScript
|
protected int |
duration
The duration of the page |
private boolean |
firstPageEvent
Signals that OnOpenDocument should be called. |
private PdfContentByte |
graphics
This is the PdfContentByte object, containing the borders and other Graphics. |
(package private) static String |
hangingPunctuation
The characters to be applied the hanging ponctuation. |
private float |
imageEnd
This is the position where the image ends. |
private float |
imageIndentLeft
This is the indentation caused by an image on the left. |
private float |
imageIndentRight
This is the indentation caused by an image on the right. |
private Image |
imageWait
This is the image that could not be shown on a previous page. |
private float |
indentBottom
This represents the current indentation of the PDF Elements on the bottom side. |
private float |
indentLeft
This represents the current indentation of the PDF Elements on the left side. |
private float |
indentRight
This represents the current indentation of the PDF Elements on the right side. |
private float |
indentTop
This represents the current indentation of the PDF Elements on the top side. |
private PdfDocument.PdfInfo |
info
some meta information about the Document. |
private boolean |
isNewpage
|
private boolean |
isParagraph
Signals that onParagraph is valid. |
private int |
lastElementType
Holds the type of the last element, that has been added to the document. |
private float |
leading
This represents the leading of the lines. |
private PdfLine |
line
The line that is currently being written. |
private ArrayList |
lines
The lines that are written until now. |
private float |
listIndentLeft
This represents the current indentation of the PDF Elements on the left side. |
private TreeMap |
localDestinations
Stores the destinations keyed by name. |
protected float |
nextMarginBottom
margin in y direction starting from the bottom. |
protected float |
nextMarginLeft
margin in x direction starting from the left. |
protected float |
nextMarginRight
margin in x direction starting from the right. |
protected float |
nextMarginTop
margin in y direction starting from the top. |
protected Rectangle |
nextPageSize
This is the size of the next page. |
private PdfAction |
openActionAction
|
private String |
openActionName
|
protected PdfDictionary |
pageAA
|
private boolean |
pageEmpty
This checks if the page is empty. |
private PdfPageLabels |
pageLabels
|
protected PageResources |
pageResources
This are the page resources of the current Page. |
private float |
paraIndent
|
private PdfOutline |
rootOutline
This is the root outline of the document. |
private boolean |
strictImageSequence
Holds value of property strictImageSequence. |
private PdfContentByte |
text
This is the PdfContentByte object, containing the text. |
private int |
textEmptySize
|
protected HashMap |
thisBoxSize
This is the size of the several boxes of the current Page. |
protected PdfTransition |
transition
The page transition |
private int |
viewerPreferences
these are the viewerpreferences of the document |
private PdfWriter |
writer
The PdfWriter . |
Fields inherited from class com.lowagie.text.Document |
---|
close, compress, footer, header, htmlStyleClass, javaScript_onLoad, javaScript_onUnLoad, marginBottom, marginLeft, marginMirroring, marginRight, marginTop, open, pageN, pageSize, watermark |
Constructor Summary | |
---|---|
PdfDocument()
Constructs a new PDF document. |
Method Summary | |
---|---|
boolean |
add(Element element)
Signals that an Element was added to the Document . |
private void |
add(Image image)
Adds an image to the document. |
private void |
add(PdfTable table,
boolean onlyFirstPage)
Adds a new table to |
boolean |
add(Watermark watermark)
Sets the Watermark . |
(package private) void |
addAdditionalAction(PdfName actionType,
PdfAction action)
|
(package private) void |
addAnnotation(PdfAnnotation annot)
|
(package private) void |
addCalculationOrder(PdfFormField formField)
|
(package private) void |
addFormFieldRaw(PdfFormField field)
|
private void |
addImage(PdfContentByte graphics,
Image image,
float a,
float b,
float c,
float d,
float e,
float f)
Adds an image to the Graphics object. |
(package private) void |
addJavaScript(PdfAction js)
|
(package private) void |
addOutline(PdfOutline outline,
String name)
Adds a named outline to the document . |
(package private) void |
addPTable(PdfPTable ptable)
Adds a PdfPTable to the document. |
void |
addWriter(PdfWriter writer)
Adds a PdfWriter to the PdfDocument . |
(package private) float |
bottom(Table table)
Returns the bottomvalue of a Table if it were added to this document. |
(package private) boolean |
breakTableIfDoesntFit(PdfTable table)
|
(package private) void |
calculateOutlineCount()
|
private void |
carriageReturn()
If the current line is not empty or null, it is added to the arraylist of lines and a new empty line is added. |
void |
clearTextWrap()
Method added by Pelikan Stephan |
void |
close()
Closes the document. |
private void |
ensureNewLine()
Ensures that a new line has been started. |
(package private) boolean |
fitsPage(PdfPTable table,
float margin)
Checks if a PdfPTable fits the current page of the PdfDocument . |
private float |
flushLines()
Writes all the lines to the text-object. |
PdfAcroForm |
getAcroForm()
Gets the AcroForm object. |
(package private) PdfDocument.PdfCatalog |
getCatalog(PdfIndirectReference pages)
Gets the PdfCatalog -object. |
(package private) ArrayList |
getDocumentJavaScript()
|
(package private) PdfDocument.PdfInfo |
getInfo()
Gets the PdfInfo -object. |
(package private) PdfAction |
getLocalGotoAction(String name)
|
(package private) PageResources |
getPageResources()
|
(package private) PdfTable |
getPdfTable(Table table,
boolean supportRowAdditions)
Gets a PdfTable object (contributed by dperezcar@fcc.es) |
PdfOutline |
getRootOutline()
Gets the root outline. |
float |
getVerticalPosition(boolean ensureNewLine)
Gets the current vertical page position. |
(package private) float |
indentBottom()
Gets the indentation on the bottom side. |
private float |
indentLeft()
Gets the indentation on the left side. |
private float |
indentRight()
Gets the indentation on the right side. |
private float |
indentTop()
Gets the indentation on the top side. |
private void |
initPage()
Initializes a page. |
(package private) boolean |
isStrictImageSequence()
Getter for property strictImageSequence. |
(package private) boolean |
localDestination(String name,
PdfDestination destination)
The local destination to where a local goto with the same name will jump to. |
(package private) void |
localGoto(String name,
float llx,
float lly,
float urx,
float ury)
Implements a link to other part of the document. |
private void |
newLine()
Adds the current line to the list of lines and also adds an empty line. |
boolean |
newPage()
Makes a new page and sends it to the PdfWriter . |
void |
open()
Opens the document. |
(package private) void |
outlineTree(PdfOutline outline)
|
(package private) void |
remoteGoto(String filename,
int page,
float llx,
float lly,
float urx,
float ury)
Implements a link to another document. |
(package private) void |
remoteGoto(String filename,
String name,
float llx,
float lly,
float urx,
float ury)
Implements a link to another document. |
void |
removeWatermark()
Removes the Watermark . |
void |
resetFooter()
Resets the footer of this document. |
void |
resetHeader()
Resets the header of this document. |
void |
resetPageCount()
Sets the page number to 0. |
protected PdfArray |
rotateAnnotations()
|
(package private) void |
setAction(PdfAction action,
float llx,
float lly,
float urx,
float ury)
Implements an action in an area. |
(package private) void |
setBoxSize(String boxName,
Rectangle size)
|
(package private) void |
setCropBoxSize(Rectangle crop)
|
(package private) void |
setDuration(int seconds)
Sets the display duration for the page (for presentations) |
void |
setFooter(HeaderFooter footer)
Changes the footer of this document. |
void |
setHeader(HeaderFooter header)
Changes the header of this document. |
boolean |
setMarginMirroring(boolean MarginMirroring)
Parameter that allows you to do margin mirroring (odd/even pages) |
boolean |
setMargins(float marginLeft,
float marginRight,
float marginTop,
float marginBottom)
Sets the margins. |
(package private) void |
setOpenAction(PdfAction action)
|
(package private) void |
setOpenAction(String name)
|
(package private) void |
setPageAction(PdfName actionType,
PdfAction action)
|
void |
setPageCount(int pageN)
Sets the page number. |
(package private) void |
setPageEmpty(boolean pageEmpty)
|
(package private) void |
setPageLabels(PdfPageLabels pageLabels)
|
boolean |
setPageSize(Rectangle pageSize)
Sets the pagesize. |
(package private) void |
setSigFlags(int f)
|
(package private) void |
setStrictImageSequence(boolean strictImageSequence)
Setter for property strictImageSequence. |
(package private) void |
setTransition(PdfTransition transition)
Sets the transition for the page |
void |
setViewerPreferences(int preferences)
Sets the viewer preferences as the sum of several constants. |
(package private) void |
traverseOutlineCount(PdfOutline outline)
|
(package private) void |
writeLineToContent(PdfLine line,
PdfContentByte text,
PdfContentByte graphics,
Object[] currentValues,
float ratio)
Writes a text line to the document. |
(package private) void |
writeOutlines()
|
Methods inherited from class com.lowagie.text.Document |
---|
addAuthor, addCreationDate, addCreator, addDocListener, addHeader, addKeywords, addProducer, addSubject, addTitle, bottom, bottom, bottomMargin, getHtmlStyleClass, getJavaScript_onLoad, getJavaScript_onUnLoad, getPageNumber, getPageSize, getVersion, isMarginMirroring, isOpen, left, left, leftMargin, removeDocListener, right, right, rightMargin, setHtmlStyleClass, setJavaScript_onLoad, setJavaScript_onUnLoad, top, top, topMargin |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
static final String hangingPunctuation
private PdfWriter writer
PdfWriter
.
private PdfDocument.PdfInfo info
private boolean firstPageEvent
private boolean isParagraph
private PdfLine line
private float indentLeft
private float indentRight
private float listIndentLeft
private int alignment
private PdfContentByte text
private PdfContentByte graphics
private ArrayList lines
private float leading
private float currentHeight
private float indentTop
private float indentBottom
private boolean pageEmpty
private int textEmptySize
protected Rectangle nextPageSize
protected HashMap thisBoxSize
protected HashMap boxSize
protected PageResources pageResources
private Image imageWait
private float imageEnd
private float imageIndentLeft
private float imageIndentRight
private ArrayList annotations
private ArrayList delayedAnnotations
PdfAcroForm acroForm
private PdfOutline rootOutline
private PdfOutline currentOutline
PdfOutline
in the hierarchy of outlines.
private PdfAction currentAction
PdfAction
when processing an Anchor
.
private TreeMap localDestinations
Object[]{PdfAction,PdfIndirectReference,PdfDestintion}
.
private ArrayList documentJavaScript
private int viewerPreferences
private String openActionName
private PdfAction openActionAction
private PdfDictionary additionalActions
private PdfPageLabels pageLabels
private boolean isNewpage
private float paraIndent
protected float nextMarginLeft
protected float nextMarginRight
protected float nextMarginTop
protected float nextMarginBottom
protected int duration
protected PdfTransition transition
protected PdfDictionary pageAA
private boolean strictImageSequence
private int lastElementType
Constructor Detail |
public PdfDocument() throws DocumentException
DocumentException
- on errorMethod Detail |
public void addWriter(PdfWriter writer) throws DocumentException
PdfWriter
to the PdfDocument
.
writer
- the PdfWriter
that writes everything
what is added to this document to an outputstream.
DocumentException
- on errorpublic boolean setPageSize(Rectangle pageSize)
setPageSize
in interface DocListener
setPageSize
in class Document
pageSize
- the new pagesize
true
if the page size was setpublic void setHeader(HeaderFooter header)
setHeader
in interface DocListener
setHeader
in class Document
header
- the new headerpublic void resetHeader()
resetHeader
in interface DocListener
resetHeader
in class Document
public void setFooter(HeaderFooter footer)
setFooter
in interface DocListener
setFooter
in class Document
footer
- the new footerpublic void resetFooter()
resetFooter
in interface DocListener
resetFooter
in class Document
public void resetPageCount()
resetPageCount
in interface DocListener
resetPageCount
in class Document
public void setPageCount(int pageN)
setPageCount
in interface DocListener
setPageCount
in class Document
pageN
- the new page numberpublic boolean add(Watermark watermark)
Watermark
.
add
in interface DocListener
add
in class Document
watermark
- the watermark to add
true
if the element was added, false
if not.public void removeWatermark()
Watermark
.
removeWatermark
in interface DocListener
removeWatermark
in class Document
public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
setMargins
in interface DocListener
setMargins
in class Document
marginLeft
- the margin on the leftmarginRight
- the margin on the rightmarginTop
- the margin on the topmarginBottom
- the margin on the bottom
boolean
protected PdfArray rotateAnnotations()
public boolean newPage() throws DocumentException
PdfWriter
.
newPage
in interface DocListener
newPage
in class Document
boolean
DocumentException
- on errorpublic void open()
You have to open the document before you can begin to add content to the body of the document.
open
in interface DocListener
open
in class Document
void outlineTree(PdfOutline outline) throws IOException
IOException
void writeOutlines() throws IOException
IOException
void traverseOutlineCount(PdfOutline outline)
void calculateOutlineCount()
public void close()
close
in interface DocListener
close
in class Document
PageResources getPageResources()
void addPTable(PdfPTable ptable) throws DocumentException
PdfPTable
to the document.
ptable
- the PdfPTable
to be added to the document.
DocumentException
- on errorPdfTable getPdfTable(Table table, boolean supportRowAdditions)
table
- a high level table objectsupportRowAdditions
-
PdfWriter.getPdfTable(Table)
boolean breakTableIfDoesntFit(PdfTable table) throws DocumentException
table
- Table to add
DocumentException
(contributed by dperezcar@fcc.es)
private void add(PdfTable table, boolean onlyFirstPage) throws DocumentException
table
- Table to add. Rendered rows will be deleted after processing.onlyFirstPage
- Render only the first full page
DocumentException
public boolean add(Element element) throws DocumentException
Element
was added to the Document
.
add
in interface ElementListener
add
in class Document
element
- the element to add
true
if the element was added, false
if not.
DocumentException
- when a document isn't open yet, or has been closedprivate void addImage(PdfContentByte graphics, Image image, float a, float b, float c, float d, float e, float f) throws DocumentException
graphics
- the PdfContentByte holding the graphics layer of this PdfDocumentimage
- the imagea
- an element of the transformation matrixb
- an element of the transformation matrixc
- an element of the transformation matrixd
- an element of the transformation matrixe
- an element of the transformation matrixf
- an element of the transformation matrix
DocumentException
private void add(Image image) throws PdfException, DocumentException
image
- the Image
to add
PdfException
- on error
DocumentException
- on errorprivate void initPage() throws DocumentException
If the footer/header is set, it is printed.
DocumentException
- on errorprivate void carriageReturn() throws DocumentException
DocumentException
- on errorprivate void newLine() throws DocumentException
DocumentException
- on errorprivate float flushLines() throws DocumentException
DocumentException
- on errorPdfDocument.PdfInfo getInfo()
PdfInfo
-object.
PdfInfo
PdfDocument.PdfCatalog getCatalog(PdfIndirectReference pages)
PdfCatalog
-object.
pages
- an indirect reference to this document pages
PdfCatalog
float bottom(Table table)
Table
if it were added to this document.
table
- the table that may or may not be added to this document
boolean fitsPage(PdfPTable table, float margin)
PdfPTable
fits the current page of the PdfDocument
.
table
- the table that has to be checkedmargin
- a certain margin
true
if the PdfPTable
fits the page, false
otherwise.public float getVerticalPosition(boolean ensureNewLine)
ensureNewLine
- Tells whether a new line shall be enforced. This may cause side effects
for elements that do not terminate the lines they've started because those lines will get
terminated.
private void ensureNewLine()
private float indentLeft()
private float indentRight()
private float indentTop()
float indentBottom()
void addOutline(PdfOutline outline, String name)
outline
- the outline to be addedname
- the name of this local destinationpublic PdfAcroForm getAcroForm()
public PdfOutline getRootOutline()
void writeLineToContent(PdfLine line, PdfContentByte text, PdfContentByte graphics, Object[] currentValues, float ratio) throws DocumentException
Before entering the line position must have been established and the
text
argument must be in text object scope (beginText()
).
line
- the line to be writtentext
- the PdfContentByte
where the text will be written tographics
- the PdfContentByte
where the graphics will be written tocurrentValues
- the current font and extra spacing valuesratio
-
DocumentException
- on errorvoid localGoto(String name, float llx, float lly, float urx, float ury)
name
- the name for this linkllx
- the lower left x corner of the activation areally
- the lower left y corner of the activation areaurx
- the upper right x corner of the activation areaury
- the upper right y corner of the activation areaPdfAction getLocalGotoAction(String name)
boolean localDestination(String name, PdfDestination destination)
name
- the name of this local destinationdestination
- the PdfDestination
with the jump coordinates
true
if the local destination was added,
false
if a local destination with the same name
already existedvoid remoteGoto(String filename, String name, float llx, float lly, float urx, float ury)
filename
- the filename for the remote documentname
- the name to jump tollx
- the lower left x corner of the activation areally
- the lower left y corner of the activation areaurx
- the upper right x corner of the activation areaury
- the upper right y corner of the activation areavoid remoteGoto(String filename, int page, float llx, float lly, float urx, float ury)
filename
- the filename for the remote documentpage
- the page to jump tollx
- the lower left x corner of the activation areally
- the lower left y corner of the activation areaurx
- the upper right x corner of the activation areaury
- the upper right y corner of the activation areapublic void setViewerPreferences(int preferences)
preferences
- the viewer preferencesPdfWriter.setViewerPreferences(int)
void setAction(PdfAction action, float llx, float lly, float urx, float ury)
action
- the PdfAction
llx
- the lower left x corner of the activation areally
- the lower left y corner of the activation areaurx
- the upper right x corner of the activation areaury
- the upper right y corner of the activation areavoid setOpenAction(String name)
void setOpenAction(PdfAction action)
void addAdditionalAction(PdfName actionType, PdfAction action)
void setPageLabels(PdfPageLabels pageLabels)
void addJavaScript(PdfAction js)
void setCropBoxSize(Rectangle crop)
void setBoxSize(String boxName, Rectangle size)
void addCalculationOrder(PdfFormField formField)
void setSigFlags(int f)
void addFormFieldRaw(PdfFormField field)
void addAnnotation(PdfAnnotation annot)
void setDuration(int seconds)
seconds
- the number of seconds to display the pagevoid setTransition(PdfTransition transition)
transition
- the PdfTransition objectvoid setPageAction(PdfName actionType, PdfAction action)
boolean isStrictImageSequence()
void setStrictImageSequence(boolean strictImageSequence)
strictImageSequence
- New value of property strictImageSequence.void setPageEmpty(boolean pageEmpty)
public void clearTextWrap() throws DocumentException
clearTextWrap
in interface DocListener
clearTextWrap
in class Document
DocumentException
DocListener.clearTextWrap()
ArrayList getDocumentJavaScript()
public boolean setMarginMirroring(boolean MarginMirroring)
DocListener
setMarginMirroring
in interface DocListener
setMarginMirroring
in class Document
MarginMirroring
- true
to mirror the margins
true
DocListener.setMarginMirroring(boolean)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |