Package com.lowagie.text.pdf
Class PdfDocument
- java.lang.Object
-
- com.lowagie.text.Document
-
- com.lowagie.text.pdf.PdfDocument
-
- All Implemented Interfaces:
DocListener
,ElementListener
,java.lang.AutoCloseable
,java.util.EventListener
public class PdfDocument extends Document
PdfDocument
is the class that is used byPdfWriter
to translate aDocument
into a PDF with different pages.A
PdfDocument
always listens to aDocument
and adds the Pdf representation of everyElement
that is added to theDocument
.- Since:
- 2.0.8 (class was package-private before)
- See Also:
Document
,DocListener
,PdfWriter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description 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
Fields Modifier and Type Field Description protected PdfDictionary
additionalActions
protected int
alignment
This represents the current alignment of the PDF Elements.protected PdfAction
anchorAction
The current activePdfAction
when processing anAnchor
.(package private) PdfAnnotationsImp
annotationsImp
protected java.util.HashMap<java.lang.String,PdfRectangle>
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 currentPdfOutline
in the hierarchy of outlines.protected java.util.HashMap<java.lang.String,PdfIndirectReference>
documentFileAttachment
protected java.util.HashMap<java.lang.String,PdfIndirectReference>
documentLevelJS
protected int
duration
The duration of the pageprotected 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 java.lang.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.private boolean
isDoFooter
This is the flag meaning whether document is creating footer.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 java.util.List<PdfLine>
lines
The lines that are written until now.protected java.util.TreeMap<java.lang.String,java.lang.Object[]>
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 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.protected PdfOutline
rootOutline
This is the root outline of the document.protected static java.text.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 java.util.HashMap<java.lang.String,PdfRectangle>
thisBoxSize
This is the size of the several boxes of the current Page.protected PdfIndirectReference
thumb
protected PdfTransition
transition
The page transitionprotected PdfViewerPreferencesImp
viewerPreferences
Contains the Viewer preferences of this PDF document.protected PdfWriter
writer
ThePdfWriter
.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
Constructors Constructor Description PdfDocument()
Constructs a new PDF document.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(Element element)
Signals that anElement
was added to theDocument
.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)
protected void
addDelay(Image image)
Occupies space forImage
that will be added later instead of now(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 .private void
addPdfTable(Table t)
Adds a new table to the document.(package private) void
addPTable(PdfPTable ptable)
Adds aPdfPTable
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 aPdfWriter
to thePdfDocument
.protected void
analyzeRow(java.util.List<java.util.List<PdfCell>> rows, PdfDocument.RenderingContext ctx)
(package private) float
bottom(Table table)
Returns the bottomvalue of aTable
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 Stephanvoid
close()
Closes the document.protected void
consumeRowspan(java.util.List<PdfCell> row, PdfDocument.RenderingContext ctx)
(package private) static PdfPTable
createInOneCell(Paragraph paragraph)
Integrate a paragraph into a table, so it can be a whole.protected void
delayTableAddition(PdfPTable table)
Occupies space forPdfPTable
that will be added later instead of nowprotected void
doFooter()
protected void
doHeader()
protected void
ensureNewLine()
Ensures that a new line has been started.protected java.util.List<java.util.List<PdfCell>>
extractRows(java.util.List<PdfCell> cells, PdfDocument.RenderingContext ctx)
(package private) boolean
fitsPage(PdfPTable table, float margin)
Checks if aPdfPTable
fits the current page of thePdfDocument
.protected float
flushLines()
Writes all the lines to the text-object.protected void
flushSpecial()
write non-textElement
into document(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 thePdfCatalog
-object.(package private) java.util.HashMap<java.lang.String,PdfIndirectReference>
getDocumentFileAttachment()
(package private) java.util.HashMap<java.lang.String,PdfIndirectReference>
getDocumentLevelJS()
protected PdfDocument.PdfInfo
getInfo()
Gets thePdfInfo
-object.float
getLeading()
Getter for the current leading.(package private) PdfAction
getLocalGotoAction(java.lang.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(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.protected boolean
mayBeRemoved(java.util.List<PdfCell> 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 thePdfWriter
.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.protected 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.(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(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 labelsboolean
setPageSize(Rectangle pageSize)
Sets the pagesize.(package private) void
setSigFlags(int f)
(package private) void
setStrictImageSequence(boolean strictImageSequence)
Setter for property strictImageSequence.private void
setTableWidth(PdfPTable table)
(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, addCreationDate, addCreator, addDocListener, addHeader, addKeywords, addModificationDate, addModificationDate, addProducer, addProducer, addSubject, addTitle, bottom, bottom, bottomMargin, getDocumentLanguage, getHtmlStyleClass, getJavaScript_onLoad, getJavaScript_onUnLoad, getPageNumber, getPageSize, getProduct, getRelease, getTextRenderingOptions, getVersion, isGlyphSubstitutionEnabled, isMarginMirroring, isOpen, left, left, leftMargin, removeDocListener, right, right, rightMargin, setDocumentLanguage, setGlyphSubstitutionEnabled, setHtmlStyleClass, setJavaScript_onLoad, setJavaScript_onUnLoad, setTextRenderingOptions, top, top, topMargin
-
-
-
-
Field Detail
-
SIXTEEN_DIGITS
protected static final java.text.DecimalFormat SIXTEEN_DIGITS
-
hangingPunctuation
static final java.lang.String hangingPunctuation
The characters to be applied the hanging punctuation.- See Also:
- Constant Field Values
-
writer
protected PdfWriter writer
ThePdfWriter
.
-
text
protected PdfContentByte text
This is the PdfContentByte object, containing the text.
-
graphics
protected PdfContentByte graphics
This is the PdfContentByte object, containing the borders and other Graphics.
-
leading
protected float leading
This represents the leading of the lines.
-
alignment
protected int alignment
This represents the current alignment of the PDF Elements.
-
currentHeight
protected float currentHeight
This is the current height of the document.
-
isSectionTitle
protected boolean isSectionTitle
Signals that onParagraph is valid (to avoid that a Chapter/Section title is treated as a Paragraph).- Since:
- 2.1.2
-
leadingCount
protected int leadingCount
Signals that the current leading has to be subtracted from a YMark object when positive.- Since:
- 2.1.2
-
anchorAction
protected PdfAction anchorAction
The current activePdfAction
when processing anAnchor
.
-
textEmptySize
protected int textEmptySize
-
xmpMetadata
protected byte[] xmpMetadata
XMP Metadata for the page.
-
nextMarginLeft
protected float nextMarginLeft
margin in x direction starting from the left. Will be valid in the next page
-
nextMarginRight
protected float nextMarginRight
margin in x direction starting from the right. Will be valid in the next page
-
nextMarginTop
protected float nextMarginTop
margin in y direction starting from the top. Will be valid in the next page
-
nextMarginBottom
protected float nextMarginBottom
margin in y direction starting from the bottom. Will be valid in the next page
-
firstPageEvent
protected boolean firstPageEvent
Signals that OnOpenDocument should be called.
-
line
protected PdfLine line
The line that is currently being written.
-
lines
protected java.util.List<PdfLine> lines
The lines that are written until now.
-
lastElementType
protected int lastElementType
Holds the type of the last element, that has been added to the document.
-
indentation
protected PdfDocument.Indentation indentation
-
info
protected PdfDocument.PdfInfo info
some meta information about the Document.
-
rootOutline
protected PdfOutline rootOutline
This is the root outline of the document.
-
currentOutline
protected PdfOutline currentOutline
This is the currentPdfOutline
in the hierarchy of outlines.
-
viewerPreferences
protected PdfViewerPreferencesImp viewerPreferences
Contains the Viewer preferences of this PDF document.
-
pageLabels
protected PdfPageLabels pageLabels
-
localDestinations
protected java.util.TreeMap<java.lang.String,java.lang.Object[]> localDestinations
Stores the destinations keyed by name. Value isObject[]{PdfAction,PdfIndirectReference,PdfDestintion}
.
-
documentLevelJS
protected java.util.HashMap<java.lang.String,PdfIndirectReference> documentLevelJS
-
documentFileAttachment
protected java.util.HashMap<java.lang.String,PdfIndirectReference> documentFileAttachment
-
openActionName
protected java.lang.String openActionName
-
openActionAction
protected PdfAction openActionAction
-
additionalActions
protected PdfDictionary additionalActions
-
collection
protected PdfCollection collection
-
markPoint
protected int markPoint
-
nextPageSize
protected Rectangle nextPageSize
This is the size of the next page.
-
thisBoxSize
protected java.util.HashMap<java.lang.String,PdfRectangle> thisBoxSize
This is the size of the several boxes of the current Page.
-
boxSize
protected java.util.HashMap<java.lang.String,PdfRectangle> boxSize
This is the size of the several boxes that will be used in the next page.
-
duration
protected int duration
The duration of the page
-
transition
protected PdfTransition transition
The page transition
-
pageAA
protected PdfDictionary pageAA
-
thumb
protected PdfIndirectReference thumb
-
pageResources
protected PageResources pageResources
This are the page resources of the current Page.
-
strictImageSequence
protected boolean strictImageSequence
Holds value of property strictImageSequence.
-
imageEnd
protected float imageEnd
This is the position where the image ends.
-
imageWait
protected Image imageWait
This is the image that could not be shown on a previous page.
-
jsCounter
int jsCounter
Stores a list of document level JavaScript actions.
-
annotationsImp
PdfAnnotationsImp annotationsImp
-
pageEmpty
private boolean pageEmpty
This checks if the page is empty.
-
isDoFooter
private boolean isDoFooter
This is the flag meaning whether document is creating footer.
-
-
Method Detail
-
createInOneCell
static PdfPTable createInOneCell(Paragraph paragraph)
Integrate a paragraph into a table, so it can be a whole.Note: This is not a table with square, it's just like the paragraph, but it cannot be separated.
- Parameters:
paragraph
- theParagraph
incoming paragraphs to be consolidated- Returns:
PdfPTable
the whole which will be used later
-
addWriter
public void addWriter(PdfWriter writer) throws DocumentException
Adds aPdfWriter
to thePdfDocument
.- Parameters:
writer
- thePdfWriter
that writes everything what is added to this document to an outputstream.- Throws:
DocumentException
- on error
-
getLeading
public float getLeading()
Getter for the current leading.- Returns:
- the current leading
- Since:
- 2.1.2
-
setLeading
void setLeading(float leading)
Setter for the current leading.- Parameters:
leading
- the current leading- Since:
- 2.1.6
-
add
public boolean add(Element element) throws DocumentException
Signals that anElement
was added to theDocument
.- Specified by:
add
in interfaceElementListener
- Overrides:
add
in classDocument
- Parameters:
element
- the element to add- Returns:
true
if the element was added,false
if not.- Throws:
DocumentException
- when a document isn't open yet, or has been closed
-
open
public void open()
Opens the document.You have to open the document before you can begin to add content to the body of the document.
- Specified by:
open
in interfaceDocListener
- Overrides:
open
in classDocument
-
close
public void close()
Closes the document.Once all the content has been written in the body, you have to close the body. After that nothing can be written to the body anymore.
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceDocListener
- Overrides:
close
in classDocument
-
setXmpMetadata
public void setXmpMetadata(byte[] xmpMetadata)
Use this method to set the XMP Metadata.- Parameters:
xmpMetadata
- The xmpMetadata to set.
-
newPage
public boolean newPage()
Makes a new page and sends it to thePdfWriter
.- Specified by:
newPage
in interfaceDocListener
- Overrides:
newPage
in classDocument
- Returns:
- a
boolean
-
setPageSize
public boolean setPageSize(Rectangle pageSize)
Sets the pagesize.- Specified by:
setPageSize
in interfaceDocListener
- Overrides:
setPageSize
in classDocument
- Parameters:
pageSize
- the new pagesize- Returns:
true
if the page size was set
-
setMargins
public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
Sets the margins.- Specified by:
setMargins
in interfaceDocListener
- Overrides:
setMargins
in classDocument
- Parameters:
marginLeft
- the margin on the leftmarginRight
- the margin on the rightmarginTop
- the margin on the topmarginBottom
- the margin on the bottom- Returns:
- a
boolean
-
setMarginMirroring
public boolean setMarginMirroring(boolean MarginMirroring)
Description copied from class:Document
Set the margin mirroring. It will mirror right/left margins for odd/even pages.Note: it will not work with
Table
.- Specified by:
setMarginMirroring
in interfaceDocListener
- Overrides:
setMarginMirroring
in classDocument
- Parameters:
MarginMirroring
-true
to mirror the margins- Returns:
- always
true
- See Also:
DocListener.setMarginMirroring(boolean)
-
setMarginMirroringTopBottom
public boolean setMarginMirroringTopBottom(boolean MarginMirroringTopBottom)
Description copied from class:Document
Set the margin mirroring. It will mirror top/bottom margins for odd/even pages.Note: it will not work with
Table
.- Specified by:
setMarginMirroringTopBottom
in interfaceDocListener
- Overrides:
setMarginMirroringTopBottom
in classDocument
- Parameters:
MarginMirroringTopBottom
-true
to mirror the margins- Returns:
- always
true
- Since:
- 2.1.6
- See Also:
DocListener.setMarginMirroring(boolean)
-
setPageCount
public void setPageCount(int pageN)
Sets the page number.- Specified by:
setPageCount
in interfaceDocListener
- Overrides:
setPageCount
in classDocument
- Parameters:
pageN
- the new page number
-
resetPageCount
public void resetPageCount()
Sets the page number to 0.- Specified by:
resetPageCount
in interfaceDocListener
- Overrides:
resetPageCount
in classDocument
-
setHeader
public void setHeader(HeaderFooter header)
Changes the header of this document.- Specified by:
setHeader
in interfaceDocListener
- Overrides:
setHeader
in classDocument
- Parameters:
header
- the new header
-
resetHeader
public void resetHeader()
Resets the header of this document.- Specified by:
resetHeader
in interfaceDocListener
- Overrides:
resetHeader
in classDocument
-
setFooter
public void setFooter(HeaderFooter footer)
Changes the footer of this document.- Specified by:
setFooter
in interfaceDocListener
- Overrides:
setFooter
in classDocument
- Parameters:
footer
- the new footer
-
resetFooter
public void resetFooter()
Resets the footer of this document.- Specified by:
resetFooter
in interfaceDocListener
- Overrides:
resetFooter
in classDocument
-
initPage
protected void initPage() throws DocumentException
Initializes a page.If the footer/header is set, it is printed.
- Throws:
DocumentException
- on error
-
newLine
protected void newLine() throws DocumentException
Adds the current line to the list of lines and also adds an empty line.- Throws:
DocumentException
- on error
-
carriageReturn
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.
-
getVerticalPosition
public float getVerticalPosition(boolean ensureNewLine)
Gets the current vertical page position.- Parameters:
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.- Returns:
- The current vertical page position.
-
ensureNewLine
protected void ensureNewLine()
Ensures that a new line has been started.
-
flushLines
protected float flushLines() throws DocumentException
Writes all the lines to the text-object.- Returns:
- the displacement that was caused
- Throws:
DocumentException
- on error
-
writeLineToContent
void writeLineToContent(PdfLine line, PdfContentByte text, PdfContentByte graphics, java.lang.Object[] currentValues, float ratio) throws DocumentException
Writes a text line to the document. It takes care of all the attributes.Before entering the line position must have been established and the
text
argument must be in text object scope (beginText()
).- Parameters:
line
- the line to be writtentext
- thePdfContentByte
where the text will be written tographics
- thePdfContentByte
where the graphics will be written tocurrentValues
- the current font and extra spacing valuesratio
-- Throws:
DocumentException
- on error
-
indentLeft
protected float indentLeft()
Gets the indentation on the left side.- Returns:
- a margin
-
indentRight
protected float indentRight()
Gets the indentation on the right side.- Returns:
- a margin
-
indentTop
protected float indentTop()
Gets the indentation on the top side.- Returns:
- a margin
-
indentBottom
float indentBottom()
Gets the indentation on the bottom side.- Returns:
- a margin
-
addSpacing
protected void addSpacing(float extraspace, float oldleading, Font f)
Adds extra space. This method should probably be rewritten.- Parameters:
extraspace
- extra spaceoldleading
- old leadingf
- font
-
getInfo
protected PdfDocument.PdfInfo getInfo()
Gets thePdfInfo
-object.- Returns:
PdfInfo
-
getCatalog
PdfDocument.PdfCatalog getCatalog(PdfIndirectReference pages)
Gets thePdfCatalog
-object.- Parameters:
pages
- an indirect reference to this document pages- Returns:
PdfCatalog
-
addOutline
void addOutline(PdfOutline outline, java.lang.String name)
Adds a named outline to the document .- Parameters:
outline
- the outline to be addedname
- the name of this local destination
-
getRootOutline
public PdfOutline getRootOutline()
Gets the root outline. All the outlines must be created with a parent. The first level is created with this outline.- Returns:
- the root outline
-
calculateOutlineCount
void calculateOutlineCount()
Updates the count in the outlines.
-
traverseOutlineCount
void traverseOutlineCount(PdfOutline outline)
Recursive method to update the count in the outlines.
-
writeOutlines
void writeOutlines() throws java.io.IOException
Writes the outline tree to the body of the PDF document.- Throws:
java.io.IOException
-
outlineTree
void outlineTree(PdfOutline outline) throws java.io.IOException
Recursive method used to write outlines.- Throws:
java.io.IOException
-
setViewerPreferences
void setViewerPreferences(int preferences)
-
setPageLabels
void setPageLabels(PdfPageLabels pageLabels)
Sets the page labels- Parameters:
pageLabels
- the page labels
-
localGoto
void localGoto(java.lang.String name, float llx, float lly, float urx, float ury)
Implements a link to other part of the document. The jump will be made to a local destination with the same name, that must exist.- Parameters:
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 area
-
remoteGoto
void remoteGoto(java.lang.String filename, java.lang.String name, float llx, float lly, float urx, float ury)
Implements a link to another document.- Parameters:
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 area
-
remoteGoto
void remoteGoto(java.lang.String filename, int page, float llx, float lly, float urx, float ury)
Implements a link to another document.- Parameters:
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 area
-
setAction
void setAction(PdfAction action, float llx, float lly, float urx, float ury)
Implements an action in an area.- Parameters:
action
- thePdfAction
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 area
-
getLocalGotoAction
PdfAction getLocalGotoAction(java.lang.String name)
-
localDestination
boolean localDestination(java.lang.String name, PdfDestination destination)
The local destination to where a local goto with the same name will jump to.- Parameters:
name
- the name of this local destinationdestination
- thePdfDestination
with the jump coordinates- Returns:
true
if the local destination was added,false
if a local destination with the same name already existed
-
addJavaScript
void addJavaScript(PdfAction js)
-
addJavaScript
void addJavaScript(java.lang.String name, PdfAction js)
-
getDocumentLevelJS
java.util.HashMap<java.lang.String,PdfIndirectReference> getDocumentLevelJS()
-
addFileAttachment
void addFileAttachment(java.lang.String description, PdfFileSpecification fs) throws java.io.IOException
- Throws:
java.io.IOException
-
getDocumentFileAttachment
java.util.HashMap<java.lang.String,PdfIndirectReference> getDocumentFileAttachment()
-
setOpenAction
void setOpenAction(java.lang.String name)
-
setOpenAction
void setOpenAction(PdfAction action)
-
setCollection
public void setCollection(PdfCollection collection)
Sets the collection dictionary.- Parameters:
collection
- a dictionary of type PdfCollection
-
getAcroForm
PdfAcroForm getAcroForm()
Gets the AcroForm object.- Returns:
- the PdfAcroform object of the PdfDocument
-
setSigFlags
void setSigFlags(int f)
-
addCalculationOrder
void addCalculationOrder(PdfFormField formField)
-
addAnnotation
void addAnnotation(PdfAnnotation annot)
-
getMarkPoint
int getMarkPoint()
-
incMarkPoint
void incMarkPoint()
-
setCropBoxSize
void setCropBoxSize(Rectangle crop)
-
setBoxSize
void setBoxSize(java.lang.String boxName, Rectangle size)
-
setNewPageSizeAndMargins
protected void setNewPageSizeAndMargins()
-
getBoxSize
Rectangle getBoxSize(java.lang.String boxName)
Gives the size of a trim, art, crop or bleed box, or null if not defined.- Parameters:
boxName
- crop, trim, art or bleed- Returns:
- Rectangle
-
isPageEmpty
boolean isPageEmpty()
-
setPageEmpty
void setPageEmpty(boolean pageEmpty)
-
setDuration
void setDuration(int seconds)
Sets the display duration for the page (for presentations)- Parameters:
seconds
- the number of seconds to display the page
-
setTransition
void setTransition(PdfTransition transition)
Sets the transition for the page- Parameters:
transition
- the PdfTransition object
-
setThumbnail
void setThumbnail(Image image) throws DocumentException
- Throws:
DocumentException
-
getPageResources
PageResources getPageResources()
-
isStrictImageSequence
boolean isStrictImageSequence()
Getter for property strictImageSequence.- Returns:
- Value of property strictImageSequence.
-
setStrictImageSequence
void setStrictImageSequence(boolean strictImageSequence)
Setter for property strictImageSequence.- Parameters:
strictImageSequence
- New value of property strictImageSequence.
-
clearTextWrap
public void clearTextWrap()
Method added by Pelikan Stephan
-
add
protected void add(Image image) throws DocumentException
Adds an image to the document.- Parameters:
image
- theImage
to add- Throws:
PdfException
- on errorDocumentException
- on error
-
flushSpecial
protected void flushSpecial()
write non-textElement
into document
-
addDelay
protected void addDelay(Image image)
Occupies space forImage
that will be added later instead of now- Parameters:
image
- the newImage
-
delayTableAddition
protected void delayTableAddition(PdfPTable table)
Occupies space forPdfPTable
that will be added later instead of now- Parameters:
table
- the newPdfPTable
-
addPTable
void addPTable(PdfPTable ptable) throws DocumentException
Adds aPdfPTable
to the document.- Parameters:
ptable
- thePdfPTable
to be added to the document.- Throws:
DocumentException
- on error
-
fitsPage
boolean fitsPage(PdfPTable table, float margin)
Checks if aPdfPTable
fits the current page of thePdfDocument
.- Parameters:
table
- the table that has to be checkedmargin
- a certain margin- Returns:
true
if thePdfPTable
fits the page,false
otherwise.
-
setTableWidth
private void setTableWidth(PdfPTable table)
-
addPdfTable
private void addPdfTable(Table t) throws DocumentException
Adds a new table to the document.- Parameters:
t
- Table to add. Rendered rows will be deleted after processing.- Throws:
DocumentException
- Since:
- iText 2.0.8
-
analyzeRow
protected void analyzeRow(java.util.List<java.util.List<PdfCell>> rows, PdfDocument.RenderingContext ctx)
-
mayBeRemoved
protected boolean mayBeRemoved(java.util.List<PdfCell> row)
-
consumeRowspan
protected void consumeRowspan(java.util.List<PdfCell> row, PdfDocument.RenderingContext ctx)
-
extractRows
protected java.util.List<java.util.List<PdfCell>> extractRows(java.util.List<PdfCell> cells, PdfDocument.RenderingContext ctx)
-
renderCells
protected void renderCells(PdfDocument.RenderingContext ctx, java.util.List cells, boolean hasToFit) throws DocumentException
- Throws:
DocumentException
-
bottom
float bottom(Table table)
Returns the bottomvalue of aTable
if it were added to this document.- Parameters:
table
- the table that may or may not be added to this document- Returns:
- a bottom value
-
doFooter
protected void doFooter() throws DocumentException
- Throws:
DocumentException
-
doHeader
protected void doHeader() throws DocumentException
- Throws:
DocumentException
-
-