Package org.openpdf.text.pdf
Class PdfDocument
java.lang.Object
org.openpdf.text.Document
org.openpdf.text.pdf.PdfDocument
- All Implemented Interfaces:
AutoCloseable,EventListener,DocListener,ElementListener
PdfDocument is the class that is used by PdfWriter to translate a Document
into a PDF with different pages.
This pruned version only manages pages (that are filled by the content of the writer), the information dictionary, the catalog and the annotations of the pages. The layout of text, tables and images is not supported.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMeta information of the document. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HashMap<String, PdfRectangle> protected PdfContentByteprotected PdfDocument.PdfInfoThe info dictionary.protected org.openpdf.text.pdf.PageResourcesThe resources of the current page.protected PdfContentByteThePdfContentByteobject that contains the text, the graphics and the images of the page.protected HashMap<String, PdfRectangle> The boxes of the pages (crop box...).protected PdfWriterThe writer associated to this document.Fields inherited from class org.openpdf.text.Document
close, compress, marginBottom, marginLeft, marginRight, marginTop, open, pageN, pageSize, plainRandomAccess -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanSignals that anElementwas added to theDocument.voidAdds aPdfWriterto thePdfDocument.voidclose()Closes the document.protected PdfDocument.PdfInfogetInfo()Gets the info dictionary.protected voidinitPage()Initializes a page.booleannewPage()Makes a new page and sends it to thePdfWriter.voidopen()Opens the document.booleansetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom) Sets the margins.protected voidbooleansetPageSize(Rectangle pageSize) Sets the pagesize.Methods inherited from class org.openpdf.text.Document
addAuthor, addCreationDate, addCreationDate, addDocListener, addModificationDate, addProducer, addProducer, addSubject, addTitle, getTextRenderingOptions, getVersion, isOpen, setTextRenderingOptions
-
Field Details
-
writer
The writer associated to this document. -
text
ThePdfContentByteobject that contains the text, the graphics and the images of the page. -
graphics
-
info
The info dictionary. -
thisBoxSize
The boxes of the pages (crop box...). -
boxSize
-
pageResources
protected org.openpdf.text.pdf.PageResources pageResourcesThe resources of the current page.
-
-
Constructor Details
-
PdfDocument
public PdfDocument()Constructs a new PDF document.
-
-
Method Details
-
addWriter
Adds aPdfWriterto thePdfDocument.- Parameters:
writer- thePdfWriter- Throws:
DocumentException- on error
-
open
public void open()Opens the document.- Specified by:
openin interfaceDocListener- Overrides:
openin classDocument
-
close
public void close()Closes the document.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDocListener- Overrides:
closein classDocument
-
add
Signals that anElementwas added to theDocument. Only the meta information is supported by this pruned version.- 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
-
newPage
public boolean newPage()Makes a new page and sends it to thePdfWriter.- Specified by:
newPagein interfaceDocListener- Overrides:
newPagein classDocument- Returns:
- a
boolean
-
setPageSize
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
-
initPage
Initializes a page.- Throws:
DocumentException- on error
-
setNewPageSizeAndMargins
protected void setNewPageSizeAndMargins() -
getInfo
Gets the info dictionary.- Returns:
- the info dictionary
-