public class PDFDocumentGraphics2D extends PDFGraphics2D
PDFGraphics2D that
is used to create a full document around the PDF rendering from
PDFGraphics2D.PDFGraphics2DPDFGraphics2D.TransparencyIgnoredEventListener| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_NATIVE_DPI
Default device resolution (300dpi is a resonable quality for most purposes)
|
protected Shape |
initialClip
Initial clipping area, used to restore to original setting
when a new page is started.
|
protected 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,
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.
|
Graphics |
create()
Creates a new
Graphics object that is
a copy of this Graphics object. |
void |
drawString(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(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(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, writeClipaddRenderingHints, 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, translatedraw3DRect, fill3DRectcreate, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toStringpublic static final int NORMAL_PDF_RESOLUTION
public static final int DEFAULT_NATIVE_DPI
protected Shape initialClip
protected 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,
OutputStream stream,
int width,
int height)
throws 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)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(OutputStream stream, int width, int height) throws IOException
stream - the output stream to write the documentwidth - the width of the pageheight - the height of the pageIOException - 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(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 PDFGraphics2Dprotected void startPage()
throws IOException
IOException - if starting the new page fails due to I/O errors.public void finish()
throws IOException
IOException - an io exception if there is a problem
writing to the output streampublic Graphics create()
Graphics object that is
a copy of this Graphics object.create in class PDFGraphics2Dpublic void drawString(String s, float x, float y)
drawString in class PDFGraphics2Ds - 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 © 2023 Apache Software Foundation. All rights reserved.