public class PDFDocumentGraphics2D extends PDFGraphics2D
PDFGraphics2D
that
is used to create a full document around the PDF rendering from
PDFGraphics2D
.PDFGraphics2D
PDFGraphics2D.TransparencyIgnoredEventListener
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_NATIVE_DPI
Default device resolution (300dpi is a resonable quality for most purposes)
|
protected java.awt.Shape |
initialClip
Initial clipping area, used to restore to original setting
when a new page is started.
|
protected java.awt.geom.AffineTransform |
initialTransform
Initial transformation matrix, used to restore to original
setting when a new page is started.
|
static int |
NORMAL_PDF_RESOLUTION
Normal PDF resolution (72dpi)
|
baseLevel, colorHandler, currentFontName, currentFontSize, currentStream, fontInfo, nativeCount, outputStream, ovFontState, pageRef, paintingState, pdfDoc, resourceContext
Constructor and Description |
---|
PDFDocumentGraphics2D()
Create a new PDFDocumentGraphics2D.
|
PDFDocumentGraphics2D(boolean textAsShapes)
Create a new PDFDocumentGraphics2D.
|
PDFDocumentGraphics2D(boolean textAsShapes,
java.io.OutputStream stream,
int width,
int height)
Create a new PDFDocumentGraphics2D.
|
PDFDocumentGraphics2D(PDFDocumentGraphics2D g)
This constructor supports the create method
|
Modifier and Type | Method and Description |
---|---|
protected void |
closePage()
Closes the current page and adds it to the PDF file.
|
java.awt.Graphics |
create()
Creates a new
Graphics object that is
a copy of this Graphics object. |
void |
drawString(java.lang.String s,
float x,
float y)
Draw a string to the pdf document.
|
void |
finish()
The rendering process has finished.
|
float |
getDeviceDPI() |
FontInfo |
getFontInfo()
Get the font info for this pdf document.
|
PDFContext |
getPDFContext()
Return the PDFContext for this instance.
|
PDFDocument |
getPDFDocument()
Get the pdf document created by this class.
|
void |
nextPage()
Is called to prepare the PDFDocumentGraphics2D for the next page to be painted.
|
void |
nextPage(int width,
int height)
Is called to prepare the PDFDocumentGraphics2D for the next page to be painted.
|
protected void |
preparePainting()
This method is used by PDFDocumentGraphics2D to prepare a new page if
necessary.
|
void |
setBackgroundColor(java.awt.Color col)
Set the background of the pdf document.
|
void |
setDeviceDPI(float deviceDPI)
Set the device resolution for rendering.
|
void |
setFontInfo(FontInfo fontInfo)
Sets the font info for this PDF document.
|
void |
setSVGDimension(float w,
float h)
Set the dimensions of the svg document that will be drawn.
|
void |
setupDefaultFontInfo()
Setup a default FontInfo instance if none has been setup before.
|
void |
setupDocument(java.io.OutputStream stream,
int width,
int height)
Setup the document.
|
protected void |
startPage()
Called to prepare a new page
|
addLink, addNativeImage, applyAlpha, applyColor, applyPaint, applyStroke, applyUnknownPaint, copyArea, dispose, doDrawing, draw, drawImage, drawImage, drawInnerRenderedImage, drawRenderableImage, drawRenderedImage, fill, getBaseTransform, getBuffer, getDeviceConfiguration, getFontMetrics, getInternalFontForAWTFont, getPageReference, getString, handleIOException, isMultiByteFont, isTransparencyAllowed, processPathIterator, registerFunction, registerPattern, registerShading, setGraphicContext, setOutputStream, setOverrideFontState, setPaintingState, setXORMode, updateCurrentFont, writeClip
addRenderingHints, clearRect, clip, clipRect, drawArc, drawGlyphVector, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolyline, drawRect, drawRoundRect, drawString, drawString, drawString, fillArc, fillOval, fillPolygon, fillRect, fillRoundRect, getBackground, getClip, getClipBounds, getColor, getComposite, getFont, getFontRenderContext, getGraphicContext, getPaint, getRenderingHint, getRenderingHints, getStroke, getTransform, hit, rotate, rotate, scale, setBackground, setClip, setClip, setColor, setComposite, setFont, setPaint, setPaintMode, setRenderingHint, setRenderingHints, setStroke, setTransform, shear, transform, translate, translate
public static final int NORMAL_PDF_RESOLUTION
public static final int DEFAULT_NATIVE_DPI
protected java.awt.Shape initialClip
protected java.awt.geom.AffineTransform initialTransform
public PDFDocumentGraphics2D(boolean textAsShapes)
textAsShapes
- set this to true so that text will be rendered
using curves and not the font.public PDFDocumentGraphics2D(boolean textAsShapes, java.io.OutputStream stream, int width, int height) throws java.io.IOException
textAsShapes
- set this to true so that text will be rendered
using curves and not the font.stream
- the stream that the final document should be written to.width
- the width of the document (in points)height
- the height of the document (in points)java.io.IOException
- an io exception if there is a problem
writing to the output streampublic PDFDocumentGraphics2D()
public PDFDocumentGraphics2D(PDFDocumentGraphics2D g)
g
- the pdf document graphics to make a copy ofpublic void setupDocument(java.io.OutputStream stream, int width, int height) throws java.io.IOException
stream
- the output stream to write the documentwidth
- the width of the pageheight
- the height of the pagejava.io.IOException
- an io exception if there is a problem
writing to the output streampublic void setupDefaultFontInfo()
public void setDeviceDPI(float deviceDPI)
deviceDPI
- the device resolution (in dpi)public float getDeviceDPI()
public void setFontInfo(FontInfo fontInfo)
fontInfo
- the font info object with all the fontspublic FontInfo getFontInfo()
public PDFDocument getPDFDocument()
public PDFContext getPDFContext()
public void setSVGDimension(float w, float h)
w
- the width of the pageh
- the height of the pagepublic void setBackgroundColor(java.awt.Color col)
col
- the background colour to fillpublic void nextPage()
public void nextPage(int width, int height)
width
- the width of the new page (in points)height
- the height of the new page (in points)protected void closePage()
protected void preparePainting()
preparePainting
in class PDFGraphics2D
protected void startPage() throws java.io.IOException
java.io.IOException
- if starting the new page fails due to I/O errors.public void finish() throws java.io.IOException
java.io.IOException
- an io exception if there is a problem
writing to the output streampublic java.awt.Graphics create()
Graphics
object that is
a copy of this Graphics
object.create
in class PDFGraphics2D
public void drawString(java.lang.String s, float x, float y)
drawString
in class PDFGraphics2D
s
- the string to drawx
- the x positiony
- the y positionAbstractGraphics2D.setPaint(java.awt.Paint)
,
Graphics.setColor(java.awt.Color)
,
Graphics.setFont(java.awt.Font)
,
AbstractGraphics2D.setTransform(java.awt.geom.AffineTransform)
,
AbstractGraphics2D.setComposite(java.awt.Composite)
,
AbstractGraphics2D.setClip(int, int, int, int)
Copyright 1999-2017 The Apache Software Foundation. All Rights Reserved.