public class PdfDocument extends Document
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| Modifier and Type | Class and Description |
|---|---|
class |
PdfDocument.Destination |
static class |
PdfDocument.Indentation |
static class |
PdfDocument.PdfInfo
PdfInfo is the PDF InfoDictionary. |
| Modifier and Type | Field and Description |
|---|---|
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. |
protected HashMap<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 current
PdfOutline in the hierarchy of outlines. |
protected HashMap<String,PdfObject> |
documentFileAttachment |
protected HashMap<String,PdfObject> |
documentLevelJS |
protected boolean |
firstPageEvent
Signals that OnOpenDocument should be called.
|
protected PdfContentByte |
graphics
This is the PdfContentByte object, containing the borders and other Graphics.
|
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).
|
protected PdfString |
language |
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 PdfLine |
line
The line that is currently being written.
|
protected ArrayList<PdfLine> |
lines
The lines that are written until now.
|
protected TreeMap<String,PdfDocument.Destination> |
localDestinations
Stores the destinations keyed by name.
|
protected HashMap<Object,Integer> |
markPoints |
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 boolean |
openMCDocument |
protected PdfDictionary |
pageAA |
protected PdfPageLabels |
pageLabels |
protected com.itextpdf.text.pdf.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 HashMap<Object,int[]> |
structParentIndices |
protected TabSettings |
tabSettings
The current tab settings.
|
protected PdfContentByte |
text
This is the PdfContentByte object, containing the text.
|
protected int |
textEmptySize |
protected HashMap<String,PdfRectangle> |
thisBoxSize
This is the size of the several boxes of the current Page.
|
protected PdfViewerPreferencesImp |
viewerPreferences
Contains the Viewer preferences of this PDF document.
|
protected PdfWriter |
writer
The
PdfWriter. |
accessibleAttributes, chapternumber, close, compress, htmlStyleClass, id, javaScript_onLoad, javaScript_onUnLoad, listeners, marginBottom, marginLeft, marginMirroring, marginMirroringTopBottom, marginRight, marginTop, open, pageN, pageSize, plainRandomAccess, role, wmfFontCorrection| Constructor and Description |
|---|
PdfDocument()
Constructs a new PDF document.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Element element)
Signals that an
Element was added to the Document. |
protected void |
add(Image image)
Adds an image to the document.
|
protected void |
addSpacing(float extraspace,
float oldleading,
Font f)
Calls addSpacing(float, float, Font, boolean (false)).
|
protected void |
addSpacing(float extraspace,
float oldleading,
Font f,
boolean spacingAfter)
Adds extra spacing.
|
void |
addWriter(PdfWriter writer)
Adds a
PdfWriter to the PdfDocument. |
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
|
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 ArrayList<IAccessibleElement> |
endPage() |
protected void |
ensureNewLine()
Ensures that a new line has been started.
|
protected float |
flushLines()
Writes all the lines to the text-object.
|
protected void |
flushStructureElementsOnNewPage() |
float |
getLeading()
Getter for the current leading.
|
int |
getNextMarkPoint(Object obj) |
PdfPageLabels |
getPageLabels() |
PdfOutline |
getRootOutline()
Gets the root outline.
|
protected PdfStructureElement |
getStructElement(AccessibleElementId id) |
protected PdfStructureElement |
getStructElement(AccessibleElementId id,
boolean toSaveFetchedElement) |
Set<AccessibleElementId> |
getStructElements() |
int |
getStructParentIndex(Object obj) |
int[] |
getStructParentIndexAndNextMarkPoint(Object obj) |
TabSettings |
getTabSettings()
Getter for the current tab stops.
|
float |
getVerticalPosition(boolean ensureNewLine)
Gets the current vertical page position.
|
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.
|
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.
|
protected void |
popLeading()
Restore @leading from leadingStack
|
protected void |
pushLeading()
Save current @leading
|
void |
resetPageCount()
Sets the page number to 0.
|
protected void |
saveStructElement(AccessibleElementId id,
PdfStructureElement element) |
void |
setCollection(PdfCollection collection)
Sets the collection dictionary.
|
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() |
void |
setPageCount(int pageN)
Sets the page number.
|
boolean |
setPageSize(Rectangle pageSize)
Sets the pagesize.
|
void |
setTabSettings(TabSettings tabSettings)
Setter for the current tab stops.
|
void |
setXmpMetadata(byte[] xmpMetadata)
Use this method to set the XMP Metadata.
|
protected void |
useExternalCache(TempFileCache externalCache) |
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, topMarginprotected PdfWriter writer
PdfWriter.protected boolean openMCDocument
protected PdfContentByte text
protected PdfContentByte graphics
protected float leading
protected int alignment
protected float currentHeight
protected boolean isSectionTitle
protected PdfAction anchorAction
PdfAction when processing an Anchor.protected TabSettings tabSettings
protected int textEmptySize
protected float nextMarginLeft
protected float nextMarginRight
protected float nextMarginTop
protected float nextMarginBottom
protected boolean firstPageEvent
protected PdfLine line
protected int lastElementType
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<String,PdfDocument.Destination> localDestinations
Destination.protected static final DecimalFormat SIXTEEN_DIGITS
protected String openActionName
protected PdfAction openActionAction
protected PdfDictionary additionalActions
protected PdfCollection collection
protected PdfString language
protected Rectangle nextPageSize
protected HashMap<String,PdfRectangle> thisBoxSize
protected HashMap<String,PdfRectangle> boxSize
protected PdfDictionary pageAA
protected com.itextpdf.text.pdf.PageResources pageResources
protected boolean strictImageSequence
protected float imageEnd
protected Image imageWait
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()
protected void pushLeading()
protected void popLeading()
public TabSettings getTabSettings()
public void setTabSettings(TabSettings tabSettings)
tabSettings - the current tab settingspublic boolean add(Element element) throws DocumentException
Element was added to the Document.add in interface ElementListeneradd in class Documentelement - the element to addtrue 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 DocListeneropen in class Documentpublic void close()
close in interface DocListenerclose in class Documentpublic void setXmpMetadata(byte[] xmpMetadata)
throws IOException
xmpMetadata - The xmpMetadata to set.IOExceptionpublic boolean newPage()
PdfWriter.newPage in interface DocListenernewPage in class Documentprotected ArrayList<IAccessibleElement> endPage()
public boolean setPageSize(Rectangle pageSize)
setPageSize in interface DocListenersetPageSize in class DocumentpageSize - the new pagesizetrue if the page size was setpublic boolean setMargins(float marginLeft,
float marginRight,
float marginTop,
float marginBottom)
setMargins in interface DocListenersetMargins in class DocumentmarginLeft - the margin on the leftmarginRight - the margin on the rightmarginTop - the margin on the topmarginBottom - the margin on the bottombooleanpublic boolean setMarginMirroring(boolean MarginMirroring)
DocumentsetMarginMirroring in interface DocListenersetMarginMirroring in class DocumentMarginMirroring - true to mirror the marginstrueDocListener.setMarginMirroring(boolean)public boolean setMarginMirroringTopBottom(boolean MarginMirroringTopBottom)
DocumentsetMarginMirroringTopBottom in interface DocListenersetMarginMirroringTopBottom in class DocumentMarginMirroringTopBottom - true to mirror the marginstrueDocListener.setMarginMirroring(boolean)public void setPageCount(int pageN)
setPageCount in interface DocListenersetPageCount in class DocumentpageN - the new page numberpublic void resetPageCount()
resetPageCount in interface DocListenerresetPageCount in class Documentprotected void initPage()
throws DocumentException
If the footer/header is set, it is printed.
DocumentException - on errorprotected void newLine()
throws DocumentException
DocumentException - on errorprotected float calculateLineHeight()
protected 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 errorprotected float indentLeft()
protected float indentRight()
protected float indentTop()
protected void addSpacing(float extraspace,
float oldleading,
Font f)
protected void addSpacing(float extraspace,
float oldleading,
Font f,
boolean spacingAfter)
public PdfOutline getRootOutline()
public PdfPageLabels getPageLabels()
public void setCollection(PdfCollection collection)
collection - a dictionary of type PdfCollectionprotected void setNewPageSizeAndMargins()
public void clearTextWrap()
public int getStructParentIndex(Object obj)
public int getNextMarkPoint(Object obj)
public int[] getStructParentIndexAndNextMarkPoint(Object obj)
protected void add(Image image) throws PdfException, DocumentException
image - the Image to addPdfException - on errorDocumentException - on errorprotected void useExternalCache(TempFileCache externalCache)
protected void saveStructElement(AccessibleElementId id, PdfStructureElement element)
protected PdfStructureElement getStructElement(AccessibleElementId id)
protected PdfStructureElement getStructElement(AccessibleElementId id, boolean toSaveFetchedElement)
protected void flushStructureElementsOnNewPage()
public Set<AccessibleElementId> getStructElements()
Copyright © 2016. All rights reserved.