com.lowagie.text.pdf
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
.
See Also: Document DocListener PdfWriter
Nested Class Summary | |
---|---|
static class | PdfDocument.Indentation |
static class | PdfDocument.PdfCatalogPdfCatalog is the PDF Catalog-object.
|
static class | PdfDocument.PdfInfoPdfInfo is the PDF InfoDictionary.
|
static class | PdfDocument.RenderingContext
This is a helper class for adding a Table to a document. |
Field Summary | |
---|---|
PdfDictionary | additionalActions |
int | alignment This represents the current alignment of the PDF Elements. |
PdfAction | anchorAction The current active PdfAction when processing an Anchor . |
PdfAnnotationsImp | annotationsImp |
protected HashMap | boxSize This is the size of the several boxes that will be used in
the next page. |
PdfCollection | collection |
float | currentHeight This is the current height of the document. |
PdfOutline | currentOutline This is the current PdfOutline in the hierarchy of outlines. |
HashMap | documentFileAttachment |
ArrayList | documentJavaScript
Stores a list of document level JavaScript actions. |
protected int | duration The duration of the page |
boolean | firstPageEvent Signals that OnOpenDocument should be called. |
PdfContentByte | graphics This is the PdfContentByte object, containing the borders and other Graphics. |
static String | hangingPunctuation The characters to be applied the hanging punctuation. |
float | imageEnd This is the position where the image ends. |
Image | imageWait This is the image that could not be shown on a previous page. |
PdfDocument.Indentation | indentation |
PdfDocument.PdfInfo | info some meta information about the Document. |
boolean | isNewpage |
boolean | isParagraph Signals that onParagraph is valid (to avoid that a Chapter/Section title is treated as a Paragraph). |
int | lastElementType Holds the type of the last element, that has been added to the document. |
float | leading This represents the leading of the lines. |
PdfLine | line The line that is currently being written. |
ArrayList | lines The lines that are written until now. |
TreeMap | localDestinations
Stores the destinations keyed by name. |
protected int | markPoint |
protected float | nextMarginBottom margin in y direction starting from the bottom. |
protected float | nextMarginLeft margin in x direction starting from the left. |
protected float | nextMarginRight margin in x direction starting from the right. |
protected float | nextMarginTop margin in y direction starting from the top. |
protected Rectangle | nextPageSize This is the size of the next page. |
PdfAction | openActionAction |
String | openActionName |
protected PdfDictionary | pageAA |
boolean | pageEmpty This checks if the page is empty. |
protected PdfPageLabels | pageLabels |
protected PageResources | pageResources This are the page resources of the current Page. |
PdfOutline | rootOutline This is the root outline of the document. |
boolean | strictImageSequence Holds value of property strictImageSequence. |
PdfContentByte | text This is the PdfContentByte object, containing the text. |
int | textEmptySize |
protected HashMap | thisBoxSize This is the size of the several boxes of the current Page. |
PdfIndirectReference | thumb |
protected PdfTransition | transition The page transition |
protected PdfViewerPreferencesImp | viewerPreferences Contains the Viewer preferences of this PDF document. |
PdfWriter | writer The PdfWriter . |
Constructor Summary | |
---|---|
PdfDocument()
Constructs a new PDF document. |
Method Summary | |
---|---|
boolean | add(Element element)
Signals that an Element was added to the Document .
|
void | add(Image image)
Adds an image to the document. |
void | add(PdfTable table, boolean onlyFirstPage)
Adds a new table to the document. |
void | addAdditionalAction(PdfName actionType, PdfAction action) |
void | addAnnotation(PdfAnnotation annot) |
void | addCalculationOrder(PdfFormField formField) |
void | addFileAttachment(String description, PdfFileSpecification fs) |
void | addJavaScript(PdfAction js) |
void | addOutline(PdfOutline outline, String name)
Adds a named outline to the document . |
void | addPTable(PdfPTable ptable) Adds a PdfPTable to the document. |
void | addSpacing(float extraspace, float oldleading, Font f)
Adds extra space.
|
void | addViewerPreference(PdfName key, PdfObject value) |
void | addWriter(PdfWriter writer)
Adds a PdfWriter to the PdfDocument .
|
void | analyzeRow(ArrayList rows, PdfDocument.RenderingContext ctx) |
float | bottom(Table table)
Returns the bottomvalue of a Table if it were added to this document.
|
boolean | breakTableIfDoesntFit(PdfTable table) |
void | calculateOutlineCount()
Updates the count in the outlines. |
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.
|
void | consumeRowspan(ArrayList row, PdfDocument.RenderingContext ctx) |
void | doFooter() |
void | doHeader() |
void | ensureNewLine()
Ensures that a new line has been started. |
ArrayList | extractRows(ArrayList cells, PdfDocument.RenderingContext ctx) |
boolean | fitsPage(PdfPTable table, float margin)
Checks if a PdfPTable fits the current page of the PdfDocument .
|
float | flushLines()
Writes all the lines to the text-object.
|
PdfAcroForm | getAcroForm()
Gets the AcroForm object. |
Rectangle | getBoxSize(String boxName)
Gives the size of a trim, art, crop or bleed box, or null if not defined. |
PdfDocument.PdfCatalog | getCatalog(PdfIndirectReference pages)
Gets the PdfCatalog -object.
|
HashMap | getDocumentFileAttachment() |
ArrayList | getDocumentJavaScript() |
PdfDocument.PdfInfo | getInfo()
Gets the PdfInfo -object.
|
PdfAction | getLocalGotoAction(String name) |
int | getMarkPoint() |
PageResources | getPageResources() |
PdfTable | getPdfTable(Table table, boolean supportRowAdditions)
Gets a PdfTable object
(contributed by dperezcar@fcc.es) |
PdfOutline | getRootOutline()
Gets the root outline. |
float | getVerticalPosition(boolean ensureNewLine)
Gets the current vertical page position. |
void | incMarkPoint() |
float | indentBottom()
Gets the indentation on the bottom side.
|
float | indentLeft()
Gets the indentation on the left side.
|
float | indentRight()
Gets the indentation on the right side.
|
float | indentTop()
Gets the indentation on the top side.
|
void | initPage()
Initializes a page.
|
boolean | isStrictImageSequence() Getter for property strictImageSequence. |
boolean | localDestination(String name, PdfDestination destination)
The local destination to where a local goto with the same
name will jump to. |
void | localGoto(String name, float llx, float lly, float urx, float ury)
Implements a link to other part of the document. |
boolean | mayBeRemoved(ArrayList row) |
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.
|
void | outlineTree(PdfOutline outline)
Recursive method used to write outlines. |
void | remoteGoto(String filename, String name, float llx, float lly, float urx, float ury)
Implements a link to another document. |
void | remoteGoto(String filename, int page, float llx, float lly, float urx, float ury)
Implements a link to another document. |
void | renderCells(PdfDocument.RenderingContext ctx, 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. |
void | setAction(PdfAction action, float llx, float lly, float urx, float ury) Implements an action in an area. |
void | setBoxSize(String boxName, Rectangle size) |
void | setCollection(PdfCollection collection)
Sets the collection dictionary. |
void | setCropBoxSize(Rectangle crop) |
void | setDuration(int seconds)
Sets the display duration for the page (for presentations) |
void | setFooter(HeaderFooter footer)
Changes the footer of this document.
|
void | setHeader(HeaderFooter header)
Changes the header of this document.
|
boolean | setMarginMirroring(boolean MarginMirroring) |
boolean | setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
Sets the margins.
|
void | setOpenAction(String name) |
void | setOpenAction(PdfAction action) |
void | setPageAction(PdfName actionType, PdfAction action) |
void | setPageCount(int pageN)
Sets the page number.
|
void | setPageEmpty(boolean pageEmpty) |
void | setPageLabels(PdfPageLabels pageLabels)
Sets the page labels |
boolean | setPageSize(Rectangle pageSize)
Sets the pagesize.
|
void | setSigFlags(int f) |
void | setStrictImageSequence(boolean strictImageSequence) Setter for property strictImageSequence. |
void | setThumbnail(Image image) |
void | setTransition(PdfTransition transition)
Sets the transition for the page |
void | setViewerPreferences(int preferences) |
void | traverseOutlineCount(PdfOutline outline)
Recursive method to update the count in the outlines. |
void | writeLineToContent(PdfLine line, PdfContentByte text, PdfContentByte graphics, Object[] currentValues, float ratio)
Writes a text line to the document. |
void | writeOutlines()
Writes the outline tree to the body of the PDF document. |
PdfAction
when processing an Anchor
.PdfOutline
in the hierarchy of outlines.Object[]{PdfAction,PdfIndirectReference,PdfDestintion}
.PdfWriter
.Throws: DocumentException on error
Element
was added to the Document
.
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
Parameters: image the Image
to add
Throws: PdfException on error DocumentException on error
Parameters: table Table to add. Rendered rows will be deleted after processing. onlyFirstPage Render only the first full page
Throws: DocumentException
Parameters: outline the outline to be added name the name of this local destination
PdfPTable
to the document.Parameters: ptable the PdfPTable
to be added to the document.
Throws: DocumentException on error
See Also: PdfViewerPreferences
PdfWriter
to the PdfDocument
.
Parameters: writer the PdfWriter
that writes everything
what is added to this document to an outputstream.
Throws: DocumentException on error
Deprecated:
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
Deprecated:
Parameters: table Table to add
Returns: true if the table will be broken
Throws: DocumentException
See Also:
(contributed by dperezcar@fcc.es)
Throws: DocumentException on error
PdfPTable
fits the current page of the PdfDocument
.
Parameters: table the table that has to be checked margin a certain margin
Returns: true
if the PdfPTable
fits the page, false
otherwise.
Returns: the displacement that was caused
Throws: DocumentException on error
Returns: the PdfAcroform object of the PdfDocument
Parameters: boxName crop, trim, art or bleed
PdfCatalog
-object.
Parameters: pages an indirect reference to this document pages
Returns: PdfCatalog
PdfInfo
-object.
Returns: PdfInfo
Parameters: table a high level table object supportRowAdditions
Returns: returns a PdfTable object
See Also: getPdfTable
Returns: the root outline
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.
Returns: a margin
Returns: a margin
Returns: a margin
Returns: a margin
If the footer/header is set, it is printed.
Throws: DocumentException on error
Returns: Value of property strictImageSequence.
Parameters: name the name of this local destination destination the PdfDestination
with the jump coordinates
Returns: true
if the local destination was added,
false
if a local destination with the same name
already existed
Parameters: name the name for this link llx the lower left x corner of the activation area lly the lower left y corner of the activation area urx the upper right x corner of the activation area ury the upper right y corner of the activation area
Throws: DocumentException on error
PdfWriter
.
Returns: a boolean
Throws: DocumentException on error
You have to open the document before you can begin to add content to the body of the document.
Parameters: filename the filename for the remote document name the name to jump to llx the lower left x corner of the activation area lly the lower left y corner of the activation area urx the upper right x corner of the activation area ury the upper right y corner of the activation area
Parameters: filename the filename for the remote document page the page to jump to llx the lower left x corner of the activation area lly the lower left y corner of the activation area urx the upper right x corner of the activation area ury the upper right y corner of the activation area
Parameters: action the PdfAction
llx the lower left x corner of the activation area lly the lower left y corner of the activation area urx the upper right x corner of the activation area ury the upper right y corner of the activation area
Parameters: collection a dictionary of type PdfCollection
Parameters: seconds the number of seconds to display the page
Parameters: footer the new footer
Parameters: header the new header
See Also: DocListener
Parameters: marginLeft the margin on the left marginRight the margin on the right marginTop the margin on the top marginBottom the margin on the bottom
Returns: a boolean
Parameters: pageN the new page number
Parameters: pageLabels the page labels
Parameters: pageSize the new pagesize
Returns: true
if the page size was set
Parameters: strictImageSequence New value of property strictImageSequence.
Parameters: transition the PdfTransition object
See Also: PdfViewerPreferences
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 written text the PdfContentByte
where the text will be written to graphics the PdfContentByte
where the graphics will be written to currentValues the current font and extra spacing values ratio
Throws: DocumentException on error