org.apache.fop.render.pdf
Class PDFRenderer

java.lang.Object
  extended byorg.apache.fop.render.AbstractRenderer
      extended byorg.apache.fop.render.PrintRenderer
          extended byorg.apache.fop.render.pdf.PDFRenderer
All Implemented Interfaces:
Renderer

public class PDFRenderer
extends PrintRenderer

Renderer that renders areas to PDF.

Modified by Mark Lillywhite, mark-fop@inomial.com to use the new Renderer interface. The PDF renderer is by far the trickiest renderer and the best supported by FOP. It also required some reworking in the way that Pages, Catalogs and the Root object were written to the stream. The output document should now still be a 100% compatible PDF document, but the order of the document writing is significantly different. See also the changes to PDFPage, PDFPages and PDFRoot.


Field Summary
protected  java.util.List extensions
           
protected  java.util.Map options
          options
protected  PDFDocument pdfDoc
          the PDF Document being created
protected  PDFResources pdfResources
          the /Resources object of the PDF document being created
 
Fields inherited from class org.apache.fop.render.PrintRenderer
currentFill, currentFontName, currentFontSize, currentStroke, fontInfo, prevLineThroughColor, prevLineThroughSize, prevLineThroughXEndPos, prevLineThroughYEndPos, prevOverlineColor, prevOverlineSize, prevOverlineXEndPos, prevOverlineYEndPos, prevUnderlineColor, prevUnderlineSize, prevUnderlineXEndPos, prevUnderlineYEndPos
 
Fields inherited from class org.apache.fop.render.AbstractRenderer
currentAreaContainerXPosition, currentXPosition, currentYPosition, idReferences, log
 
Constructor Summary
PDFRenderer()
          create the PDF renderer
 
Method Summary
protected  void addFilledRect(int x, int y, int w, int h, PDFPathPaint fill)
          add a filled rectangle to the current stream
protected  void addLine(int x1, int y1, int x2, int y2, int th, int rs, PDFPathPaint stroke)
          add a line to the current stream
protected  void addLine(int x1, int y1, int x2, int y2, int th, PDFPathPaint stroke)
          add a line to the current stream
protected  void drawImageClipped(int x, int y, int clipX, int clipY, int clipW, int clipH, FopImage image, FontState fs)
          Renders an image, clipping it as specified.
protected  void drawImageScaled(int x, int y, int w, int h, FopImage image, FontState fs)
          Renders an image, scaling it to the given width and height.
 void render(Page page, java.io.OutputStream outputStream)
          render page to PDF
 void renderForeignObjectArea(ForeignObjectArea area)
          render a foreign object area
 void renderPage(Page page)
          render page into PDF
protected  void renderRootExtensions(java.util.List extensions)
          render root extensions such as outlines
 void renderSVGArea(SVGArea area)
          render SVG area to PDF
protected  void renderSVGDocument(org.w3c.dom.Document doc, int x, int y, FontState fs)
          render SVG document to PDF
 void renderWordArea(WordArea area)
          render inline area to PDF
 void setOptions(java.util.Map options)
          set up renderer options
 void setProducer(java.lang.String producer)
          set the PDF document's producer
 void startRenderer(java.io.OutputStream stream)
          Starts the renderer
 void stopRenderer(java.io.OutputStream stream)
          Called when the renderer has finished its work
 
Methods inherited from class org.apache.fop.render.PrintRenderer
addFilledRect, addWordLines, doFrame, renderDisplaySpace, renderInlineSpace, renderLeaderArea, setupFontInfo
 
Methods inherited from class org.apache.fop.render.AbstractRenderer
doBackground, drawImage, getIDReferences, renderAreaContainer, renderBlockArea, renderBodyAreaContainer, renderImageArea, renderLineArea, renderRegionAreaContainer, renderRegions, renderSpanArea, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pdfDoc

protected PDFDocument pdfDoc
the PDF Document being created


pdfResources

protected PDFResources pdfResources
the /Resources object of the PDF document being created


options

protected java.util.Map options
options


extensions

protected java.util.List extensions
Constructor Detail

PDFRenderer

public PDFRenderer()
create the PDF renderer

Method Detail

setOptions

public void setOptions(java.util.Map options)
set up renderer options

Parameters:
options - Options for the renderer

setProducer

public void setProducer(java.lang.String producer)
set the PDF document's producer

Specified by:
setProducer in interface Renderer
Specified by:
setProducer in class PrintRenderer
Parameters:
producer - string indicating application producing PDF

startRenderer

public void startRenderer(java.io.OutputStream stream)
                   throws java.io.IOException
Starts the renderer

Specified by:
startRenderer in interface Renderer
Overrides:
startRenderer in class PrintRenderer
Parameters:
stream - OutputStream to be written to
Throws:
java.io.IOException - In case of an IO problem

stopRenderer

public void stopRenderer(java.io.OutputStream stream)
                  throws java.io.IOException
Called when the renderer has finished its work

Specified by:
stopRenderer in interface Renderer
Overrides:
stopRenderer in class PrintRenderer
Parameters:
stream - OutputStream to be written to
Throws:
java.io.IOException - In cas of an IO problem

addLine

protected void addLine(int x1,
                       int y1,
                       int x2,
                       int y2,
                       int th,
                       PDFPathPaint stroke)
add a line to the current stream

Specified by:
addLine in class PrintRenderer
Parameters:
x1 - the start x location in millipoints
y1 - the start y location in millipoints
x2 - the end x location in millipoints
y2 - the end y location in millipoints
th - the thickness in millipoints
stroke - the stroke color/gradient

addLine

protected void addLine(int x1,
                       int y1,
                       int x2,
                       int y2,
                       int th,
                       int rs,
                       PDFPathPaint stroke)
add a line to the current stream

Specified by:
addLine in class PrintRenderer
Parameters:
x1 - the start x location in millipoints
y1 - the start y location in millipoints
x2 - the end x location in millipoints
y2 - the end y location in millipoints
th - the thickness in millipoints
rs - the rule style
stroke - the stroke color/gradient

addFilledRect

protected void addFilledRect(int x,
                             int y,
                             int w,
                             int h,
                             PDFPathPaint fill)
add a filled rectangle to the current stream

Specified by:
addFilledRect in class PrintRenderer
Parameters:
x - the x position of left edge in millipoints
y - the y position of top edge in millipoints
w - the width in millipoints
h - the height in millipoints
fill - the fill color/gradient

drawImageScaled

protected void drawImageScaled(int x,
                               int y,
                               int w,
                               int h,
                               FopImage image,
                               FontState fs)
Renders an image, scaling it to the given width and height. If the scaled width and height is the same intrinsic size of the image, the image is not scaled.

Specified by:
drawImageScaled in class AbstractRenderer
Parameters:
x - the x position of left edge in millipoints
y - the y position of top edge in millipoints
w - the width in millipoints
h - the height in millipoints
image - the image to be rendered
fs - the font state to use when rendering text in non-bitmapped images.

drawImageClipped

protected void drawImageClipped(int x,
                                int y,
                                int clipX,
                                int clipY,
                                int clipW,
                                int clipH,
                                FopImage image,
                                FontState fs)
Renders an image, clipping it as specified.

Specified by:
drawImageClipped in class AbstractRenderer
Parameters:
x - the x position of left edge in millipoints.
y - the y position of top edge in millipoints.
clipX - the left edge of the clip in millipoints
clipY - the top edge of the clip in millipoints
clipW - the clip width in millipoints
clipH - the clip height in millipoints
fs - the font state to use when rendering text in non-bitmapped images.
image - the image to be painted

renderForeignObjectArea

public void renderForeignObjectArea(ForeignObjectArea area)
render a foreign object area

Specified by:
renderForeignObjectArea in interface Renderer
Specified by:
renderForeignObjectArea in class PrintRenderer
Parameters:
area - the foreign object area to be rendered

renderSVGArea

public void renderSVGArea(SVGArea area)
render SVG area to PDF

Specified by:
renderSVGArea in interface Renderer
Specified by:
renderSVGArea in class PrintRenderer
Parameters:
area - the SVG area to render

renderSVGDocument

protected void renderSVGDocument(org.w3c.dom.Document doc,
                                 int x,
                                 int y,
                                 FontState fs)
render SVG document to PDF

Parameters:
doc - the document to render
x - the x offset
y - the y offset
fs - the fontstate to use

renderWordArea

public void renderWordArea(WordArea area)
render inline area to PDF

Specified by:
renderWordArea in interface Renderer
Specified by:
renderWordArea in class PrintRenderer
Parameters:
area - inline area to render

render

public void render(Page page,
                   java.io.OutputStream outputStream)
            throws FOPException,
                   java.io.IOException
render page to PDF

Parameters:
page - the page render
outputStream - the target OutputStream
Throws:
FOPException - in case of an internal problem
java.io.IOException - in case of an IO problem

renderPage

public void renderPage(Page page)
render page into PDF

Specified by:
renderPage in interface Renderer
Specified by:
renderPage in class PrintRenderer
Parameters:
page - page to render

renderRootExtensions

protected void renderRootExtensions(java.util.List extensions)
render root extensions such as outlines



Copyright ? 1999-2003 Apache Software Foundation. All Rights Reserved.