Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| fop 1.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.fop.render.pdf
Class PDFContentGenerator

    java.lang.Object
      org.apache.fop.render.pdf.PDFContentGenerator

public class PDFContentGenerator
extends java.lang.Object

Generator class encapsulating all object references and state necessary to generate a PDF content stream.

Field Summary
`protected PDFPaintingState` | `currentState` drawing state
`protected PDFTextUtil` | `textutil` Text generation utility holding the current font status
`protected static boolean` | `WRITE_COMMENTS` Controls whether comments are written to the PDF stream.

Constructor Summary
`PDFContentGenerator(PDFDocument document, java.io.OutputStream out, PDFResourceContext resourceContext)` Main constructor.

Method Summary
`void` | `add(java.lang.String content)` Adds content to the stream.
`protected void` | `beginMarkedContentSequence(java.lang.String structElemType, int mcid)` Begins a new marked content sequence (BDC or BMC).
`protected void` | `beginTextObject()` Indicates the beginning of a text object.
`protected void` | `beginTextObject(java.lang.String structElemType, int mcid)` Indicates the beginning of a marked-content text object.
`void` | `clipRect(java.awt.Rectangle rect)` Intersects the current clip region with the given rectangle.
`protected void` | `comment(java.lang.String text)` Writes out a comment.
`void` | `concatenate(java.awt.geom.AffineTransform transform)` Concatenates the given transformation matrix with the current one.
`protected void` | `endTextObject()` Indicates the end of a text object.
`void` | `flushPDFDoc()` Flushes all queued PDF objects ready to be written to the output stream.
`static java.lang.String` | `format(float value)` Formats a float value (normally coordinates in points) as Strings.
`PDFDocument` | `getDocument()` Returns the applicable resource context for the generator.
`java.io.OutputStream` | `getOutputStream()` Returns the output stream the PDF document is written to.
`PDFResourceContext` | `getResourceContext()` Returns the applicable resource context for the generator.
`PDFPaintingState` | `getState()` Returns the `PDFState` associated with this instance.
`PDFStream` | `getStream()` Returns the `PDFStream` associated with this instance.
`PDFTextUtil` | `getTextUtil()` Returns the `PDFTextUtil` associated with this instance.
`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` | `placeImage(float x, float y, float w, float h, PDFXObject xobj, java.lang.String structElemType, int mcid)` Places a previously registered image at a certain place on the page, bracketing it as a marked-content sequence.
`protected void` | `restoreGraphicsState()` Same as `restoreGraphicsState(boolean)`, with `true` as a parameter.
`protected void` | `restoreGraphicsState(boolean popState)` Restored the graphics state valid before the previous `saveGraphicsState()`.
`protected void` | `restoreGraphicsStateAccess()` Same as `restoreGraphicsState()`, additionally ending the current marked content sequence if any.
`protected void` | `saveGraphicsState()` {@inheritDoc}
`protected void` | `saveGraphicsState(java.lang.String structElemType, int sequenceNum)` {@inheritDoc}
`protected void` | `separateTextElements(java.lang.String structElemType, int mcid)` Separates 2 text elements, ending the current marked content sequence and starting a new one.
`void` | `setColor(java.awt.Color col, boolean fill)` Establishes a new foreground or fill color.
`void` | `setColor(java.awt.Color col, boolean fill, PDFStream stream)` Establishes a new foreground or fill color.
`protected void` | `setColor(java.awt.Color col, boolean fill, java.lang.StringBuffer pdf)` Establishes a new foreground or fill color.
`void` | `updateCharacterSpacing(float value)` Sets the current character spacing (Tc) value.
`void` | `updateColor(java.awt.Color col, boolean fill, java.lang.StringBuffer pdf)` Establishes a new foreground or fill color.
`void` | `updateLineWidth(float width)` Sets the current line width in points.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### WRITE_COMMENTS

    protected static final boolean WRITE_COMMENTS

  Controls whether comments are written to the PDF stream.

  See Also:
    Constant Field Values

### currentState

    protected PDFPaintingState currentState

  drawing state

### textutil

    protected PDFTextUtil textutil

  Text generation utility holding the current font status

Constructor Detail

### PDFContentGenerator

    public PDFContentGenerator(PDFDocument document,
                               java.io.OutputStream out,
                               PDFResourceContext resourceContext)

  Main constructor. Creates a new PDF stream and additional helper classes for text painting and state management.

Parameters:
  `document` - the PDF document
  `out` - the output stream the PDF document is generated to
  `resourceContext` - the resource context

Method Detail

### getDocument

    public PDFDocument getDocument()

  Returns the applicable resource context for the generator.

  Returns:
    the resource context

### getOutputStream

    public java.io.OutputStream getOutputStream()

  Returns the output stream the PDF document is written to.

  Returns:
    the output stream

### getResourceContext

    public PDFResourceContext getResourceContext()

  Returns the applicable resource context for the generator.

  Returns:
    the resource context

### getStream

    public PDFStream getStream()

  Returns the `PDFStream` associated with this instance.

  Returns:
    the PDF stream

### getState

    public PDFPaintingState getState()

  Returns the `PDFState` associated with this instance.

  Returns:
    the PDF state

### getTextUtil

    public PDFTextUtil getTextUtil()

  Returns the `PDFTextUtil` associated with this instance.

  Returns:
    the text utility

### flushPDFDoc

    public void flushPDFDoc()
                     throws java.io.IOException

  Flushes all queued PDF objects ready to be written to the output stream.

  Throws:
    `java.io.IOException` - if an error occurs while flushing the PDF objects

### comment

    protected void comment(java.lang.String text)

  Writes out a comment.

  Parameters:
    `text` - text for the comment

### saveGraphicsState

    protected void saveGraphicsState()

  {@inheritDoc}

### saveGraphicsState

    protected void saveGraphicsState(java.lang.String structElemType,
                                     int sequenceNum)

  {@inheritDoc}

### beginMarkedContentSequence

    protected void beginMarkedContentSequence(java.lang.String structElemType,
                                              int mcid)

  Begins a new marked content sequence (BDC or BMC). If the parameter structElemType is null, the sequenceNum is ignored and instead of a BDC with the MCID as parameter, an "Artifact" and a BMC command is generated.

  Parameters:
    `structElemType` - Structure Element Type
    `mcid` - Sequence number

### restoreGraphicsState

    protected void restoreGraphicsState(boolean popState)

  Restored the graphics state valid before the previous `saveGraphicsState()`.

  Parameters:
    `popState` - true if the state should also be popped, false if only the PDF command should be issued

### restoreGraphicsState

    protected void restoreGraphicsState()

  Same as `restoreGraphicsState(boolean)`, with `true` as a parameter.

### restoreGraphicsStateAccess

    protected void restoreGraphicsStateAccess()

  Same as `restoreGraphicsState()`, additionally ending the current marked content sequence if any.

### separateTextElements

    protected void separateTextElements(java.lang.String structElemType,
                                        int mcid)

  Separates 2 text elements, ending the current marked content sequence and starting a new one.

  Parameters:
    `structElemType` - structure element type
    `mcid` - sequence number
  See Also:
    `beginMarkedContentSequence(String, int)`

### beginTextObject

    protected void beginTextObject()

  Indicates the beginning of a text object.

### beginTextObject

    protected void beginTextObject(java.lang.String structElemType,
                                   int mcid)

  Indicates the beginning of a marked-content text object.

  Parameters:
    `structElemType` - structure element type
    `mcid` - sequence number
  See Also:
    `beginTextObject()`, `beginMarkedContentSequence(String, int)`

### endTextObject

    protected void endTextObject()

  Indicates the end of a text object.

### concatenate

    public void concatenate(java.awt.geom.AffineTransform transform)

  Concatenates the given transformation matrix with the current one.

  Parameters:
    `transform` - the transformation matrix (in points)

### clipRect

    public void clipRect(java.awt.Rectangle rect)

  Intersects the current clip region with the given rectangle.

  Parameters:
    `rect` - the clip rectangle

### add

    public void add(java.lang.String content)

  Adds content to the stream.

  Parameters:
    `content` - the PDF content

### format

    public static final java.lang.String format(float value)

  Formats a float value (normally coordinates in points) as Strings.

  Parameters:
    `value` - the value
  Returns:
    the formatted value

### updateLineWidth

    public void updateLineWidth(float width)

  Sets the current line width in points.

  Parameters:
    `width` - line width in points

### updateCharacterSpacing

    public void updateCharacterSpacing(float value)

  Sets the current character spacing (Tc) value.

  Parameters:
    `value` - the Tc value (in unscaled text units)

### setColor

    public void setColor(java.awt.Color col,
                         boolean fill,
                         PDFStream stream)

  Establishes a new foreground or fill color.

  Parameters:
    `col` - the color to apply
    `fill` - true to set the fill color, false for the foreground color
    `stream` - the PDFStream to write the PDF code to

### setColor

    public void setColor(java.awt.Color col,
                         boolean fill)

  Establishes a new foreground or fill color.

  Parameters:
    `col` - the color to apply
    `fill` - true to set the fill color, false for the foreground color

### setColor

    protected void setColor(java.awt.Color col,
                            boolean fill,
                            java.lang.StringBuffer pdf)

  Establishes a new foreground or fill color. In contrast to updateColor this method does not check the PDFState for optimization possibilities.

  Parameters:
    `col` - the color to apply
    `fill` - true to set the fill color, false for the foreground color
    `pdf` - StringBuffer to write the PDF code to, if null, the code is written to the current stream.

### updateColor

    public void updateColor(java.awt.Color col,
                            boolean fill,
                            java.lang.StringBuffer pdf)

  Establishes a new foreground or fill color.

  Parameters:
    `col` - the color to apply (null skips this operation)
    `fill` - true to set the fill color, false for the foreground color
    `pdf` - StringBuffer to write the PDF code to, if null, the code is written to the current stream.

### placeImage

    public void placeImage(float x,
                           float y,
                           float w,
                           float h,
                           PDFXObject xobj)

  Places a previously registered image at a certain place on the page.

  Parameters:
    `x` - X coordinate
    `y` - Y coordinate
    `w` - width for image
    `h` - height for image
    `xobj` - the image XObject

### placeImage

    public void placeImage(float x,
                           float y,
                           float w,
                           float h,
                           PDFXObject xobj,
                           java.lang.String structElemType,
                           int mcid)

  Places a previously registered image at a certain place on the page, bracketing it as a marked-content sequence.

  Parameters:
    `x` - X coordinate
    `y` - Y coordinate
    `w` - width for image
    `h` - height for image
    `xobj` - the image XObject
    `structElemType` - structure element type
    `mcid` - sequence number
  See Also:
    `beginMarkedContentSequence(String, int)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| fop 1.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 1999-2010 The Apache Software Foundation. All Rights Reserved.