|
fop 0.95 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.fop.render.AbstractRenderer
org.apache.fop.render.PrintRenderer
org.apache.fop.render.AbstractPathOrientedRenderer
org.apache.fop.render.pdf.PDFRenderer
public class PDFRenderer
Renderer that renders areas to PDF.
Field Summary | |
---|---|
protected PDFResourceContext |
currentContext
the current annotation list to add annotations to |
protected java.lang.String |
currentFontName
Name of currently selected font |
protected int |
currentFontSize
Size of currently selected font |
protected PDFPage |
currentPage
the current page to add annotations to |
protected java.lang.String |
currentPageRef
the current page's PDF reference string (to avoid numerous function calls) |
protected PDFState |
currentState
drawing state |
protected PDFStream |
currentStream
the current stream to add PDF commands to |
protected boolean |
disableSRGBColorSpace
controls whether the sRGB color space should be installed |
static java.lang.String |
ENCRYPTION_PARAMS
PDF encryption parameter: all parameters as object, datatype: PDFEncryptionParams |
protected PDFEncryptionParams |
encryptionParams
the (optional) encryption parameters |
protected java.util.Map |
filterMap
Registry of PDF filters |
protected java.util.Map |
idGoTos
Maps XSL-FO element IDs to PDFGoTo objects targeting the corresponding areas These objects may not all be fully filled in yet |
protected java.util.Map |
idPositions
Maps XSL-FO element IDs to their on-page XY-positions Must be used in conjunction with the page reference to fully specify the PDFGoTo details |
protected boolean |
inTextMode
true if a BT command has been written. |
static java.lang.String |
KEY_DISABLE_SRGB_COLORSPACE
Rendering Options key for disabling the sRGB color space (only possible if no PDF/A or PDF/X profile is active). |
static java.lang.String |
KEY_OUTPUT_PROFILE
Rendering Options key for the ICC profile for the output intent. |
static java.lang.String |
MIME_TYPE
The mime type for pdf |
static java.lang.String |
NO_ANNOTATIONS
PDF encryption parameter: Forbids annotations, datatype: Boolean or "true"/"false" |
static java.lang.String |
NO_COPY_CONTENT
PDF encryption parameter: Forbids copying content, datatype: Boolean or "true"/"false" |
static java.lang.String |
NO_EDIT_CONTENT
PDF encryption parameter: Forbids editing content, datatype: Boolean or "true"/"false" |
static java.lang.String |
NO_PRINT
PDF encryption parameter: Forbids printing, datatype: Boolean or "true"/"false" |
static int |
NORMAL_PDF_RESOLUTION
Normal PDF resolution (72dpi) |
protected java.io.OutputStream |
ostream
The output stream to write the document to |
protected PDFICCStream |
outputProfile
the ICC stream used as output profile by this document for PDF/A and PDF/X functionality. |
protected java.lang.String |
outputProfileURI
Optional URI to an output profile to be used. |
static java.lang.String |
OWNER_PASSWORD
PDF encryption parameter: owner password, datatype: String |
protected int |
pageHeight
page height |
protected java.util.Map |
pageReferences
Maps unique PageViewport key to PDF page reference |
protected java.util.Map |
pages
Map of pages using the PageViewport as the key this is used for prepared pages that cannot be immediately rendered |
static java.lang.String |
PDF_A_MODE
Rendering Options key for the PDF/A mode. |
static java.lang.String |
PDF_X_MODE
Rendering Options key for the PDF/X mode. |
protected PDFAMode |
pdfAMode
the PDF/A mode (Default: disabled) |
protected PDFDocument |
pdfDoc
the PDF Document being created |
protected PDFResources |
pdfResources
the /Resources object of the PDF document being created |
protected PDFXMode |
pdfXMode
the PDF/X mode (Default: disabled) |
protected java.util.Map |
pvReferences
Maps unique PageViewport key back to PageViewport itself |
protected PDFICCBasedColorSpace |
sRGBColorSpace
the default sRGB color space. |
protected java.util.List |
unfinishedGoTos
The PDFGoTos in idGoTos that are not complete yet |
static java.lang.String |
USER_PASSWORD
PDF encryption parameter: user password, datatype: String |
protected static boolean |
WRITE_COMMENTS
Controls whether comments are written to the PDF stream. |
Fields inherited from class org.apache.fop.render.PrintRenderer |
---|
fontInfo, fontList, fontResolver |
Fields inherited from class org.apache.fop.render.AbstractRenderer |
---|
containingBPPosition, containingIPPosition, currentBPPosition, currentIPPosition, currentPageViewport, log, userAgent |
Fields inherited from interface org.apache.fop.render.Renderer |
---|
ROLE |
Constructor Summary | |
---|---|
PDFRenderer()
create the PDF renderer |
Method Summary | |
---|---|
protected void |
beginTextObject()
Indicates the beginning of a text object. |
protected java.util.List |
breakOutOfStateStack()
Breaks out of the state stack to handle fixed block-containers. |
protected void |
clip()
Clip an area. |
protected void |
clipRect(float x,
float y,
float width,
float height)
Clip using a rectangular area. |
protected void |
closePath()
Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath. |
protected void |
closeText()
Checks to see if we have some text rendering commands open still and writes out the TJ command to the stream if we do |
protected void |
comment(java.lang.String text)
writes out a comment. |
protected void |
concatenateTransformationMatrix(java.awt.geom.AffineTransform at)
Concatenates the current transformation matrix with the given one, therefore establishing a new coordinate system. |
protected RendererContext |
createRendererContext(int x,
int y,
int width,
int height,
java.util.Map foreignAttributes)
Creates a RendererContext for an image. |
protected void |
drawBorderLine(float x1,
float y1,
float x2,
float y2,
boolean horz,
boolean startOrBefore,
int style,
java.awt.Color col)
Draw a border segment of an XSL-FO style border. |
protected void |
drawImage(java.lang.String url,
java.awt.geom.Rectangle2D pos,
java.util.Map foreignAttributes)
Draw an image at the indicated location. |
protected void |
endTextObject()
Indicates the end of a text object. |
protected void |
endVParea()
Signals exit from a viewport area. |
void |
escapeText(java.lang.String s,
int[] letterAdjust,
Font fs,
AbstractTextArea parentArea,
boolean useMultiByte,
java.lang.StringBuffer pdf)
Escapes text according to PDF rules. |
protected void |
fillRect(float x,
float y,
float w,
float h)
Fill a rectangular area. |
protected void |
finishIDGoTo(PDFGoTo gt,
java.awt.geom.Point2D.Float position)
Set XY position in the PDFGoTo and add it to the PDF trailer. |
protected void |
finishIDGoTo(PDFGoTo gt,
java.lang.String pdfPageRef,
java.awt.geom.Point2D.Float position)
Set page reference and XY position in the PDFGoTo and add it to the PDF trailer. |
protected void |
finishOpenGoTos()
Checks if there are any unfinished PDFGoTos left in the list and resolves them to a default position on the page. |
protected static java.lang.String |
format(float value)
Formats a float value (normally coordinates) as Strings. |
Graphics2DAdapter |
getGraphics2DAdapter()
|
java.lang.String |
getMimeType()
Get the MIME type of the renderer. |
protected PDFGoTo |
getPDFGoToForID(java.lang.String targetID,
java.lang.String pvKey)
Get a PDFGoTo pointing to the given id. |
protected java.lang.String |
getTargetableID(Area area)
Returns area's id if it is the first area in the document with that id (i.e. |
protected void |
handleRegionTraits(RegionViewport region)
Handle the traits for a region This is used to draw the traits for the given page region. |
protected void |
lineTo(float x,
float y)
Appends a straight line segment from the current point to (x, y). |
protected void |
moveTo(float x,
float y)
Moves the current point to (x, y), omitting any connecting line segment. |
void |
placeImage(float x,
float y,
float w,
float h,
PDFXObject xobj)
Places a previously registered image at a certain place on the page. |
void |
preparePage(PageViewport page)
The pdf page is prepared by making the page. |
void |
processOffDocumentItem(OffDocumentItem odi)
Tells the renderer to process an item not explicitly placed on the document (e.g., PDF bookmarks). |
protected void |
putImage(java.lang.String uri,
java.awt.geom.Rectangle2D pos)
Deprecated. Use @putImage(String, Rectangle2D, Map) instead. |
protected void |
putImage(java.lang.String uri,
java.awt.geom.Rectangle2D pos,
java.util.Map foreignAttributes)
Adds a PDF XObject (a bitmap or form) to the PDF that will later be referenced. |
protected void |
renderBlock(Block block)
Renders a block area. |
protected void |
renderBookmarkTree(BookmarkData bookmarks)
Renders a Bookmark-Tree object |
void |
renderImage(Image image,
java.awt.geom.Rectangle2D pos)
Renders an image area. |
protected void |
renderInlineArea(InlineArea inlineArea)
Render the given InlineArea. |
void |
renderInlineParent(InlineParent ip)
Render inline parent area. |
void |
renderLeader(Leader area)
Render leader area. |
protected void |
renderLineArea(LineArea line)
Renders a line area. |
void |
renderPage(PageViewport page)
This method creates a pdf stream for the current page uses it as the contents of a new page. |
void |
renderSpace(SpaceArea space)
Render the given SpaceArea. |
void |
renderText(TextArea text)
Render the given TextArea. |
void |
renderWord(WordArea word)
Render the given WordArea. |
protected void |
restoreGraphicsState()
Restores the last graphics state of the rendering engine. |
protected void |
restoreStateStackAfterBreakOut(java.util.List breakOutList)
Restores the state stack after a break out. |
protected void |
saveAbsolutePosition(java.lang.String id,
int relativeIPP,
int relativeBPP)
Saves id's absolute position on page for later retrieval by PDFGoTos, using the currently valid transformation and the currently valid PDF page reference |
protected void |
saveAbsolutePosition(java.lang.String id,
java.lang.String pdfPageRef,
int relativeIPP,
int relativeBPP,
java.awt.geom.AffineTransform tf)
Saves id's absolute position on page for later retrieval by PDFGoTos |
protected void |
saveBlockPosIfTargetable(Block block)
If the given block area is a possible link target, its id + absolute position will be saved. |
protected void |
saveGraphicsState()
Saves the graphics state of the rendering engine. |
protected void |
saveInlinePosIfTargetable(InlineArea inlineArea)
If the given inline area is a possible link target, its id + absolute position will be saved. |
void |
setAMode(PDFAMode mode)
|
protected void |
setColor(java.awt.Color col,
boolean fill,
java.lang.StringBuffer pdf)
Establishes a new foreground or fill color. |
void |
setFilterMap(java.util.Map filterMap)
|
void |
setOutputProfileURI(java.lang.String outputProfileURI)
|
void |
setUserAgent(FOUserAgent agent)
Set the User Agent. |
void |
setXMode(PDFXMode mode)
|
void |
startPageSequence(PageSequence pageSequence)
Start the next page sequence. |
void |
startRenderer(java.io.OutputStream stream)
Initiates the rendering phase. |
protected void |
startVParea(CTM ctm,
java.awt.geom.Rectangle2D clippingRect)
Establishes a new viewport area. |
void |
stopRenderer()
Signals the end of the rendering phase. |
boolean |
supportsOutOfOrder()
Check if this renderer supports out of order rendering. |
protected void |
updateColor(java.awt.Color col,
boolean fill)
Establishes a new foreground or fill color. |
Methods inherited from class org.apache.fop.render.AbstractPathOrientedRenderer |
---|
drawBackAndBorders, drawBorders, drawImage, handleBlockTraits, renderBlockViewport, renderFlow, renderForeignObject, renderInlineAreaBackAndBorders, renderReferenceArea, renderTextDecoration, renderViewport |
Methods inherited from class org.apache.fop.render.PrintRenderer |
---|
addFontList, getFontFromArea, getFontResolver, getInternalFontNameForArea, lightenColor, renderDocument, setFontList, setupFontInfo |
Methods inherited from class org.apache.fop.render.AbstractRenderer |
---|
convertTitleToString, getCurrentPageViewport, getImageAdapter, getUserAgent, mptToPt, ptToMpt, renderBeforeFloat, renderBlocks, renderBodyRegion, renderCharacter, renderContainer, renderFootnote, renderInlineBlockParent, renderInlineSpace, renderMainReference, renderPageAreas, renderRegion, renderRegionViewport, renderXML, startPageSequence |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String MIME_TYPE
public static final int NORMAL_PDF_RESOLUTION
public static final java.lang.String ENCRYPTION_PARAMS
public static final java.lang.String USER_PASSWORD
public static final java.lang.String OWNER_PASSWORD
public static final java.lang.String NO_PRINT
public static final java.lang.String NO_COPY_CONTENT
public static final java.lang.String NO_EDIT_CONTENT
public static final java.lang.String NO_ANNOTATIONS
public static final java.lang.String PDF_A_MODE
public static final java.lang.String PDF_X_MODE
public static final java.lang.String KEY_OUTPUT_PROFILE
public static final java.lang.String KEY_DISABLE_SRGB_COLORSPACE
protected static final boolean WRITE_COMMENTS
protected PDFDocument pdfDoc
protected PDFAMode pdfAMode
protected PDFXMode pdfXMode
protected java.util.Map pages
protected java.util.Map pageReferences
protected java.util.Map pvReferences
protected java.util.Map idPositions
protected java.util.Map idGoTos
protected java.util.List unfinishedGoTos
protected java.io.OutputStream ostream
protected PDFResources pdfResources
protected PDFStream currentStream
protected PDFResourceContext currentContext
protected PDFPage currentPage
protected java.lang.String currentPageRef
protected PDFEncryptionParams encryptionParams
protected PDFICCStream outputProfile
protected PDFICCBasedColorSpace sRGBColorSpace
protected boolean disableSRGBColorSpace
protected java.lang.String outputProfileURI
protected PDFState currentState
protected java.lang.String currentFontName
protected int currentFontSize
protected int pageHeight
protected java.util.Map filterMap
protected boolean inTextMode
Constructor Detail |
---|
public PDFRenderer()
Method Detail |
---|
public void setUserAgent(FOUserAgent agent)
setUserAgent
in interface Renderer
setUserAgent
in class AbstractRenderer
agent
- The User Agentpublic void startRenderer(java.io.OutputStream stream) throws java.io.IOException
startRenderer
in interface Renderer
startRenderer
in class AbstractRenderer
stream
- The OutputStream to use for output
java.io.IOException
- If an I/O error occursprotected void finishOpenGoTos()
public void stopRenderer() throws java.io.IOException
stopRenderer
in interface Renderer
stopRenderer
in class AbstractRenderer
java.io.IOException
- If an I/O error occurspublic boolean supportsOutOfOrder()
supportsOutOfOrder
in interface Renderer
supportsOutOfOrder
in class AbstractRenderer
public void processOffDocumentItem(OffDocumentItem odi)
processOffDocumentItem
in interface Renderer
processOffDocumentItem
in class AbstractRenderer
odi
- The off-document item to be renderedprotected void renderBookmarkTree(BookmarkData bookmarks)
bookmarks
- the BookmarkData object containing all the Bookmark-Itemspublic Graphics2DAdapter getGraphics2DAdapter()
getGraphics2DAdapter
in interface Renderer
getGraphics2DAdapter
in class AbstractRenderer
protected void comment(java.lang.String text)
text
- text for the commentprotected void saveGraphicsState()
saveGraphicsState
in class AbstractPathOrientedRenderer
protected void restoreGraphicsState()
restoreGraphicsState
in class AbstractPathOrientedRenderer
protected void beginTextObject()
beginTextObject
in class AbstractPathOrientedRenderer
protected void endTextObject()
endTextObject
in class AbstractPathOrientedRenderer
public void startPageSequence(PageSequence pageSequence)
startPageSequence
in interface Renderer
startPageSequence
in class AbstractRenderer
pageSequence
- the page sequencepublic void preparePage(PageViewport page)
preparePage
in interface Renderer
preparePage
in class AbstractRenderer
page
- the page to preparepublic void renderPage(PageViewport page) throws java.io.IOException, FOPException
renderPage
in interface Renderer
renderPage
in class AbstractRenderer
page
- The page to be rendered
java.io.IOException
- if an I/O error occurs
FOPException
- if a FOP interal error occurs.protected void startVParea(CTM ctm, java.awt.geom.Rectangle2D clippingRect)
startVParea
in class AbstractRenderer
ctm
- the coordinate transformation matrix to useclippingRect
- the clipping rectangle if the viewport should be clipping,
null if no clipping is performed.protected void endVParea()
endVParea
in class AbstractRenderer
protected void concatenateTransformationMatrix(java.awt.geom.AffineTransform at)
concatenateTransformationMatrix
in class AbstractPathOrientedRenderer
at
- the transformation matrix to process (coordinates in points)protected void handleRegionTraits(RegionViewport region)
handleRegionTraits
in class AbstractPathOrientedRenderer
region
- the RegionViewport whose region is to be drawnprotected static final java.lang.String format(float value)
value
- the value
protected void drawBorderLine(float x1, float y1, float x2, float y2, boolean horz, boolean startOrBefore, int style, java.awt.Color col)
drawBorderLine
in class AbstractPathOrientedRenderer
x1
- starting x coordinatey1
- starting y coordinatex2
- ending x coordinatey2
- ending y coordinatehorz
- true for horizontal border segments, false for vertical border segmentsstartOrBefore
- true for border segments on the start or before edge,
false for end or after.style
- the border style (one of Constants.EN_DASHED etc.)col
- the color for the border segmentprotected void clipRect(float x, float y, float width, float height)
clipRect
in class AbstractPathOrientedRenderer
x
- the x coordinate (in points)y
- the y coordinate (in points)width
- the width of the rectangle (in points)height
- the height of the rectangle (in points)protected void clip()
clip
in class AbstractPathOrientedRenderer
protected void moveTo(float x, float y)
moveTo
in class AbstractPathOrientedRenderer
x
- x coordinatey
- y coordinateprotected void lineTo(float x, float y)
lineTo
in class AbstractPathOrientedRenderer
x
- x coordinatey
- y coordinateprotected void closePath()
closePath
in class AbstractPathOrientedRenderer
protected void fillRect(float x, float y, float w, float h)
fillRect
in class AbstractPathOrientedRenderer
x
- the x coordinatey
- the y coordinatew
- the width of the rectangleh
- the height of the rectangleprotected java.util.List breakOutOfStateStack()
breakOutOfStateStack
in class AbstractPathOrientedRenderer
protected void restoreStateStackAfterBreakOut(java.util.List breakOutList)
restoreStateStackAfterBreakOut
in class AbstractPathOrientedRenderer
breakOutList
- the state stack to restore.protected java.lang.String getTargetableID(Area area)
area
- the area for which to return the idprotected void finishIDGoTo(PDFGoTo gt, java.awt.geom.Point2D.Float position)
gt
- the PDFGoTo objectposition
- the X,Y position to setprotected void finishIDGoTo(PDFGoTo gt, java.lang.String pdfPageRef, java.awt.geom.Point2D.Float position)
gt
- the PDFGoTo objectpdfPageRef
- the PDF reference string of the target page objectposition
- the X,Y position to setprotected PDFGoTo getPDFGoToForID(java.lang.String targetID, java.lang.String pvKey)
targetID
- the target id of the PDFGoTopvKey
- the unique key of the target PageViewport
protected void saveAbsolutePosition(java.lang.String id, java.lang.String pdfPageRef, int relativeIPP, int relativeBPP, java.awt.geom.AffineTransform tf)
id
- the id of the area whose position must be savedpdfPageRef
- the PDF page reference stringrelativeIPP
- the *relative* IP position in millipointsrelativeBPP
- the *relative* BP position in millipointstf
- the transformation to apply once the relative positions have been
converted to pointsprotected void saveAbsolutePosition(java.lang.String id, int relativeIPP, int relativeBPP)
id
- the id of the area whose position must be savedrelativeIPP
- the *relative* IP position in millipointsrelativeBPP
- the *relative* BP position in millipointsprotected void saveBlockPosIfTargetable(Block block)
block
- the block area in questionprotected void saveInlinePosIfTargetable(InlineArea inlineArea)
inlineArea
- the inline area in questionprotected void renderBlock(Block block)
renderBlock
in class AbstractRenderer
block
- The block areaprotected void renderLineArea(LineArea line)
A line area may have grouped styling for its children such as underline, background.
renderLineArea
in class AbstractRenderer
line
- The line areaprotected void renderInlineArea(InlineArea inlineArea)
renderInlineArea
in class AbstractRenderer
inlineArea
- inline area text to renderpublic void renderInlineParent(InlineParent ip)
renderInlineParent
in class AbstractRenderer
ip
- the inline parent areapublic void renderText(TextArea text)
renderText
in class AbstractRenderer
text
- the text to renderpublic void renderWord(WordArea word)
renderWord
in class AbstractRenderer
word
- the word to renderpublic void renderSpace(SpaceArea space)
renderSpace
in class AbstractRenderer
space
- the space to renderpublic void escapeText(java.lang.String s, int[] letterAdjust, Font fs, AbstractTextArea parentArea, boolean useMultiByte, java.lang.StringBuffer pdf)
s
- Text to escapeletterAdjust
- an array of widths for letter adjustment (may be null)fs
- Font stateparentArea
- the parent text area to retrieve certain traits fromuseMultiByte
- Indicates the use of multi byte conventionpdf
- target buffer for the escaped textprotected void closeText()
protected void setColor(java.awt.Color col, boolean fill, java.lang.StringBuffer pdf)
col
- the color to applyfill
- true to set the fill color, false for the foreground colorpdf
- StringBuffer to write the PDF code to, if null, the code is
written to the current stream.protected void updateColor(java.awt.Color col, boolean fill)
updateColor
in class AbstractPathOrientedRenderer
col
- the color to apply (null skips this operation)fill
- true to set the fill color, false for the foreground colorpublic void renderImage(Image image, java.awt.geom.Rectangle2D pos)
renderImage
in class AbstractRenderer
image
- The imagepos
- The target position of the image
(todo) Make renderImage() protectedprotected void drawImage(java.lang.String url, java.awt.geom.Rectangle2D pos, java.util.Map foreignAttributes)
drawImage
in class AbstractPathOrientedRenderer
url
- the URI/URL of the imagepos
- the position of the imageforeignAttributes
- an optional Map with foreign attributes, may be nullprotected void putImage(java.lang.String uri, java.awt.geom.Rectangle2D pos)
@putImage(String, Rectangle2D, Map)
instead.
uri
- URL of the bitmappos
- Position of the bitmapprotected void putImage(java.lang.String uri, java.awt.geom.Rectangle2D pos, java.util.Map foreignAttributes)
uri
- URL of the bitmappos
- Position of the bitmapforeignAttributes
- foreign attributes associated with the imagepublic void placeImage(float x, float y, float w, float h, PDFXObject xobj)
x
- X coordinatey
- Y coordinatew
- width for imageh
- height for imagexobj
- the image XObjectprotected RendererContext createRendererContext(int x, int y, int width, int height, java.util.Map foreignAttributes)
createRendererContext
in class PrintRenderer
x
- the x coordinate (in millipoints)y
- the y coordinate (in millipoints)width
- the width of the image (in millipoints)height
- the height of the image (in millipoints)foreignAttributes
- a Map or foreign attributes, may be null
public void renderLeader(Leader area)
renderLeader
in class AbstractRenderer
area
- the leader area to renderpublic java.lang.String getMimeType()
getMimeType
in interface Renderer
getMimeType
in class AbstractRenderer
public void setAMode(PDFAMode mode)
public void setXMode(PDFXMode mode)
public void setOutputProfileURI(java.lang.String outputProfileURI)
public void setFilterMap(java.util.Map filterMap)
|
fop 0.95 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |