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, topMargin
protected 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 error
public float getLeading()
protected void pushLeading()
protected void popLeading()
public TabSettings getTabSettings()
public void setTabSettings(TabSettings tabSettings)
tabSettings
- the current tab settings
public 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 closed
public 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) throws IOException
xmpMetadata
- The xmpMetadata to set.
IOException
public boolean newPage()
PdfWriter
.
newPage
in interface DocListener
newPage
in class Document
protected ArrayList<IAccessibleElement> endPage()
public boolean setPageSize(Rectangle pageSize)
setPageSize
in interface DocListener
setPageSize
in class Document
pageSize
- the new pagesize
true
if the page size was set
public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
setMargins
in interface DocListener
setMargins
in class Document
marginLeft
- the margin on the left
marginRight
- the margin on the right
marginTop
- the margin on the top
marginBottom
- the margin on the bottom
boolean
public boolean setMarginMirroring(boolean MarginMirroring)
Document
setMarginMirroring
in interface DocListener
setMarginMirroring
in class Document
MarginMirroring
- true
to mirror the margins
true
DocListener.setMarginMirroring(boolean)
public boolean setMarginMirroringTopBottom(boolean MarginMirroringTopBottom)
Document
setMarginMirroringTopBottom
in interface DocListener
setMarginMirroringTopBottom
in class Document
MarginMirroringTopBottom
- true
to mirror the margins
true
DocListener.setMarginMirroring(boolean)
public void setPageCount(int pageN)
setPageCount
in interface DocListener
setPageCount
in class Document
pageN
- the new page number
public void resetPageCount()
resetPageCount
in interface DocListener
resetPageCount
in class Document
protected void initPage() throws DocumentException
If the footer/header is set, it is printed.
DocumentException
- on error
protected void newLine() throws DocumentException
DocumentException
- on error
protected 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 error
protected 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 PdfCollection
protected 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 add
PdfException
- on error
DocumentException
- on error
protected 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 © 1998–2016. All rights reserved.