|
![]() |
||||||||
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
public class 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 | |
---|---|
static class |
PdfDocument.Indentation
|
(package private) static class |
PdfDocument.PdfCatalog
PdfCatalog is the PDF Catalog-object. |
static class |
PdfDocument.PdfInfo
PdfInfo is the PDF InfoDictionary. |
protected static class |
PdfDocument.RenderingContext
This is a helper class for adding a Table to a document. |
Field Summary | |
---|---|
protected PdfDictionary |
additionalActions
|
protected int |
alignment
This represents the current alignment of the PDF Elements. |
protected PdfAction |
anchorAction
The current active PdfAction when processing an Anchor . |
(package private) PdfAnnotationsImp |
annotationsImp
|
protected HashMap |
boxSize
This is the size of the several boxes that will be used in the next page. |
protected PdfCollection |
collection
|
protected float |
currentHeight
This is the current height of the document. |
protected PdfOutline |
currentOutline
This is the current PdfOutline in the hierarchy of outlines. |
protected HashMap |
documentFileAttachment
|
protected HashMap |
documentLevelJS
|
protected int |
duration
The duration of the page |
protected boolean |
firstPageEvent
Signals that OnOpenDocument should be called. |
protected 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 punctuation. |
protected float |
imageEnd
This is the position where the image ends. |
protected Image |
imageWait
This is the image that could not be shown on a previous page. |
protected PdfDocument.Indentation |
indentation
|
protected PdfDocument.PdfInfo |
info
some meta information about the Document. |
protected boolean |
isSectionTitle
Signals that onParagraph is valid (to avoid that a Chapter/Section title is treated as a Paragraph). |
(package private) int |
jsCounter
Stores a list of document level JavaScript actions. |
protected int |
lastElementType
Holds the type of the last element, that has been added to the document. |
protected float |
leading
This represents the leading of the lines. |
protected int |
leadingCount
Signals that the current leading has to be subtracted from a YMark object when positive. |
protected PdfLine |
line
The line that is currently being written. |
protected ArrayList |
lines
The lines that are written until now. |
protected TreeMap |
localDestinations
Stores the destinations keyed by name. |
protected int |
markPoint
|
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. |
protected PdfAction |
openActionAction
|
protected String |
openActionName
|
protected PdfDictionary |
pageAA
|
private boolean |
pageEmpty
This checks if the page is empty. |
protected PdfPageLabels |
pageLabels
|
protected PageResources |
pageResources
This are the page resources of the current Page. |
protected PdfOutline |
rootOutline
This is the root outline of the document. |
protected static DecimalFormat |
SIXTEEN_DIGITS
|
protected boolean |
strictImageSequence
Holds value of property strictImageSequence. |
protected PdfContentByte |
text
This is the PdfContentByte object, containing the text. |
protected int |
textEmptySize
|
protected HashMap |
thisBoxSize
This is the size of the several boxes of the current Page. |
protected PdfIndirectReference |
thumb
|
protected PdfTransition |
transition
The page transition |
protected PdfViewerPreferencesImp |
viewerPreferences
Contains the Viewer preferences of this PDF document. |
protected PdfWriter |
writer
The PdfWriter . |
protected byte[] |
xmpMetadata
XMP Metadata for the page. |
Fields inherited from class com.lowagie.text.Document |
---|
chapternumber, close, compress, footer, header, htmlStyleClass, javaScript_onLoad, javaScript_onUnLoad, marginBottom, marginLeft, marginMirroring, marginMirroringTopBottom, marginRight, marginTop, open, pageN, pageSize, plainRandomAccess, wmfFontCorrection |
Constructor Summary | |
---|---|
PdfDocument()
Constructs a new PDF document. |
Method Summary | |
---|---|
boolean |
add(Element element)
Signals that an Element was added to the Document . |
protected void |
add(Image image)
Adds an image to the document. |
(package private) void |
addAdditionalAction(PdfName actionType,
PdfAction action)
|
(package private) void |
addAnnotation(PdfAnnotation annot)
|
(package private) void |
addCalculationOrder(PdfFormField formField)
|
(package private) void |
addFileAttachment(String description,
PdfFileSpecification fs)
|
(package private) void |
addJavaScript(PdfAction js)
|
(package private) void |
addJavaScript(String name,
PdfAction js)
|
(package private) void |
addOutline(PdfOutline outline,
String name)
Adds a named outline to the document . |
private void |
addPdfTable(Table t)
Adds a new table to the document. |
(package private) void |
addPTable(PdfPTable ptable)
Adds a PdfPTable to the document. |
protected void |
addSpacing(float extraspace,
float oldleading,
Font f)
Adds extra space. |
(package private) void |
addViewerPreference(PdfName key,
PdfObject value)
|
void |
addWriter(PdfWriter writer)
Adds a PdfWriter to the PdfDocument . |
protected void |
analyzeRow(ArrayList rows,
PdfDocument.RenderingContext ctx)
|
(package private) float |
bottom(Table table)
Returns the bottomvalue of a Table if it were added to this document. |
(package private) void |
calculateOutlineCount()
Updates the count in the outlines. |
protected 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. |
protected void |
consumeRowspan(ArrayList row,
PdfDocument.RenderingContext ctx)
|
protected void |
doFooter()
|
protected void |
doHeader()
|
protected void |
ensureNewLine()
Ensures that a new line has been started. |
protected ArrayList |
extractRows(ArrayList cells,
PdfDocument.RenderingContext ctx)
|
(package private) boolean |
fitsPage(PdfPTable table,
float margin)
Checks if a PdfPTable fits the current page of the PdfDocument . |
protected float |
flushLines()
Writes all the lines to the text-object. |
(package private) PdfAcroForm |
getAcroForm()
Gets the AcroForm object. |
(package private) Rectangle |
getBoxSize(String boxName)
Gives the size of a trim, art, crop or bleed box, or null if not defined. |
(package private) PdfDocument.PdfCatalog |
getCatalog(PdfIndirectReference pages)
Gets the PdfCatalog -object. |
(package private) HashMap |
getDocumentFileAttachment()
|
(package private) HashMap |
getDocumentLevelJS()
|
(package private) PdfDocument.PdfInfo |
getInfo()
Gets the PdfInfo -object. |
float |
getLeading()
Getter for the current leading. |
(package private) PdfAction |
getLocalGotoAction(String name)
|
(package private) int |
getMarkPoint()
|
(package private) PageResources |
getPageResources()
|
PdfOutline |
getRootOutline()
Gets the root outline. |
float |
getVerticalPosition(boolean ensureNewLine)
Gets the current vertical page position. |
(package private) void |
incMarkPoint()
|
(package private) float |
indentBottom()
Gets the indentation on the bottom side. |
protected float |
indentLeft()
Gets the indentation on the left side. |
protected float |
indentRight()
Gets the indentation on the right side. |
protected float |
indentTop()
Gets the indentation on the top side. |
protected void |
initPage()
Initializes a page. |
(package private) boolean |
isPageEmpty()
|
(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. |
protected boolean |
mayBeRemoved(ArrayList row)
|
protected 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)
Recursive method used to write outlines. |
(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. |
protected void |
renderCells(PdfDocument.RenderingContext ctx,
List cells,
boolean hasToFit)
|
void |
resetFooter()
Resets the footer of this document. |
void |
resetHeader()
Resets the header of this document. |
void |
resetPageCount()
Sets the page number to 0. |
(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)
|
void |
setCollection(PdfCollection collection)
Sets the collection dictionary. |
(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. |
(package private) void |
setLeading(float leading)
Setter for the current leading. |
boolean |
setMarginMirroring(boolean MarginMirroring)
Set the margin mirroring. |
boolean |
setMarginMirroringTopBottom(boolean MarginMirroringTopBottom)
Set the margin mirroring. |
boolean |
setMargins(float marginLeft,
float marginRight,
float marginTop,
float marginBottom)
Sets the margins. |
protected void |
setNewPageSizeAndMargins()
|
(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)
Sets the page labels |
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 |
setThumbnail(Image image)
|
(package private) void |
setTransition(PdfTransition transition)
Sets the transition for the page |
(package private) void |
setViewerPreferences(int preferences)
|
void |
setXmpMetadata(byte[] xmpMetadata)
Use this method to set the XMP Metadata. |
(package private) void |
traverseOutlineCount(PdfOutline outline)
Recursive method to update the count in the outlines. |
(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()
Writes the outline tree to the body of the PDF document. |
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, getProduct, getRelease, 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 |
---|
protected PdfWriter writer
PdfWriter
.
protected PdfContentByte text
protected PdfContentByte graphics
protected float leading
protected int alignment
protected float currentHeight
protected boolean isSectionTitle
protected int leadingCount
protected PdfAction anchorAction
PdfAction
when processing an Anchor
.
protected int textEmptySize
protected byte[] xmpMetadata
protected float nextMarginLeft
protected float nextMarginRight
protected float nextMarginTop
protected float nextMarginBottom
protected boolean firstPageEvent
protected PdfLine line
protected ArrayList lines
protected int lastElementType
static final String hangingPunctuation
protected PdfDocument.Indentation indentation
protected PdfDocument.PdfInfo info
protected PdfOutline rootOutline
protected PdfOutline currentOutline
PdfOutline
in the hierarchy of outlines.
protected PdfViewerPreferencesImp viewerPreferences
protected PdfPageLabels pageLabels
protected TreeMap localDestinations
Object[]{PdfAction,PdfIndirectReference,PdfDestintion}
.
int jsCounter
protected HashMap documentLevelJS
protected static final DecimalFormat SIXTEEN_DIGITS
protected HashMap documentFileAttachment
protected String openActionName
protected PdfAction openActionAction
protected PdfDictionary additionalActions
protected PdfCollection collection
PdfAnnotationsImp annotationsImp
protected int markPoint
protected Rectangle nextPageSize
protected HashMap thisBoxSize
protected HashMap boxSize
private boolean pageEmpty
protected int duration
protected PdfTransition transition
protected PdfDictionary pageAA
protected PdfIndirectReference thumb
protected PageResources pageResources
protected boolean strictImageSequence
protected float imageEnd
protected Image imageWait
Constructor Detail |
---|
public PdfDocument()
Method 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 float getLeading()
void setLeading(float leading)
leading
- the current leadingpublic 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 closedpublic 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
public void close()
close
in interface DocListener
close
in class Document
public void setXmpMetadata(byte[] xmpMetadata)
xmpMetadata
- The xmpMetadata to set.public boolean newPage()
PdfWriter
.
newPage
in interface DocListener
newPage
in class Document
boolean
public boolean setPageSize(Rectangle pageSize)
setPageSize
in interface DocListener
setPageSize
in class Document
pageSize
- the new pagesize
true
if the page size was setpublic 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
public boolean setMarginMirroring(boolean MarginMirroring)
Document
Note: it will not work with Table
.
setMarginMirroring
in interface DocListener
setMarginMirroring
in class Document
MarginMirroring
- true
to mirror the margins
true
DocListener.setMarginMirroring(boolean)
public boolean setMarginMirroringTopBottom(boolean MarginMirroringTopBottom)
Document
Note: it will not work with Table
.
setMarginMirroringTopBottom
in interface DocListener
setMarginMirroringTopBottom
in class Document
MarginMirroringTopBottom
- true
to mirror the margins
true
DocListener.setMarginMirroring(boolean)
public void setPageCount(int pageN)
setPageCount
in interface DocListener
setPageCount
in class Document
pageN
- the new page numberpublic void resetPageCount()
resetPageCount
in interface DocListener
resetPageCount
in class Document
public 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
protected void initPage() throws DocumentException
If the footer/header is set, it is printed.
DocumentException
- on errorprotected void newLine() throws DocumentException
DocumentException
- on errorprotected void carriageReturn()
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.
protected void ensureNewLine()
protected float flushLines() throws DocumentException
DocumentException
- on errorvoid 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 errorprotected float indentLeft()
protected float indentRight()
protected float indentTop()
float indentBottom()
protected void addSpacing(float extraspace, float oldleading, Font f)
PdfDocument.PdfInfo getInfo()
PdfInfo
-object.
PdfInfo
PdfDocument.PdfCatalog getCatalog(PdfIndirectReference pages)
PdfCatalog
-object.
pages
- an indirect reference to this document pages
PdfCatalog
void addOutline(PdfOutline outline, String name)
outline
- the outline to be addedname
- the name of this local destinationpublic PdfOutline getRootOutline()
void calculateOutlineCount()
void traverseOutlineCount(PdfOutline outline)
void writeOutlines() throws IOException
IOException
void outlineTree(PdfOutline outline) throws IOException
IOException
void setViewerPreferences(int preferences)
PdfViewerPreferences.setViewerPreferences(int)
void addViewerPreference(PdfName key, PdfObject value)
PdfViewerPreferences.addViewerPreference(com.lowagie.text.pdf.PdfName, com.lowagie.text.pdf.PdfObject)
void setPageLabels(PdfPageLabels pageLabels)
pageLabels
- the page labelsvoid 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 areavoid 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 areavoid 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 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 addJavaScript(PdfAction js)
void addJavaScript(String name, PdfAction js)
HashMap getDocumentLevelJS()
void addFileAttachment(String description, PdfFileSpecification fs) throws IOException
IOException
HashMap getDocumentFileAttachment()
void setOpenAction(String name)
void setOpenAction(PdfAction action)
void addAdditionalAction(PdfName actionType, PdfAction action)
public void setCollection(PdfCollection collection)
collection
- a dictionary of type PdfCollectionPdfAcroForm getAcroForm()
void setSigFlags(int f)
void addCalculationOrder(PdfFormField formField)
void addAnnotation(PdfAnnotation annot)
int getMarkPoint()
void incMarkPoint()
void setCropBoxSize(Rectangle crop)
void setBoxSize(String boxName, Rectangle size)
protected void setNewPageSizeAndMargins()
Rectangle getBoxSize(String boxName)
boxName
- crop, trim, art or bleedvoid setPageEmpty(boolean pageEmpty)
boolean isPageEmpty()
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)
void setThumbnail(Image image) throws PdfException, DocumentException
PdfException
DocumentException
PageResources getPageResources()
boolean isStrictImageSequence()
void setStrictImageSequence(boolean strictImageSequence)
strictImageSequence
- New value of property strictImageSequence.public void clearTextWrap()
protected void add(Image image) throws PdfException, DocumentException
image
- the Image
to add
PdfException
- on error
DocumentException
- on errorvoid addPTable(PdfPTable ptable) throws DocumentException
PdfPTable
to the document.
ptable
- the PdfPTable
to be added to the document.
DocumentException
- on errorboolean 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.private void addPdfTable(Table t) throws DocumentException
t
- Table to add. Rendered rows will be deleted after processing.
DocumentException
protected void analyzeRow(ArrayList rows, PdfDocument.RenderingContext ctx)
protected boolean mayBeRemoved(ArrayList row)
protected void consumeRowspan(ArrayList row, PdfDocument.RenderingContext ctx)
protected ArrayList extractRows(ArrayList cells, PdfDocument.RenderingContext ctx)
protected void renderCells(PdfDocument.RenderingContext ctx, List cells, boolean hasToFit) throws DocumentException
DocumentException
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
protected void doFooter() throws DocumentException
DocumentException
protected void doHeader() throws DocumentException
DocumentException
|
Hosted by Hostbasket | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |