Renderer that renders areas to PDF.
ENCRYPTION_PARAMS
public static final String ENCRYPTION_PARAMS
PDF encryption parameter: all parameters as object, datatype: PDFEncryptionParams
KEY_OUTPUT_PROFILE
public static final String KEY_OUTPUT_PROFILE
Rendering Options key for the ICC profile for the output intent.
MIME_TYPE
public static final String MIME_TYPE
The mime type for pdf
NORMAL_PDF_RESOLUTION
public static final int NORMAL_PDF_RESOLUTION
Normal PDF resolution (72dpi)
NO_ANNOTATIONS
public static final String NO_ANNOTATIONS
PDF encryption parameter: Forbids annotations, datatype: Boolean or "true"/"false"
NO_COPY_CONTENT
public static final String NO_COPY_CONTENT
PDF encryption parameter: Forbids copying content, datatype: Boolean or "true"/"false"
NO_EDIT_CONTENT
public static final String NO_EDIT_CONTENT
PDF encryption parameter: Forbids editing content, datatype: Boolean or "true"/"false"
NO_PRINT
public static final String NO_PRINT
PDF encryption parameter: Forbids printing, datatype: Boolean or "true"/"false"
OWNER_PASSWORD
public static final String OWNER_PASSWORD
PDF encryption parameter: owner password, datatype: String
PDF_A_MODE
public static final String PDF_A_MODE
Rendering Options key for the PDF/A mode.
PDF_X_MODE
public static final String PDF_X_MODE
Rendering Options key for the PDF/X mode.
USER_PASSWORD
public static final String USER_PASSWORD
PDF encryption parameter: user password, datatype: String
WRITE_COMMENTS
protected static final boolean WRITE_COMMENTS
Controls whether comments are written to the PDF stream.
currentContext
protected PDFResourceContext currentContext
the current annotation list to add annotations to
currentFontName
protected String currentFontName
Name of currently selected font
currentFontSize
protected int currentFontSize
Size of currently selected font
currentPage
protected PDFPage currentPage
the current page to add annotations to
currentPageRef
protected String currentPageRef
the current page's PDF reference string (to avoid numerous function calls)
currentState
protected PDFState currentState
drawing state
currentStream
protected PDFStream currentStream
the current stream to add PDF commands to
encryptionParams
protected PDFEncryptionParams encryptionParams
the (optional) encryption parameters
filterMap
protected Map filterMap
Registry of PDF filters
idGoTos
protected Map idGoTos
Maps XSL-FO element IDs to PDFGoTo objects targeting the corresponding areas
These objects may not all be fully filled in yet
idPositions
protected 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
inTextMode
protected boolean inTextMode
true if a BT command has been written.
ostream
protected OutputStream ostream
The output stream to write the document to
outputProfile
protected PDFICCStream outputProfile
the ICC stream used as output profile by this document for PDF/A and PDF/X functionality.
outputProfileURI
protected String outputProfileURI
Optional URI to an output profile to be used.
pageHeight
protected int pageHeight
page height
pageReferences
protected Map pageReferences
Maps unique PageViewport key to PDF page reference
pages
protected Map pages
Map of pages using the PageViewport as the key
this is used for prepared pages that cannot be immediately
rendered
pdfAMode
protected PDFAMode pdfAMode
the PDF/A mode (Default: disabled)
pdfDoc
protected PDFDocument pdfDoc
the PDF Document being created
pdfResources
protected PDFResources pdfResources
the /Resources object of the PDF document being created
pdfXMode
protected PDFXMode pdfXMode
the PDF/X mode (Default: disabled)
pvReferences
protected Map pvReferences
Maps unique PageViewport key back to PageViewport itself
unfinishedGoTos
protected List unfinishedGoTos
The PDFGoTos in idGoTos that are not complete yet
clipRect
protected void clipRect(float x,
float y,
float width,
float height)
Clip a rectangular area.
write a clipping operation given coordinates in the current
transform.
- clipRect in interface AbstractPathOrientedRenderer
x
- the x coordinatey
- the y coordinatewidth
- the width of the areaheight
- the height of the area
closePath
protected void closePath()
Closes the current subpath by appending a straight line segment from
the current point to the starting point of the subpath.
- closePath in interface AbstractPathOrientedRenderer
closeText
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
comment
protected void comment(String text)
writes out a comment.
text
- text for the comment
createRendererContext
protected RendererContext createRendererContext(int x,
int y,
int width,
int height,
Map foreignAttributes)
- createRendererContext in interface PrintRenderer
org.apache.fop.render.PrintRenderer.createRendererContext(
int, int, int, int, java.util.Map)
escapeText
public void escapeText(String s,
int[] letterAdjust,
Font fs,
AbstractTextArea parentArea,
boolean useMultiByte,
StringBuffer pdf)
Escapes text according to PDF rules.
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 text
finishIDGoTo
protected void finishIDGoTo(PDFGoTo gt,
Point2D.Float position)
Set XY position in the PDFGoTo and add it to the PDF trailer.
gt
- the PDFGoTo objectposition
- the X,Y position to set
finishIDGoTo
protected void finishIDGoTo(PDFGoTo gt,
String pdfPageRef,
Point2D.Float position)
Set page reference and XY position in the PDFGoTo and add it to the PDF trailer.
gt
- the PDFGoTo objectpdfPageRef
- the PDF reference string of the target page objectposition
- the X,Y position to set
finishOpenGoTos
protected void finishOpenGoTos()
Checks if there are any unfinished PDFGoTos left in the list and resolves them
to a default position on the page. Logs a warning, as this should not happen.
format
protected static final String format(float value)
Formats a float value (normally coordinates) as Strings.
getPDFGoToForID
protected PDFGoTo getPDFGoToForID(String targetID,
String pvKey)
Get a PDFGoTo pointing to the given id. Create one if necessary.
It is possible that the PDFGoTo is not fully resolved yet. In that case
it must be completed (and added to the PDF trailer) later.
targetID
- the target id of the PDFGoTopvKey
- the unique key of the target PageViewport
- the PDFGoTo that was found or created
getTargetableID
protected String getTargetableID(Area area)
Returns area's id if it is the first area in the document with that id
(i.e. if the area qualifies as a link target).
Otherwise, or if the area has no id, null is returned.
NOTE : area must be on currentPageViewport, otherwise result may be wrong!
area
- the area for which to return the id
handleRegionTraits
protected void handleRegionTraits(RegionViewport region)
Handle the traits for a region
This is used to draw the traits for the given page region.
(See Sect. 6.4.1.2 of XSL-FO spec.)
- handleRegionTraits in interface AbstractPathOrientedRenderer
region
- the RegionViewport whose region is to be drawn
lineTo
protected void lineTo(float x,
float y)
Appends a straight line segment from the current point to (x, y). The
new current point is (x, y).
- lineTo in interface AbstractPathOrientedRenderer
x
- x coordinatey
- y coordinate
moveTo
protected void moveTo(float x,
float y)
Moves the current point to (x, y), omitting any connecting line segment.
- moveTo in interface AbstractPathOrientedRenderer
x
- x coordinatey
- y coordinate
placeImage
protected void placeImage(float x,
float y,
float w,
float h,
int xobj)
Places a previously registered image at a certain place on the page.
x
- X coordinatey
- Y coordinatew
- width for imageh
- height for imagexobj
- object number of the referenced image
preparePage
public void preparePage(PageViewport page)
The pdf page is prepared by making the page.
The page is made in the pdf document without any contents
and then stored to add the contents later.
The page objects is stored using the area tree PageViewport
as a key.
- preparePage in interface Renderer
- preparePage in interface AbstractRenderer
page
- the page to prepare
putImage
protected void putImage(String url,
Rectangle2D pos)
Adds a PDF XObject (a bitmap) to the PDF that will later be referenced.
url
- URL of the bitmappos
- Position of the bitmap
renderBookmarkTree
protected void renderBookmarkTree(BookmarkData bookmarks)
Renders a Bookmark-Tree object
bookmarks
- the BookmarkData object containing all the Bookmark-Items
renderInlineParent
public void renderInlineParent(InlineParent ip)
Render inline parent area.
For pdf this handles the inline parent area traits such as
links, border, background.
- renderInlineParent in interface AbstractRenderer
ip
- the inline parent area
renderLeader
public void renderLeader(Leader area)
Render leader area.
This renders a leader area which is an area with a rule.
- renderLeader in interface AbstractRenderer
area
- the leader area to render
saveAbsolutePosition
protected void saveAbsolutePosition(String id,
String pdfPageRef,
int relativeIPP,
int relativeBPP,
AffineTransform tf)
Saves id's absolute position on page for later retrieval by PDFGoTos
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 points
saveAbsolutePosition
protected void saveAbsolutePosition(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
id
- the id of the area whose position must be savedrelativeIPP
- the *relative* IP position in millipointsrelativeBPP
- the *relative* BP position in millipoints
saveBlockPosIfTargetable
protected void saveBlockPosIfTargetable(Block block)
If the given block area is a possible link target, its id + absolute position will
be saved. The saved position is only correct if this function is called at the very
start of renderBlock!
block
- the block area in question
saveInlinePosIfTargetable
protected void saveInlinePosIfTargetable(InlineArea inlineArea)
If the given inline area is a possible link target, its id + absolute position will
be saved. The saved position is only correct if this function is called at the very
start of renderInlineArea!
inlineArea
- the inline area in question
setAMode
public void setAMode(PDFAMode mode)
setColor
protected void setColor(Color col,
boolean fill,
StringBuffer pdf)
Establishes a new foreground or fill color. In contrast to updateColor
this method does not check the PDFState for optimization possibilities.
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.
setFilterMap
public void setFilterMap(Map filterMap)
setOutputProfileURI
public void setOutputProfileURI(String outputProfileURI)
setXMode
public void setXMode(PDFXMode mode)
startPageSequence
public void startPageSequence(LineArea seqTitle)
Start the next page sequence.
For the pdf renderer there is no concept of page sequences
but it uses the first available page sequence title to set
as the title of the pdf document.
- startPageSequence in interface Renderer
- startPageSequence in interface AbstractRenderer
seqTitle
- the title of the page sequence