Class PDFDocument
- java.lang.Object
-
- pdf.PDFDocument
-
- All Implemented Interfaces:
java.io.Serializable
public class PDFDocument extends java.lang.Object implements java.io.SerializableRepresents a PDF document with functionalities to manage PDF objects, pages, fonts, images, and document metadata.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected PDFObjectdefaultOutlineBorderThis holds a PDFObject describing the default border for annotations.static intFULLSCREENThis page mode indicates that when the document is opened, it is displayed in full-screen-mode.protected java.util.Vector<PDFObject>objectsThis vector contains each indirect object within the document.protected intobjserstatic java.lang.String[]PDF_PAGE_MODESThese map the page modes just defined to the pagemodes setting of PDF.static intUSENONEThis page mode indicates that the document should be opened just with the page visible.static intUSEOUTLINESThis page mode indicates that the Outlines should also be displayed when the document is opened.static intUSETHUMBSThis page mode indicates that the Thumbnails should be visible when the document first opens.
-
Constructor Summary
Constructors Constructor Description PDFDocument()This creates a PDF document with the default pagemodePDFDocument(int pagemode)This creates a PDF document
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intadd(PDFObject obj)This adds a top level object to the document.PDFFontgetFont(java.lang.String type, java.lang.String font, int style)This returns a font of the specified type and font.PDFOutlinegetOutline()PDFPagegetPage(int page)This returns a specific page.PDFInfogetPDFInfo()Get the PDFInfo object, which contains author, title, keywords, etcjava.lang.StringsetImageName(PDFImage img)Sets a unique name to a PDFImagevoidsetPDFInfo(PDFInfo info)Set the PDFInfo object, which contains author, title, keywords, etcvoidwrite(java.io.OutputStream os)
-
-
-
Field Detail
-
objser
protected int objser
-
objects
protected java.util.Vector<PDFObject> objects
This vector contains each indirect object within the document.
-
defaultOutlineBorder
protected PDFObject defaultOutlineBorder
This holds a PDFObject describing the default border for annotations. It's only used when the document is being written.
-
USENONE
public static final int USENONE
This page mode indicates that the document should be opened just with the page visible. This is the default
- See Also:
- Constant Field Values
-
USEOUTLINES
public static final int USEOUTLINES
This page mode indicates that the Outlines should also be displayed when the document is opened.
- See Also:
- Constant Field Values
-
USETHUMBS
public static final int USETHUMBS
This page mode indicates that the Thumbnails should be visible when the document first opens.
- See Also:
- Constant Field Values
-
FULLSCREEN
public static final int FULLSCREEN
This page mode indicates that when the document is opened, it is displayed in full-screen-mode. There is no menu bar, window controls nor any other window present.
- See Also:
- Constant Field Values
-
PDF_PAGE_MODES
public static final java.lang.String[] PDF_PAGE_MODES
These map the page modes just defined to the pagemodes setting of PDF.
-
-
Method Detail
-
add
public int add(PDFObject obj)
This adds a top level object to the document.Once added, it is allocated a unique serial number.
Note: Not all object are added directly using this method. Some objects which have Kids (in PDF sub-objects or children are called Kids) will have their own add() method, which will call this one internally.
- Parameters:
obj- The PDFObject to add to the document- Returns:
- the unique serial number for this object.
-
getPage
public PDFPage getPage(int page)
This returns a specific page. It's used mainly when using a Serialized template file.
?? How does a serialized template file work ???- Parameters:
page- page number to return- Returns:
- PDFPage at that position
-
getOutline
public PDFOutline getOutline()
- Returns:
- the root outline
-
getFont
public PDFFont getFont(java.lang.String type, java.lang.String font, int style)
This returns a font of the specified type and font. If the font has not been defined, it creates a new font in the PDF document, and returns it.- Parameters:
type- PDF Font Type - usually "/Type1"font- Java font namestyle- java.awt.Font style (NORMAL, BOLD etc)- Returns:
- PDFFont defining this font
-
setImageName
public java.lang.String setImageName(PDFImage img)
Sets a unique name to a PDFImage- Parameters:
img- PDFImage to set the name of- Returns:
- the name given to the image
-
setPDFInfo
public void setPDFInfo(PDFInfo info)
Set the PDFInfo object, which contains author, title, keywords, etc
- Parameters:
info- a PDFInof object
-
getPDFInfo
public PDFInfo getPDFInfo()
Get the PDFInfo object, which contains author, title, keywords, etc
- Returns:
- the PDFInfo object for this document.
-
write
public void write(java.io.OutputStream os) throws java.io.IOException- Throws:
java.io.IOException
-
-