Package com.itextpdf.text.pdf
Class PdfDocument
- java.lang.Object
-
- com.itextpdf.text.Document
-
- com.itextpdf.text.pdf.PdfDocument
-
- All Implemented Interfaces:
DocListener,ElementListener,IAccessibleElement,java.util.EventListener
public class PdfDocument extends Document
PdfDocumentis the class that is used byPdfWriterto translate aDocumentinto a PDF with different pages.A
PdfDocumentalways listens to aDocumentand adds the Pdf representation of everyElementthat 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 classPdfDocument.Destinationstatic classPdfDocument.Indentation(package private) static classPdfDocument.PdfCatalogPdfCatalogis the PDF Catalog-object.static classPdfDocument.PdfInfoPdfInfois the PDF InfoDictionary.
-
Field Summary
Fields Modifier and Type Field Description protected PdfDictionaryadditionalActionsprotected intalignmentThis represents the current alignment of the PDF Elements.protected PdfActionanchorActionThe current activePdfActionwhen processing anAnchor.(package private) PdfAnnotationsImpannotationsImpprivate PdfBodybodyprotected java.util.HashMap<java.lang.String,PdfRectangle>boxSizeThis is the size of the several boxes that will be used in the next page.protected PdfCollectioncollectionprotected floatcurrentHeightThis is the current height of the document.protected PdfOutlinecurrentOutlineThis is the currentPdfOutlinein the hierarchy of outlines.protected java.util.HashMap<java.lang.String,PdfObject>documentFileAttachmentprotected java.util.HashMap<java.lang.String,PdfObject>documentLevelJSprivate java.util.HashMap<AccessibleElementId,AccessibleElementId>elementsParentsprivate TempFileCacheexternalCacheprivate java.util.HashMap<AccessibleElementId,TempFileCache.ObjectPosition>externallyStoredStructElementsprotected booleanfirstPageEventSignals that OnOpenDocument should be called.private java.util.ArrayList<Element>floatingElementsprotected PdfContentBytegraphicsThis is the PdfContentByte object, containing the borders and other Graphics.(package private) static java.lang.StringhangingPunctuationThe characters to be applied the hanging punctuation.protected floatimageEndThis is the position where the image ends.protected ImageimageWaitThis is the image that could not be shown on a previous page.protected PdfDocument.Indentationindentationprotected PdfDocument.PdfInfoinfosome meta information about the Document.protected booleanisSectionTitleSignals that onParagraph is valid (to avoid that a Chapter/Section title is treated as a Paragraph).private booleanisToUseExternalCache(package private) intjsCounterStores a list of document level JavaScript actions.protected PdfStringlanguageprotected intlastElementTypeHolds the type of the last element, that has been added to the document.protected floatleadingThis represents the leading of the lines.private java.util.Stack<java.lang.Float>leadingStackSignals that the current leading has to be subtracted from a YMark object when positive and save current leadingprotected PdfLinelineThe line that is currently being written.protected java.util.ArrayList<PdfLine>linesThe lines that are written until now.protected java.util.TreeMap<java.lang.String,PdfDocument.Destination>localDestinationsStores the destinations keyed by name.protected java.util.HashMap<java.lang.Object,java.lang.Integer>markPointsprotected floatnextMarginBottommargin in y direction starting from the bottom.protected floatnextMarginLeftmargin in x direction starting from the left.protected floatnextMarginRightmargin in x direction starting from the right.protected floatnextMarginTopmargin in y direction starting from the top.protected RectanglenextPageSizeThis is the size of the next page.protected PdfActionopenActionActionprotected java.lang.StringopenActionNameprotected booleanopenMCDocumentprotected PdfDictionarypageAAprivate booleanpageEmptyThis checks if the page is empty.protected PdfPageLabelspageLabelsprotected PageResourcespageResourcesThis are the page resources of the current Page.protected PdfOutlinerootOutlineThis is the root outline of the document.protected static java.text.DecimalFormatSIXTEEN_DIGITSprotected booleanstrictImageSequenceHolds value of property strictImageSequence.private java.util.HashMap<AccessibleElementId,PdfStructureElement>structElementsprotected java.util.HashMap<java.lang.Object,int[]>structParentIndicesprotected TabSettingstabSettingsThe current tab settings.protected PdfContentBytetextThis is the PdfContentByte object, containing the text.protected inttextEmptySizeprotected java.util.HashMap<java.lang.String,PdfRectangle>thisBoxSizeThis is the size of the several boxes of the current Page.protected PdfViewerPreferencesImpviewerPreferencesContains the Viewer preferences of this PDF document.protected PdfWriterwriterThePdfWriter.-
Fields inherited from class com.itextpdf.text.Document
accessibleAttributes, chapternumber, close, compress, htmlStyleClass, id, javaScript_onLoad, javaScript_onUnLoad, listeners, marginBottom, marginLeft, marginMirroring, marginMirroringTopBottom, marginRight, marginTop, open, pageN, pageSize, plainRandomAccess, role, 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 booleanadd(Element element)Signals that anElementwas added to theDocument.protected voidadd(Image image)Adds an image to the document.(package private) voidaddAdditionalAction(PdfName actionType, PdfAction action)(package private) voidaddAnnotation(PdfAnnotation annot)(package private) voidaddCalculationOrder(PdfFormField formField)private voidaddDiv(PdfDiv div)(package private) voidaddFileAttachment(java.lang.String description, PdfFileSpecification fs)(package private) voidaddJavaScript(PdfAction js)(package private) voidaddJavaScript(java.lang.String name, PdfAction js)(package private) voidaddOutline(PdfOutline outline, java.lang.String name)Adds a named outline to the document .(package private) voidaddPTable(PdfPTable ptable)Adds aPdfPTableto the document.protected voidaddSpacing(float extraspace, float oldleading, Font f)Calls addSpacing(float, float, Font, boolean (false)).protected voidaddSpacing(float extraspace, float oldleading, Font f, boolean spacingAfter)Adds extra spacing.(package private) voidaddViewerPreference(PdfName key, PdfObject value)voidaddWriter(PdfWriter writer)Adds aPdfWriterto thePdfDocument.protected floatcalculateLineHeight()line.height() is usually the same as the leading We should take leading into account if it is not the same as the line.height(package private) voidcalculateOutlineCount()Updates the count in the outlines.protected voidcarriageReturn()If the current line is not empty or null, it is added to the arraylist of lines and a new empty line is added.voidclearTextWrap()Method added by Pelikan Stephanvoidclose()Closes the document.protected java.util.ArrayList<IAccessibleElement>endPage()protected voidensureNewLine()Ensures that a new line has been started.(package private) booleanfitsPage(PdfPTable table, float margin)Checks if aPdfPTablefits the current page of thePdfDocument.private voidflushFloatingElements()protected floatflushLines()Writes all the lines to the text-object.protected voidflushStructureElementsOnNewPage()(package private) PdfAcroFormgetAcroForm()Gets the AcroForm object.(package private) RectanglegetBoxSize(java.lang.String boxName)Gives the size of a trim, art, crop or bleed box, or null if not defined.(package private) PdfDocument.PdfCataloggetCatalog(PdfIndirectReference pages)Gets thePdfCatalog-object.(package private) java.util.HashMap<java.lang.String,PdfObject>getDocumentFileAttachment()(package private) java.util.HashMap<java.lang.String,PdfObject>getDocumentLevelJS()(package private) PdfDocument.PdfInfogetInfo()Gets thePdfInfo-object.private PdfLinegetLastLine()floatgetLeading()Getter for the current leading.(package private) PdfActiongetLocalGotoAction(java.lang.String name)intgetNextMarkPoint(java.lang.Object obj)PdfPageLabelsgetPageLabels()(package private) PageResourcesgetPageResources()PdfOutlinegetRootOutline()Gets the root outline.protected PdfStructureElementgetStructElement(AccessibleElementId id)protected PdfStructureElementgetStructElement(AccessibleElementId id, boolean toSaveFetchedElement)java.util.Set<AccessibleElementId>getStructElements()intgetStructParentIndex(java.lang.Object obj)int[]getStructParentIndexAndNextMarkPoint(java.lang.Object obj)TabSettingsgetTabSettings()Getter for the current tab stops.floatgetVerticalPosition(boolean ensureNewLine)Gets the current vertical page position.(package private) floatindentBottom()Gets the indentation on the bottom side.protected floatindentLeft()Gets the indentation on the left side.protected floatindentRight()Gets the indentation on the right side.protected floatindentTop()Gets the indentation on the top side.protected voidinitPage()Initializes a page.(package private) booleanisPageEmpty()(package private) booleanisStrictImageSequence()Getter for property strictImageSequence.private static booleanisTagged(PdfWriter writer)(package private) booleanlocalDestination(java.lang.String name, PdfDestination destination)The local destination to where a local goto with the same name will jump to.(package private) voidlocalGoto(java.lang.String name, float llx, float lly, float urx, float ury)Implements a link to other part of the document.protected voidnewLine()Adds the current line to the list of lines and also adds an empty line.booleannewPage()Makes a new page and sends it to thePdfWriter.voidopen()Opens the document.(package private) voidoutlineTree(PdfOutline outline)Recursive method used to write outlines.protected voidpopLeading()Restore @leading from leadingStackprotected voidpushLeading()Save current @leading(package private) voidremoteGoto(java.lang.String filename, int page, float llx, float lly, float urx, float ury)Implements a link to another document.(package private) voidremoteGoto(java.lang.String filename, java.lang.String name, float llx, float lly, float urx, float ury)Implements a link to another document.voidresetPageCount()Sets the page number to 0.protected voidsaveStructElement(AccessibleElementId id, PdfStructureElement element)(package private) voidsetAction(PdfAction action, float llx, float lly, float urx, float ury)Implements an action in an area.(package private) voidsetBoxSize(java.lang.String boxName, Rectangle size)voidsetCollection(PdfCollection collection)Sets the collection dictionary.(package private) voidsetCropBoxSize(Rectangle crop)(package private) voidsetDuration(int seconds)Sets the display duration for the page (for presentations)(package private) voidsetLanguage(java.lang.String language)(package private) voidsetLeading(float leading)Setter for the current leading.booleansetMarginMirroring(boolean MarginMirroring)Set the margin mirroring.booleansetMarginMirroringTopBottom(boolean MarginMirroringTopBottom)Set the margin mirroring.booleansetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)Sets the margins.protected voidsetNewPageSizeAndMargins()(package private) voidsetOpenAction(PdfAction action)(package private) voidsetOpenAction(java.lang.String name)(package private) voidsetPageAction(PdfName actionType, PdfAction action)voidsetPageCount(int pageN)Sets the page number.(package private) voidsetPageEmpty(boolean pageEmpty)(package private) voidsetPageLabels(PdfPageLabels pageLabels)Sets the page labelsbooleansetPageSize(Rectangle pageSize)Sets the pagesize.(package private) voidsetSigFlags(int f)(package private) voidsetStrictImageSequence(boolean strictImageSequence)Setter for property strictImageSequence.voidsetTabSettings(TabSettings tabSettings)Setter for the current tab stops.(package private) voidsetThumbnail(Image image)(package private) voidsetTransition(PdfTransition transition)Sets the transition for the page(package private) voidsetViewerPreferences(int preferences)voidsetXmpMetadata(byte[] xmpMetadata)Use this method to set the XMP Metadata.(package private) voidtraverseOutlineCount(PdfOutline outline)Recursive method to update the count in the outlines.protected voiduseExternalCache(TempFileCache externalCache)(package private) floatwriteLineToContent(PdfLine line, PdfContentByte text, PdfContentByte graphics, java.lang.Object[] currentValues, float ratio)Writes a text line to the document.(package private) voidwriteOutlines()Writes the outline tree to the body of the PDF document.-
Methods inherited from class com.itextpdf.text.Document
addAuthor, addCreationDate, addCreator, addDocListener, addHeader, addKeywords, addLanguage, addProducer, addSubject, addTitle, bottom, bottom, bottomMargin, getAccessibleAttribute, getAccessibleAttributes, getHtmlStyleClass, getId, getJavaScript_onLoad, getJavaScript_onUnLoad, getPageNumber, getPageSize, getRole, isInline, isMarginMirroring, isOpen, left, left, leftMargin, removeDocListener, right, right, rightMargin, setAccessibleAttribute, setHtmlStyleClass, setId, setJavaScript_onLoad, setJavaScript_onUnLoad, setRole, top, top, topMargin
-
-
-
-
Field Detail
-
writer
protected PdfWriter writer
ThePdfWriter.
-
structElements
private java.util.HashMap<AccessibleElementId,PdfStructureElement> structElements
-
externalCache
private TempFileCache externalCache
-
externallyStoredStructElements
private java.util.HashMap<AccessibleElementId,TempFileCache.ObjectPosition> externallyStoredStructElements
-
elementsParents
private java.util.HashMap<AccessibleElementId,AccessibleElementId> elementsParents
-
isToUseExternalCache
private boolean isToUseExternalCache
-
openMCDocument
protected boolean openMCDocument
-
structParentIndices
protected java.util.HashMap<java.lang.Object,int[]> structParentIndices
-
markPoints
protected java.util.HashMap<java.lang.Object,java.lang.Integer> markPoints
-
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
-
anchorAction
protected PdfAction anchorAction
The current activePdfActionwhen processing anAnchor.
-
tabSettings
protected TabSettings tabSettings
The current tab settings.- Since:
- 5.4.0
-
leadingStack
private java.util.Stack<java.lang.Float> leadingStack
Signals that the current leading has to be subtracted from a YMark object when positive and save current leading- Since:
- 2.1.2
-
body
private PdfBody body
-
textEmptySize
protected int textEmptySize
-
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.ArrayList<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.
-
hangingPunctuation
static final java.lang.String hangingPunctuation
The characters to be applied the hanging punctuation.- See Also:
- Constant Field Values
-
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 currentPdfOutlinein 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,PdfDocument.Destination> localDestinations
Stores the destinations keyed by name. Value is aDestination.
-
jsCounter
int jsCounter
Stores a list of document level JavaScript actions.
-
documentLevelJS
protected java.util.HashMap<java.lang.String,PdfObject> documentLevelJS
-
SIXTEEN_DIGITS
protected static final java.text.DecimalFormat SIXTEEN_DIGITS
-
documentFileAttachment
protected java.util.HashMap<java.lang.String,PdfObject> documentFileAttachment
-
openActionName
protected java.lang.String openActionName
-
openActionAction
protected PdfAction openActionAction
-
additionalActions
protected PdfDictionary additionalActions
-
collection
protected PdfCollection collection
-
annotationsImp
PdfAnnotationsImp annotationsImp
-
language
protected PdfString language
-
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.
-
pageEmpty
private boolean pageEmpty
This checks if the page is empty.
-
pageAA
protected PdfDictionary pageAA
-
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.
-
floatingElements
private java.util.ArrayList<Element> floatingElements
-
-
Method Detail
-
addWriter
public void addWriter(PdfWriter writer) throws DocumentException
Adds aPdfWriterto thePdfDocument.- Parameters:
writer- thePdfWriterthat 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
-
pushLeading
protected void pushLeading()
Save current @leading
-
popLeading
protected void popLeading()
Restore @leading from leadingStack
-
getTabSettings
public TabSettings getTabSettings()
Getter for the current tab stops.- Since:
- 5.4.0
-
setTabSettings
public void setTabSettings(TabSettings tabSettings)
Setter for the current tab stops.- Parameters:
tabSettings- the current tab settings- Since:
- 5.4.0
-
add
public boolean add(Element element) throws DocumentException
Signals that anElementwas added to theDocument.- Specified by:
addin interfaceElementListener- Overrides:
addin classDocument- Parameters:
element- the element to add- Returns:
trueif the element was added,falseif 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:
openin interfaceDocListener- Overrides:
openin 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:
closein interfaceDocListener- Overrides:
closein classDocument
-
setXmpMetadata
public void setXmpMetadata(byte[] xmpMetadata) throws java.io.IOExceptionUse this method to set the XMP Metadata.- Parameters:
xmpMetadata- The xmpMetadata to set.- Throws:
java.io.IOException
-
newPage
public boolean newPage()
Makes a new page and sends it to thePdfWriter.- Specified by:
newPagein interfaceDocListener- Overrides:
newPagein classDocument- Returns:
- true if new page is added
-
endPage
protected java.util.ArrayList<IAccessibleElement> endPage()
-
setPageSize
public boolean setPageSize(Rectangle pageSize)
Sets the pagesize.- Specified by:
setPageSizein interfaceDocListener- Overrides:
setPageSizein classDocument- Parameters:
pageSize- the new pagesize- Returns:
trueif the page size was set
-
setMargins
public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)Sets the margins.- Specified by:
setMarginsin interfaceDocListener- Overrides:
setMarginsin 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:DocumentSet the margin mirroring. It will mirror right/left margins for odd/even pages.- Specified by:
setMarginMirroringin interfaceDocListener- Overrides:
setMarginMirroringin classDocument- Parameters:
MarginMirroring-trueto mirror the margins- Returns:
- always
true - See Also:
DocListener.setMarginMirroring(boolean)
-
setMarginMirroringTopBottom
public boolean setMarginMirroringTopBottom(boolean MarginMirroringTopBottom)
Description copied from class:DocumentSet the margin mirroring. It will mirror top/bottom margins for odd/even pages.- Specified by:
setMarginMirroringTopBottomin interfaceDocListener- Overrides:
setMarginMirroringTopBottomin classDocument- Parameters:
MarginMirroringTopBottom-trueto 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:
setPageCountin interfaceDocListener- Overrides:
setPageCountin classDocument- Parameters:
pageN- the new page number
-
resetPageCount
public void resetPageCount()
Sets the page number to 0.- Specified by:
resetPageCountin interfaceDocListener- Overrides:
resetPageCountin classDocument
-
initPage
protected void initPage() throws DocumentExceptionInitializes a page.If the footer/header is set, it is printed.
- Throws:
DocumentException- on error
-
newLine
protected void newLine() throws DocumentExceptionAdds the current line to the list of lines and also adds an empty line.- Throws:
DocumentException- on error
-
calculateLineHeight
protected float calculateLineHeight()
line.height() is usually the same as the leading We should take leading into account if it is not the same as the line.height- Returns:
- float combined height of the line
- Since:
- 5.5.1
-
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 DocumentExceptionWrites all the lines to the text-object.- Returns:
- the displacement that was caused
- Throws:
DocumentException- on error
-
writeLineToContent
float 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
textargument must be in text object scope (beginText()).- Parameters:
line- the line to be writtentext- thePdfContentBytewhere the text will be written tographics- thePdfContentBytewhere the graphics will be written tocurrentValues- the current font and extra spacing valuesratio-- Throws:
DocumentException- on error- Since:
- 5.0.3 returns a float instead of void
-
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)Calls addSpacing(float, float, Font, boolean (false)).
-
addSpacing
protected void addSpacing(float extraspace, float oldleading, Font f, boolean spacingAfter)Adds extra spacing.
-
getInfo
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.IOExceptionWrites 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
-
getPageLabels
public PdfPageLabels getPageLabels()
-
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- thePdfActionllx- 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- thePdfDestinationwith the jump coordinates- Returns:
trueif the local destination was added,falseif 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,PdfObject> 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,PdfObject> 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)
-
setLanguage
void setLanguage(java.lang.String language)
-
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
-
setPageEmpty
void setPageEmpty(boolean pageEmpty)
-
isPageEmpty
boolean isPageEmpty()
-
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 PdfException, DocumentException
- Throws:
PdfExceptionDocumentException
-
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
-
getStructParentIndex
public int getStructParentIndex(java.lang.Object obj)
-
getNextMarkPoint
public int getNextMarkPoint(java.lang.Object obj)
-
getStructParentIndexAndNextMarkPoint
public int[] getStructParentIndexAndNextMarkPoint(java.lang.Object obj)
-
add
protected void add(Image image) throws PdfException, DocumentException
Adds an image to the document.- Parameters:
image- theImageto add- Throws:
PdfException- on errorDocumentException- on error
-
addPTable
void addPTable(PdfPTable ptable) throws DocumentException
Adds aPdfPTableto the document.- Parameters:
ptable- thePdfPTableto be added to the document.- Throws:
DocumentException- on error
-
addDiv
private void addDiv(PdfDiv div) throws DocumentException
- Throws:
DocumentException
-
flushFloatingElements
private void flushFloatingElements() throws DocumentException- Throws:
DocumentException
-
fitsPage
boolean fitsPage(PdfPTable table, float margin)
Checks if aPdfPTablefits the current page of thePdfDocument.- Parameters:
table- the table that has to be checkedmargin- a certain margin- Returns:
trueif thePdfPTablefits the page,falseotherwise.
-
isTagged
private static boolean isTagged(PdfWriter writer)
-
getLastLine
private PdfLine getLastLine()
-
useExternalCache
protected void useExternalCache(TempFileCache externalCache)
-
saveStructElement
protected void saveStructElement(AccessibleElementId id, PdfStructureElement element)
-
getStructElement
protected PdfStructureElement getStructElement(AccessibleElementId id)
-
getStructElement
protected PdfStructureElement getStructElement(AccessibleElementId id, boolean toSaveFetchedElement)
-
flushStructureElementsOnNewPage
protected void flushStructureElementsOnNewPage()
-
getStructElements
public java.util.Set<AccessibleElementId> getStructElements()
-
-