|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.PrintJob gnu.jpdf.PDFJob
public class PDFJob
This class extends awt's PrintJob, to provide a simple method of writing PDF documents.
You can use this with any code that uses Java's printing mechanism. It does include a few extra methods to provide access to some of PDF's features like annotations, or outlines.
Field Summary | |
---|---|
protected java.io.OutputStream |
os
This is the OutputStream the PDF file will be written to when complete Note: This is transient, as it's not valid after being Serialized. |
protected PDFPage |
page
This is the current page being constructed by the last getGraphics() call |
protected int |
pagenum
This is the page number of the current page |
protected PDFDocument |
pdfDocument
This is the PDF file being constructed |
Constructor Summary | |
---|---|
PDFJob()
This constructs the job. |
|
PDFJob(java.io.OutputStream os)
This constructs the job. |
|
PDFJob(java.io.OutputStream os,
java.lang.String title)
This constructs the job. |
Method Summary | |
---|---|
PDFAnnot |
addNote(java.lang.String note,
int x,
int y,
int w,
int h)
Convenience method: Adds a text note to the document. |
PDFOutline |
addOutline(java.lang.String title)
This method attaches an outline to the current page being generated. |
PDFOutline |
addOutline(java.lang.String title,
int x,
int y,
int w,
int h)
This method attaches an outline to the current page being generated. |
void |
end()
This writes the PDF document to the OutputStream, finishing the document. |
PDFPage |
getCurrentPage()
Returns the current PDFPage being worked on. |
int |
getCurrentPageNumber()
Returns the current page number. |
java.awt.Graphics |
getGraphics()
This returns a graphics object that can be used to draw on a page. |
java.awt.Graphics |
getGraphics(int orient)
This returns a graphics object that can be used to draw on a page. |
java.awt.Dimension |
getPageDimension()
Returns the page dimension |
int |
getPageResolution()
This returns the page resolution. |
PDFDocument |
getPDFDocument()
Returns the PDFDocument object for this document. |
boolean |
lastPageFirst()
In AWT's PrintJob, this would return true if the user requested that the file is printed in reverse order. |
Methods inherited from class java.awt.PrintJob |
---|
finalize |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected transient java.io.OutputStream os
protected PDFDocument pdfDocument
protected PDFPage page
protected int pagenum
Constructor Detail |
---|
public PDFJob()
This constructs the job. This method must be used when creating a template pdf file, ie one that is Serialised by one application, and then restored by another.
ezb 20011115 - Haven't done anything with templates yet, don't know how/if they are implemented
public PDFJob(java.io.OutputStream os)
This constructs the job. This is the primary constructor that will be used for creating pdf documents with this package. The specified output stream is a handle to the .pdf file you wish to create.
os
- - OutputStream
to use for the pdf outputpublic PDFJob(java.io.OutputStream os, java.lang.String title)
This constructs the job. This is the primary constructor that will be used for creating pdf documents with this package. The specified output stream is a handle to the .pdf file you wish to create.
Use this constructor if you want to give the pdf document a name other than the default of "PDF Doc"
os
- - OutputStream
to use for the pdf outputtitle
- a String
valueMethod Detail |
---|
public java.awt.Graphics getGraphics(int orient)
This returns a graphics object that can be used to draw on a page. In PDF, this will be a new page within the document.
orient
- - the int
Orientation of the new page,
as defined in PDFPage
PDFPage.PORTRAIT
,
PDFPage.LANDSCAPE
,
PDFPage.INVERTEDPORTRAIT
,
PDFPage.SEASCAPE
public void end()
This writes the PDF document to the OutputStream, finishing the document.
end
in class java.awt.PrintJob
public java.awt.Graphics getGraphics()
This returns a graphics object that can be used to draw on a page. In PDF, this will be a new page within the document.
This new page will by default be oriented as a portrait
getGraphics
in class java.awt.PrintJob
Graphics
object to draw to.public java.awt.Dimension getPageDimension()
Returns the page dimension
getPageDimension
in class java.awt.PrintJob
Dimension
instance, the size of the pagepublic int getPageResolution()
This is the PDF (and Postscript) device resolution of 72 dpi (equivalent to 1 point).
getPageResolution
in class java.awt.PrintJob
int
, the resolution in pixels per inchpublic boolean lastPageFirst()
In AWT's PrintJob, this would return true if the user requested that the file is printed in reverse order. For PDF's this is not applicable, so it will always return false.
lastPageFirst
in class java.awt.PrintJob
public PDFDocument getPDFDocument()
public PDFPage getCurrentPage()
Returns the current PDFPage being worked on. Useful for working on Annotations (like links), etc.
PDFPage
currently being constructedpublic int getCurrentPageNumber()
Returns the current page number. Useful if you need to include one in the document
int
current page numberpublic PDFOutline addOutline(java.lang.String title)
This method attaches an outline to the current page being generated. When selected, the outline displays the top of the page.
title
- a String
, the title of the Outline
PDFOutline
object that was created,
for adding sub-outline's if required.public PDFOutline addOutline(java.lang.String title, int x, int y, int w, int h)
This method attaches an outline to the current page being generated. When selected, the outline displays the specified region.
title
- Outline title to attachx
- Left coordinate of regiony
- Top coordinate of regionw
- width of regionh
- height of region
PDFOutline
object created,
for adding sub-outline's if required.public PDFAnnot addNote(java.lang.String note, int x, int y, int w, int h)
note
- Text of the notex
- Coordinate of notey
- Coordinate of notew
- Width of the noteh
- Height of the note
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |