com.lowagie.text.pdf
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
.
Since: 2.0.8 (class was package-private before)
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.
|
protected static class | PdfDocument.RenderingContext
This is a helper class for adding a Table to a document. |
Field Summary | |
---|---|
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 . |
PdfAnnotationsImp | annotationsImp |
protected HashMap | 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 | documentFileAttachment |
protected HashMap | documentLevelJS |
protected int | duration The duration of the page |
protected boolean | firstPageEvent Signals that OnOpenDocument should be called. |
protected PdfContentByte | graphics This is the PdfContentByte object, containing the borders and other Graphics. |
static 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. |
protected boolean | isSectionTitle
Signals that onParagraph is valid (to avoid that a Chapter/Section title is treated as a Paragraph). |
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 ArrayList | lines The lines that are written until now. |
protected 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. |
protected PdfAction | openActionAction |
protected String | openActionName |
protected PdfDictionary | pageAA |
protected 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 boolean | strictImageSequence Holds value of property strictImageSequence. |
protected static DecimalFormat | SIXTEEN_DIGITS |
protected PdfContentByte | text This is the PdfContentByte object, containing the text. |
protected int | textEmptySize |
protected HashMap | thisBoxSize This is the size of the several boxes of the current Page. |
protected PdfIndirectReference | thumb |
protected PdfTransition | transition The page transition |
protected PdfViewerPreferencesImp | viewerPreferences Contains the Viewer preferences of this PDF document. |
protected PdfWriter | writer The PdfWriter . |
protected byte[] | xmpMetadata XMP Metadata for the page. |
Constructor Summary | |
---|---|
PdfDocument()
Constructs a new PDF document. |
Method Summary | |
---|---|
boolean | add(Element element)
Signals that an Element was added to the Document .
|
protected void | add(Image image)
Adds an image 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 | addJavaScript(String name, PdfAction js) |
void | addOutline(PdfOutline outline, String name)
Adds a named outline to the document . |
void | addPdfTable(Table t)
Adds a new table to the document. |
void | addPTable(PdfPTable ptable) Adds a PdfPTable to the document. |
protected 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 .
|
protected void | analyzeRow(ArrayList rows, PdfDocument.RenderingContext ctx) |
float | bottom(Table table)
Returns the bottomvalue of a Table if it were added to this document.
|
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 Stephan |
void | close()
Closes the document.
|
protected void | consumeRowspan(ArrayList row, PdfDocument.RenderingContext ctx) |
protected void | doFooter() |
protected void | doHeader() |
protected void | ensureNewLine()
Ensures that a new line has been started. |
protected ArrayList | extractRows(ArrayList cells, PdfDocument.RenderingContext ctx) |
boolean | fitsPage(PdfPTable table, float margin)
Checks if a PdfPTable fits the current page of the PdfDocument .
|
protected 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() |
HashMap | getDocumentLevelJS() |
PdfDocument.PdfInfo | getInfo()
Gets the PdfInfo -object.
|
float | getLeading()
Getter for the current leading. |
PdfAction | getLocalGotoAction(String name) |
int | getMarkPoint() |
PageResources | getPageResources() |
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.
|
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.
|
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. |
protected boolean | mayBeRemoved(ArrayList 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 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. |
protected 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.
|
protected void | setNewPageSizeAndMargins() |
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 | setXmpMetadata(byte[] xmpMetadata)
Use this method to set the XMP Metadata. |
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.Since: 2.1.2
Since: 2.1.2
Object[]{PdfAction,PdfIndirectReference,PdfDestintion}
.PdfWriter
.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: outline the outline to be added name the name of this local destination
Parameters: t Table to add. Rendered rows will be deleted after processing.
Throws: DocumentException
Since: iText 2.0.8
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
Table
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
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
Returns: the current leading
Since: 2.1.2
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
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
Parameters: xmpMetadata The xmpMetadata to set.
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