|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.fop.pdf.PDFDocument
class representing a PDF document. The document is built up by calling various methods and then finally output to given filehandle using output method. A PDF document consists of a series of numbered objects preceded by a header and followed by an xref table and trailer. The xref table allows for quick access to objects by listing their character positions within the document. For this reason the PDF document must keep track of the character position of each object. The document also keeps direct track of the /Root, /Info and /Resources objects.
Field Summary | |
protected ColorSpace |
colorspace
the colorspace (0=RGB, 1=CMYK) |
protected IDReferences |
idReferences
the documents idReferences |
protected PDFInfo |
info
the /Info object |
protected java.util.Vector |
location
the character position of each object |
protected int |
objectcount
the counter for object numbering |
protected java.util.Vector |
objects
the objects themselves |
protected int |
patternCount
the counter for Pattern name numbering (e.g. |
protected static java.lang.String |
pdfVersion
the version of PDF supported |
protected int |
position
the current character position |
protected PDFResources |
resources
the /Resources object |
protected PDFRoot |
root
the /Root object |
protected int |
shadingCount
the counter for Shading name numbering |
protected int |
xObjectCount
the counter for XObject numbering |
protected java.util.Vector |
xObjects
the XObjects |
protected java.util.Hashtable |
xObjectsMap
the XObjects Map. |
protected int |
xref
character position of xref table |
Constructor Summary | |
PDFDocument()
creates an empty PDF document |
Method Summary | |
int |
addImage(FopImage img)
|
PDFPattern |
createGradient(boolean radial,
ColorSpace theColorspace,
java.util.Vector theColors,
java.util.Vector theBounds,
java.util.Vector theCoords)
|
int |
getColorSpace()
|
PDFResources |
getResources()
get the /Resources object for the document |
PDFAnnotList |
makeAnnotList()
make an annotation list object |
PDFArray |
makeArray(int[] values)
make an Array object (ex. |
PDFEncoding |
makeEncoding(java.lang.String encodingName)
make a /Encoding object |
PDFFont |
makeFont(java.lang.String fontname,
java.lang.String basefont,
java.lang.String encoding,
FontMetric metrics,
FontDescriptor descriptor)
make a Type1 /Font object |
PDFFontDescriptor |
makeFontDescriptor(FontDescriptor desc)
make a /FontDescriptor object for a CID font |
PDFFunction |
makeFunction(int theNumber,
int theFunctionType,
java.util.Vector theDomain,
java.util.Vector theRange,
java.lang.StringBuffer theFunctionDataStream)
make a postscript calculator function |
PDFFunction |
makeFunction(int theFunctionType,
java.util.Vector theDomain,
java.util.Vector theRange,
java.util.Vector theSize,
int theBitsPerSample,
int theOrder,
java.util.Vector theEncode,
java.util.Vector theDecode,
java.lang.StringBuffer theFunctionDataStream,
java.util.Vector theFilter)
Make a Type 0 sampled function |
PDFFunction |
makeFunction(int theFunctionType,
java.util.Vector theDomain,
java.util.Vector theRange,
java.util.Vector theCZero,
java.util.Vector theCOne,
double theInterpolationExponentN)
make a type Exponential interpolation function (for shading usually) |
PDFFunction |
makeFunction(int theFunctionType,
java.util.Vector theDomain,
java.util.Vector theRange,
java.util.Vector theFunctions,
java.util.Vector theBounds,
java.util.Vector theEncode)
Make a Type 3 Stitching function |
protected PDFInfo |
makeInfo()
make an /Info object |
PDFLink |
makeLink(java.awt.Rectangle rect,
java.lang.String destination,
int linkType)
make a link object |
PDFOutline |
makeOutline(PDFOutline parent,
java.lang.String label,
java.lang.String destination)
Make an outline object and add it to the given outline |
PDFOutline |
makeOutlineRoot()
Make the root Outlines object |
PDFPage |
makePage(PDFResources resources,
PDFStream contents,
int pagewidth,
int pageheight,
Page currentPage)
make a /Page object |
PDFPattern |
makePattern(int thePatternType,
PDFResources theResources,
int thePaintType,
int theTilingType,
java.util.Vector theBBox,
double theXStep,
double theYStep,
java.util.Vector theMatrix,
java.util.Vector theXUID,
java.lang.StringBuffer thePatternDataStream)
Make a tiling pattern |
PDFPattern |
makePattern(int thePatternType,
PDFShading theShading,
java.util.Vector theXUID,
java.lang.StringBuffer theExtGState,
java.util.Vector theMatrix)
Make a smooth shading pattern |
protected PDFRoot |
makeRoot()
make /Root object as next object |
PDFShading |
makeShading(int theShadingType,
ColorSpace theColorSpace,
java.util.Vector theBackground,
java.util.Vector theBBox,
boolean theAntiAlias,
int theBitsPerCoordinate,
int theBitsPerComponent,
int theBitsPerFlag,
java.util.Vector theDecode,
PDFFunction theFunction)
Make a free-form gouraud shaded triangle mesh, coons patch mesh, or tensor patch mesh shading object |
PDFShading |
makeShading(int theShadingType,
ColorSpace theColorSpace,
java.util.Vector theBackground,
java.util.Vector theBBox,
boolean theAntiAlias,
int theBitsPerCoordinate,
int theBitsPerComponent,
java.util.Vector theDecode,
int theVerticesPerRow,
PDFFunction theFunction)
make a Lattice-Form Gouraud mesh shading object |
PDFShading |
makeShading(int theShadingType,
ColorSpace theColorSpace,
java.util.Vector theBackground,
java.util.Vector theBBox,
boolean theAntiAlias,
java.util.Vector theDomain,
java.util.Vector theMatrix,
PDFFunction theFunction)
make a function based shading object |
PDFShading |
makeShading(int theShadingType,
ColorSpace theColorSpace,
java.util.Vector theBackground,
java.util.Vector theBBox,
boolean theAntiAlias,
java.util.Vector theCoords,
java.util.Vector theDomain,
PDFFunction theFunction,
java.util.Vector theExtend)
Make an axial or radial shading object. |
PDFStream |
makeStream()
make a stream object |
void |
output(java.io.OutputStream stream)
write the entire document out |
protected int |
outputHeader(java.io.OutputStream stream)
write the PDF header |
protected void |
outputTrailer(java.io.OutputStream stream)
write the trailer |
void |
setColorSpace(int theColorspace)
|
void |
setIDReferences(IDReferences idReferences)
|
void |
setProducer(java.lang.String producer)
set the producer of the document |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected static final java.lang.String pdfVersion
protected int position
protected java.util.Vector location
protected int objectcount
protected java.util.Vector objects
protected int xref
protected PDFRoot root
protected PDFInfo info
protected PDFResources resources
protected IDReferences idReferences
protected ColorSpace colorspace
protected int patternCount
protected int shadingCount
protected int xObjectCount
protected java.util.Vector xObjects
protected java.util.Hashtable xObjectsMap
Constructor Detail |
public PDFDocument()
Method Detail |
public void setProducer(java.lang.String producer)
producer
- string indicating application producing the PDFprotected PDFRoot makeRoot()
protected PDFInfo makeInfo()
producer
- string indicating application producing the PDFpublic PDFFunction makeFunction(int theFunctionType, java.util.Vector theDomain, java.util.Vector theRange, java.util.Vector theSize, int theBitsPerSample, int theOrder, java.util.Vector theEncode, java.util.Vector theDecode, java.lang.StringBuffer theFunctionDataStream, java.util.Vector theFilter)
theDomain
- Vector objects of Double objects.
This is the domain of the function.
See page 264 of the PDF 1.3 Spec.theRange
- Vector objects of Double objects.
This is the Range of the function.
See page 264 of the PDF 1.3 Spec.theSize
- A Vector object of Integer objects.
This is the number of samples in each input dimension.
I can't imagine there being more or less than two input dimensions,
so maybe this should be an array of length 2.
See page 265 of the PDF 1.3 Spec.theBitsPerSample
- An int specifying the number of bits user to represent each sample value.
Limited to 1,2,4,8,12,16,24 or 32.
See page 265 of the 1.3 PDF Spec.theOrder
- The order of interpolation between samples. Default is 1 (one). Limited
to 1 (one) or 3, which means linear or cubic-spline interpolation.
This attribute is optional.
See page 265 in the PDF 1.3 spec.theEncode
- Vector objects of Double objects.
This is the linear mapping of input values intop the domain
of the function's sample table. Default is hard to represent in
ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
This attribute is optional.
See page 265 in the PDF 1.3 spec.theDecode
- Vector objects of Double objects.
This is a linear mapping of sample values into the range.
The default is just the range.
This attribute is optional.
Read about it on page 265 of the PDF 1.3 spec.theFunctionDataStream
- The sample values that specify the function are provided in a stream.
This is optional, but is almost always used.
Page 265 of the PDF 1.3 spec has more.theFilter
- This is a vector of String objects which are the various filters that
have are to be applied to the stream to make sense of it. Order matters,
so watch out.
This is not documented in the Function section of the PDF 1.3 spec,
it was deduced from samples that this is sometimes used, even if we may never
use it in FOP. It is added for completeness sake.theNumber
- The object number of this PDF object.theFunctionType
- This is the type of function (0,2,3, or 4).
It should be 0 as this is the constructor for sampled functions.public PDFFunction makeFunction(int theFunctionType, java.util.Vector theDomain, java.util.Vector theRange, java.util.Vector theCZero, java.util.Vector theCOne, double theInterpolationExponentN)
theDomain
- Vector objects of Double objects.
This is the domain of the function.
See page 264 of the PDF 1.3 Spec.theRange
- Vector of Doubles that is the Range of the function.
See page 264 of the PDF 1.3 Spec.theCZero
- This is a vector of Double objects which defines the function result
when x=0.
This attribute is optional.
It's described on page 268 of the PDF 1.3 spec.theCOne
- This is a vector of Double objects which defines the function result
when x=1.
This attribute is optional.
It's described on page 268 of the PDF 1.3 spec.theInterpolationExponentN
- This is the inerpolation exponent.
This attribute is required.
PDF Spec page 268theFunctionType
- The type of the function, which should be 2.public PDFFunction makeFunction(int theFunctionType, java.util.Vector theDomain, java.util.Vector theRange, java.util.Vector theFunctions, java.util.Vector theBounds, java.util.Vector theEncode)
theDomain
- Vector objects of Double objects.
This is the domain of the function.
See page 264 of the PDF 1.3 Spec.theRange
- Vector objects of Double objects.
This is the Range of the function.
See page 264 of the PDF 1.3 Spec.theFunctions
- A Vector of the PDFFunction objects that the stitching function stitches.
This attributed is required.
It is described on page 269 of the PDF spec.theBounds
- This is a vector of Doubles representing the numbers that,
in conjunction with Domain define the intervals to which each function from
the 'functions' object applies. It must be in order of increasing magnitude,
and each must be within Domain.
It basically sets how much of the gradient each function handles.
This attributed is required.
It's described on page 269 of the PDF 1.3 spec.theEncode
- Vector objects of Double objects.
This is the linear mapping of input values intop the domain
of the function's sample table. Default is hard to represent in
ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
This attribute is required.
See page 270 in the PDF 1.3 spec.theFunctionType
- This is the function type. It should be 3,
for a stitching function.public PDFFunction makeFunction(int theNumber, int theFunctionType, java.util.Vector theDomain, java.util.Vector theRange, java.lang.StringBuffer theFunctionDataStream)
theNumber
- theFunctionType
- theDomain
- theRange
- theFunctionDataStream
- public PDFShading makeShading(int theShadingType, ColorSpace theColorSpace, java.util.Vector theBackground, java.util.Vector theBBox, boolean theAntiAlias, java.util.Vector theDomain, java.util.Vector theMatrix, PDFFunction theFunction)
theShadingType
- The type of shading object, which should be 1 for function
based shading.theColorSpace
- The colorspace is 'DeviceRGB' or something similar.theBackground
- An array of color components appropriate to the
colorspace key specifying a single color value.
This key is used by the f operator buy ignored by the sh operator.theBBox
- Vector of double's representing a rectangle
in the coordinate space that is current at the
time of shading is imaged. Temporary clipping
boundary.theAntiAlias
- Whether or not to anti-alias.theDomain
- Optional vector of Doubles specifying the domain.theMatrix
- Vector of Doubles specifying the matrix.
If it's a pattern, then the matrix maps it to pattern space.
If it's a shading, then it maps it to current user space.
It's optional, the default is the identity matrixtheFunction
- The PDF Function that maps an (x,y) location to a colorpublic PDFShading makeShading(int theShadingType, ColorSpace theColorSpace, java.util.Vector theBackground, java.util.Vector theBBox, boolean theAntiAlias, java.util.Vector theCoords, java.util.Vector theDomain, PDFFunction theFunction, java.util.Vector theExtend)
theShadingType
- 2 or 3 for axial or radial shadingtheColorSpace
- "DeviceRGB" or similar.theBackground
- theBackground An array of color components appropriate to the
colorspace key specifying a single color value.
This key is used by the f operator buy ignored by the sh operator.theBBox
- Vector of double's representing a rectangle
in the coordinate space that is current at the
time of shading is imaged. Temporary clipping
boundary.theAntiAlias
- Default is falsetheCoords
- Vector of four (type 2) or 6 (type 3) DoubletheDomain
- Vector of Doubles specifying the domaintheFunction
- the Stitching (PDFfunction type 3) function, even if it's stitching a single functiontheExtend
- Vector of Booleans of whether to extend teh start and end colors past the start and end points
The default is [false, false]public PDFShading makeShading(int theShadingType, ColorSpace theColorSpace, java.util.Vector theBackground, java.util.Vector theBBox, boolean theAntiAlias, int theBitsPerCoordinate, int theBitsPerComponent, int theBitsPerFlag, java.util.Vector theDecode, PDFFunction theFunction)
theShadingType
- 4, 6, or 7 depending on whether it's
Free-form gouraud-shaded triangle meshes, coons patch meshes,
or tensor product patch meshes, respectively.theColorSpace
- "DeviceRGB" or similar.theBackground
- theBackground An array of color components appropriate to the
colorspace key specifying a single color value.
This key is used by the f operator buy ignored by the sh operator.theBBox
- Vector of double's representing a rectangle
in the coordinate space that is current at the
time of shading is imaged. Temporary clipping
boundary.theAntiAlias
- Default is falsetheBitsPerCoordinate
- 1,2,4,8,12,16,24 or 32.theBitsPerComponent
- 1,2,4,8,12, and 16theBitsPerFlag
- 2,4,8.theDecode
- Vector of Doubles see PDF 1.3 spec pages 303 to 312.theFunction
- the PDFFunctionpublic PDFShading makeShading(int theShadingType, ColorSpace theColorSpace, java.util.Vector theBackground, java.util.Vector theBBox, boolean theAntiAlias, int theBitsPerCoordinate, int theBitsPerComponent, java.util.Vector theDecode, int theVerticesPerRow, PDFFunction theFunction)
theShadingType
- 5 for lattice-Form Gouraud shaded-triangle mesh
without spaces. "Shading1" or "Sh1" are good examples.theColorSpace
- "DeviceRGB" or similar.theBackground
- theBackground An array of color components appropriate to the
colorspace key specifying a single color value.
This key is used by the f operator buy ignored by the sh operator.theBBox
- Vector of double's representing a rectangle
in the coordinate space that is current at the
time of shading is imaged. Temporary clipping
boundary.theAntiAlias
- Default is falsetheBitsPerCoordinate
- 1,2,4,8,12,16, 24, or 32theBitsPerComponent
- 1,2,4,8,12,24,32theDecode
- Vector of Doubles. See page 305 in PDF 1.3 spec.theVerticesPerRow
- number of vertices in each "row" of the lattice.theFunction
- The PDFFunction that's mapped on to this shapepublic PDFPattern makePattern(int thePatternType, PDFResources theResources, int thePaintType, int theTilingType, java.util.Vector theBBox, double theXStep, double theYStep, java.util.Vector theMatrix, java.util.Vector theXUID, java.lang.StringBuffer thePatternDataStream)
thePatternType
- the type of pattern, which is 1 for tiling.theResources
- the resources associated with this patternthePaintType
- 1 or 2, colored or uncolored.theTilingType
- 1, 2, or 3, constant spacing, no distortion, or faster tilingtheBBox
- Vector of Doubles: The pattern cell bounding boxtheXStep
- horizontal spacingtheYStep
- vertical spacingtheMatrix
- Optional Vector of Doubles transformation matrixtheXUID
- Optional vector of Integers that uniquely identify the patternthePatternDataStream
- The stream of pattern data to be tiled.public PDFPattern makePattern(int thePatternType, PDFShading theShading, java.util.Vector theXUID, java.lang.StringBuffer theExtGState, java.util.Vector theMatrix)
thePatternType
- the type of the pattern, which is 2, smooth shadingtheShading
- the PDF Shading object that comprises this patterntheXUID
- optional:the extended unique Identifier if used.theExtGState
- optional: the extended graphics state, if used.theMatrix
- Optional:Vector of Doubles that specify the matrix.public int getColorSpace()
public void setColorSpace(int theColorspace)
public PDFPattern createGradient(boolean radial, ColorSpace theColorspace, java.util.Vector theColors, java.util.Vector theBounds, java.util.Vector theCoords)
public PDFEncoding makeEncoding(java.lang.String encodingName)
encodingName
- character encoding scheme namepublic PDFFont makeFont(java.lang.String fontname, java.lang.String basefont, java.lang.String encoding, FontMetric metrics, FontDescriptor descriptor)
fontname
- internal name to use for this font (eg "F1")basefont
- name of the base font (eg "Helvetica")encoding
- character encoding scheme used by the fontmetrics
- additional information about the fontdescriptor
- additional information about the fontpublic PDFFontDescriptor makeFontDescriptor(FontDescriptor desc)
public PDFArray makeArray(int[] values)
public int addImage(FopImage img)
public PDFPage makePage(PDFResources resources, PDFStream contents, int pagewidth, int pageheight, Page currentPage)
resources
- resources object to usecontents
- stream object with contentpagewidth
- width of the page in pointspageheight
- height of the page in pointspublic PDFLink makeLink(java.awt.Rectangle rect, java.lang.String destination, int linkType)
rect
- the clickable rectangledestination
- the destination filelinkType
- the link typepublic PDFStream makeStream()
public PDFAnnotList makeAnnotList()
public PDFOutline makeOutlineRoot()
public PDFOutline makeOutline(PDFOutline parent, java.lang.String label, java.lang.String destination)
parent
- parent PDFOutline objectlabel
- the title for the new outline objectaction
- the PDFAction to referencepublic PDFResources getResources()
public void output(java.io.OutputStream stream) throws java.io.IOException
writer
- the OutputStream to output the document toprotected int outputHeader(java.io.OutputStream stream) throws java.io.IOException
stream
- the OutputStream to write the header toprotected void outputTrailer(java.io.OutputStream stream) throws java.io.IOException
stream
- the OutputStream to write the trailer topublic void setIDReferences(IDReferences idReferences)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |