|
![]() |
||||||||
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
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. |
private static class |
PdfDocument.RenderingContext
This is a helper class for adding a Table to a document. |
Field Summary | |
---|---|
private PdfDictionary |
additionalActions
|
private int |
alignment
This represents the current alignment of the PDF Elements. |
private PdfAction |
anchorAction
The current active PdfAction when processing an Anchor . |
(package private) PdfAnnotationsImp |
annotationsImp
|
protected java.util.HashMap |
boxSize
This is the size of the several boxes that will be used in the next page. |
private PdfCollection |
collection
|
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 java.util.HashMap |
documentFileAttachment
|
private java.util.HashMap |
documentLevelJS
|
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 java.lang.String |
hangingPunctuation
The characters to be applied the hanging punctuation. |
private float |
imageEnd
This is the position where the image ends. |
private Image |
imageWait
This is the image that could not be shown on a previous page. |
(package private) PdfDocument.Indentation |
indentation
|
private PdfDocument.PdfInfo |
info
some meta information about the Document. |
private boolean |
isParagraph
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. |
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 java.util.ArrayList |
lines
The lines that are written until now. |
private java.util.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. |
private PdfAction |
openActionAction
|
private java.lang.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. |
private PdfOutline |
rootOutline
This is the root outline of the document. |
private java.text.DecimalFormat |
SIXTEEN_DIGITS
|
private boolean |
strictImageSequence
Holds value of property strictImageSequence. |
private PdfContentByte |
text
This is the PdfContentByte object, containing the text. |
private int |
textEmptySize
|
protected java.util.HashMap |
thisBoxSize
This is the size of the several boxes of the current Page. |
private PdfIndirectReference |
thumb
|
protected PdfTransition |
transition
The page transition |
protected PdfViewerPreferencesImp |
viewerPreferences
Contains the Viewer preferences of this PDF document. |
private 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, 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 . |
private void |
add(Image image)
Adds an image to the document. |
private void |
add(PdfTable table,
boolean onlyFirstPage)
Adds a new table 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(java.lang.String description,
PdfFileSpecification fs)
|
(package private) void |
addJavaScript(PdfAction js)
|
(package private) void |
addJavaScript(java.lang.String name,
PdfAction js)
|
(package private) void |
addOutline(PdfOutline outline,
java.lang.String name)
Adds a named outline to the document . |
(package private) void |
addPTable(PdfPTable ptable)
Adds a PdfPTable to the document. |
private 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 . |
private void |
analyzeRow(java.util.ArrayList rows,
PdfDocument.RenderingContext ctx)
|
(package private) float |
bottom(Table table)
Deprecated. |
(package private) boolean |
breakTableIfDoesntFit(PdfTable table)
Deprecated. |
(package private) void |
calculateOutlineCount()
Updates the count in the outlines. |
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 |
consumeRowspan(java.util.ArrayList row,
PdfDocument.RenderingContext ctx)
|
private void |
doFooter()
|
private void |
doHeader()
|
private void |
ensureNewLine()
Ensures that a new line has been started. |
private java.util.ArrayList |
extractRows(java.util.ArrayList cells,
PdfDocument.RenderingContext ctx)
|
(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. |
(package private) PdfAcroForm |
getAcroForm()
Gets the AcroForm object. |
(package private) Rectangle |
getBoxSize(java.lang.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) java.util.HashMap |
getDocumentFileAttachment()
|
(package private) java.util.HashMap |
getDocumentLevelJS()
|
(package private) PdfDocument.PdfInfo |
getInfo()
Gets the PdfInfo -object. |
(package private) PdfAction |
getLocalGotoAction(java.lang.String name)
|
(package private) int |
getMarkPoint()
|
(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) void |
incMarkPoint()
|
(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(java.lang.String name,
PdfDestination destination)
The local destination to where a local goto with the same name will jump to. |
(package private) void |
localGoto(java.lang.String name,
float llx,
float lly,
float urx,
float ury)
Implements a link to other part of the document. |
private boolean |
mayBeRemoved(java.util.ArrayList row)
|
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)
Recursive method used to write outlines. |
(package private) void |
remoteGoto(java.lang.String filename,
int page,
float llx,
float lly,
float urx,
float ury)
Implements a link to another document. |
(package private) void |
remoteGoto(java.lang.String filename,
java.lang.String name,
float llx,
float lly,
float urx,
float ury)
Implements a link to another document. |
private void |
renderCells(PdfDocument.RenderingContext ctx,
java.util.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(java.lang.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. |
boolean |
setMarginMirroring(boolean MarginMirroring)
Set the margin mirroring. |
boolean |
setMargins(float marginLeft,
float marginRight,
float marginTop,
float marginBottom)
Sets the margins. |
private void |
setNewPageSizeAndMargins()
|
(package private) void |
setOpenAction(PdfAction action)
|
(package private) void |
setOpenAction(java.lang.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,
java.lang.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, 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 |
---|
private PdfWriter writer
PdfWriter
.
private PdfContentByte text
private PdfContentByte graphics
private float leading
private int alignment
private float currentHeight
private boolean isParagraph
private PdfAction anchorAction
PdfAction
when processing an Anchor
.
private int textEmptySize
protected byte[] xmpMetadata
protected float nextMarginLeft
protected float nextMarginRight
protected float nextMarginTop
protected float nextMarginBottom
private boolean firstPageEvent
private PdfLine line
private java.util.ArrayList lines
private int lastElementType
static final java.lang.String hangingPunctuation
PdfDocument.Indentation indentation
private PdfDocument.PdfInfo info
private PdfOutline rootOutline
private PdfOutline currentOutline
PdfOutline
in the hierarchy of outlines.
protected PdfViewerPreferencesImp viewerPreferences
protected PdfPageLabels pageLabels
private java.util.TreeMap localDestinations
Object[]{PdfAction,PdfIndirectReference,PdfDestintion}
.
int jsCounter
private java.util.HashMap documentLevelJS
private java.text.DecimalFormat SIXTEEN_DIGITS
private java.util.HashMap documentFileAttachment
private java.lang.String openActionName
private PdfAction openActionAction
private PdfDictionary additionalActions
private PdfCollection collection
PdfAnnotationsImp annotationsImp
protected int markPoint
protected Rectangle nextPageSize
protected java.util.HashMap thisBoxSize
protected java.util.HashMap boxSize
private boolean pageEmpty
protected int duration
protected PdfTransition transition
protected PdfDictionary pageAA
private PdfIndirectReference thumb
protected PageResources pageResources
private boolean strictImageSequence
private float imageEnd
private Image imageWait
Constructor Detail |
---|
public PdfDocument()
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 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
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 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 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
private void initPage() throws DocumentException
If the footer/header is set, it is printed.
DocumentException
- on errorprivate void newLine() throws DocumentException
DocumentException
- on errorprivate void carriageReturn()
DocumentException
- on errorpublic 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 flushLines() throws DocumentException
DocumentException
- on errorvoid writeLineToContent(PdfLine line, PdfContentByte text, PdfContentByte graphics, java.lang.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 errorprivate float indentLeft()
private float indentRight()
private float indentTop()
float indentBottom()
private 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, java.lang.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 java.io.IOException
java.io.IOException
void outlineTree(PdfOutline outline) throws java.io.IOException
java.io.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(java.lang.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(java.lang.String filename, java.lang.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(java.lang.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(java.lang.String name)
boolean localDestination(java.lang.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(java.lang.String name, PdfAction js)
java.util.HashMap getDocumentLevelJS()
void addFileAttachment(java.lang.String description, PdfFileSpecification fs) throws java.io.IOException
java.io.IOException
java.util.HashMap getDocumentFileAttachment()
void setOpenAction(java.lang.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(java.lang.String boxName, Rectangle size)
private void setNewPageSizeAndMargins()
Rectangle getBoxSize(java.lang.String boxName)
boxName
- crop, trim, art or bleedvoid setPageEmpty(boolean pageEmpty)
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()
private 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.PdfTable getPdfTable(Table table, boolean supportRowAdditions)
table
- a high level table objectsupportRowAdditions
-
PdfWriter.getPdfTable(Table)
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
private void analyzeRow(java.util.ArrayList rows, PdfDocument.RenderingContext ctx)
private boolean mayBeRemoved(java.util.ArrayList row)
private void consumeRowspan(java.util.ArrayList row, PdfDocument.RenderingContext ctx)
private java.util.ArrayList extractRows(java.util.ArrayList cells, PdfDocument.RenderingContext ctx)
private void renderCells(PdfDocument.RenderingContext ctx, java.util.List cells, boolean hasToFit) throws DocumentException
DocumentException
boolean breakTableIfDoesntFit(PdfTable table) throws DocumentException
table
- Table to add
DocumentException
(contributed by dperezcar@fcc.es)
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
private void doFooter() throws DocumentException
DocumentException
private void doHeader() throws DocumentException
DocumentException
|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |