Klasse PdfBoxGraphics2D
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic booleanGlobal Flag: If set to true the Callstack when creating a context is recorded. -
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungPdfBoxGraphics2D(org.apache.pdfbox.pdmodel.PDDocument document, float pixelWidth, float pixelHeight) Create a PDfBox Graphics2D.PdfBoxGraphics2D(org.apache.pdfbox.pdmodel.PDDocument document, int pixelWidth, int pixelHeight) Create a PDfBox Graphics2D.PdfBoxGraphics2D(org.apache.pdfbox.pdmodel.PDDocument document, org.apache.pdfbox.pdmodel.common.PDRectangle bbox) -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidaddRenderingHints(Map<?, ?> hints) voidclearRect(int x, int y, int width, int height) voidvoidclipRect(int x, int y, int width, int height) voidcopyArea(int x, int y, int width, int height, int dx, int dy) create()Creates a copy of this graphics object.create(int x, int y, int width, int height) voiddispose()voidvoidvoiddrawArc(int x, int y, int width, int height, int startAngle, int arcAngle) voiddrawGlyphVector(GlyphVector g, float x, float y) voiddrawImage(BufferedImage img, BufferedImageOp op, int x, int y) booleandrawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) booleandrawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) booleandrawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) booleandrawImage(Image img, int x, int y, int width, int height, ImageObserver observer) booleandrawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) booleandrawImage(Image img, int x, int y, ImageObserver observer) booleandrawImage(Image img, AffineTransform xform, ImageObserver obs) voiddrawInMarkedContentSequence(org.apache.pdfbox.cos.COSName tagName, IPdfBoxGraphics2DMarkedContentDrawer drawer) Draw on the Graphics2D and enclose the drawing command with a BMC/EMC content marking pair.voiddrawInMarkedContentSequence(org.apache.pdfbox.cos.COSName tagName, org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDPropertyList properties, IPdfBoxGraphics2DMarkedContentDrawer drawer) Draw on the Graphics2D and enclose the drawing command with a BDC/EMC content marking pair.voiddrawLine(int x1, int y1, int x2, int y2) voiddrawOval(int x, int y, int width, int height) voiddrawPolygon(int[] xPoints, int[] yPoints, int nPoints) voiddrawPolyline(int[] xPoints, int[] yPoints, int nPoints) voiddrawRect(int x, int y, int width, int height) voiddrawRenderableImage(RenderableImage img, AffineTransform xform) voiddrawRenderedImage(RenderedImage img, AffineTransform xform) voiddrawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) voiddrawString(String str, float x, float y) voiddrawString(String str, int x, int y) voiddrawString(AttributedCharacterIterator iterator, float x, float y) voiddrawString(AttributedCharacterIterator iterator, int x, int y) voidvoidfillArc(int x, int y, int width, int height, int startAngle, int arcAngle) voidfillOval(int x, int y, int width, int height) voidfillPolygon(int[] xPoints, int[] yPoints, int nPoints) voidfillRect(int x, int y, int width, int height) voidfillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) getClip()getColor()getFont()getPaint()getRenderingHint(RenderingHints.Key hintKey) org.apache.pdfbox.pdmodel.PDResourcesSometimes you need to access the PDResources and add special resources to it for some stuff (e.g. patterns of embedded PDFs or simmilar).org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject*AFTER* you have disposed() this Graphics2D you can access the XFormbooleanvoidrotate(double theta) voidrotate(double theta, double x, double y) voidscale(double sx, double sy) voidsetBackground(Color color) voidsetClip(int x, int y, int width, int height) voidvoidvoidsetColorMapper(IPdfBoxGraphics2DColorMapper colorMapper) Set a new color mapper.voidsetComposite(Composite comp) voidsetDrawControl(IPdfBoxGraphics2DDrawControl drawControl) Set a new draw control.voidvoidsetFontTextDrawer(IPdfBoxGraphics2DFontTextDrawer fontTextDrawer) Set an optional text drawer.voidsetImageEncoder(IPdfBoxGraphics2DImageEncoder imageEncoder) Set a new image encodervoidvoidsetPaintApplier(IPdfBoxGraphics2DPaintApplier paintApplier) Set a new paint applier.voidvoidsetRenderingHint(RenderingHints.Key hintKey, Object hintValue) voidsetRenderingHints(Map<?, ?> hints) voidvoidvoidsetXORMode(Color c1) XOR Mode is currently not implemented as it's not possible in PDF.voidshear(double shx, double shy) voidvoidtranslate(double tx, double ty) voidtranslate(int x, int y) Von Klasse geerbte Methoden java.awt.Graphics2D
draw3DRect, fill3DRectVon Klasse geerbte Methoden java.awt.Graphics
drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
-
Felddetails
-
ENABLE_CHILD_CREATING_DEBUG
public static boolean ENABLE_CHILD_CREATING_DEBUGGlobal Flag: If set to true the Callstack when creating a context is recorded.Note: Setting this to true will slow down the library. Use this only for debugging.
-
-
Konstruktordetails
-
PdfBoxGraphics2D
public PdfBoxGraphics2D(org.apache.pdfbox.pdmodel.PDDocument document, int pixelWidth, int pixelHeight) throws IOException Create a PDfBox Graphics2D. This size is used for the BBox of the XForm. So everything drawn outside the rectangle (0x0)-(pixelWidth,pixelHeight) will be clipped.Note: pixelWidth and pixelHeight only define the size of the coordinate space within this Graphics2D. They do not affect how big the XForm is finally displayed in the PDF.
- Parameter:
document- The document the graphics should be used to create a XForm in.pixelWidth- the width in pixel of the drawing area.pixelHeight- the height in pixel of the drawing area.- Löst aus:
IOException- if something goes wrong with writing into the content stream of thePDDocument.
-
PdfBoxGraphics2D
public PdfBoxGraphics2D(org.apache.pdfbox.pdmodel.PDDocument document, float pixelWidth, float pixelHeight) throws IOException Create a PDfBox Graphics2D. This size is used for the BBox of the XForm. So everything drawn outside the rectangle (0x0)-(pixelWidth,pixelHeight) will be clipped.Note: pixelWidth and pixelHeight only define the size of the coordinate space within this Graphics2D. They do not affect how big the XForm is finally displayed in the PDF.
- Parameter:
document- The document the graphics should be used to create a XForm in.pixelWidth- the width in pixel of the drawing area.pixelHeight- the height in pixel of the drawing area.- Löst aus:
IOException- if something goes wrong with writing into the content stream of thePDDocument.
-
PdfBoxGraphics2D
public PdfBoxGraphics2D(org.apache.pdfbox.pdmodel.PDDocument document, org.apache.pdfbox.pdmodel.common.PDRectangle bbox) throws IOException - Parameter:
document- The document the graphics should be used to create a XForm in.bbox- Bounding Box of the graphics- Löst aus:
IOException- when something goes wrong with writing into the content stream of thePDDocument.
-
-
Methodendetails
-
setColorMapper
Set a new color mapper.- Parameter:
colorMapper- the color mapper which maps Color to PDColor.
-
setImageEncoder
Set a new image encoder- Parameter:
imageEncoder- the image encoder, which encodes an image as PDImageXForm.
-
setPaintApplier
Set a new paint applier. You should always derive your custom paint applier from theIPdfBoxGraphics2DPaintApplierand just extend the paint mapping for custom paint.If the paint you map is a paint from a standard library, and you can implement the mapping using reflection please feel free to send a pull request to extend the default paint mapper.
- Parameter:
paintApplier- the paint applier responsible for mapping the paint correctly
-
setDrawControl
Set a new draw control. This allows you to influence fill() and draw() operations. drawString() is only influence if the text is drawn as vector shape.- Parameter:
drawControl- the draw control
-
setFontTextDrawer
Set an optional text drawer. By default, all text is vectorized and drawn using vector shapes. To embed fonts into a PDF file it is necessary to have the underlying TTF file. The java.awt.Font class does not provide that. The FontTextDrawer must perform the java.awt.Font <=> PDFont mapping and also must perform the text layout. If it can not map the text or font correctly, the font drawing falls back to vectoring the text.- Parameter:
fontTextDrawer- The text drawer, which can draw text using fonts
-
getResources
public org.apache.pdfbox.pdmodel.PDResources getResources()Sometimes you need to access the PDResources and add special resources to it for some stuff (e.g. patterns of embedded PDFs or simmilar). For that you need the PDResources associated with the XForm.It's identlical with getXFormObject().getResources(), with the difference beeing that you can access it while the Graphics2D is not yet disposed.
- Gibt zurück:
- the PDResources of the resulting XForm
-
getXFormObject
public org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject getXFormObject()*AFTER* you have disposed() this Graphics2D you can access the XForm- Gibt zurück:
- the PDFormXObject which resulted in this graphics
-
disposeDanglingChildGraphics
public void disposeDanglingChildGraphics()Sometimes the users ofcreate()don't correctlydispose()the child graphics they create. And you may not always be able to fix this uses, as it may be in some 3rdparty library. In this case this method can help you. It will cleanup all dangling child graphics. The child graphics can not be used after that. This method is a workaround for a buggy old code. You should only use it if you have to.
Note: You can only call this method on the "main" graphics, not on a child created with
create() -
dispose
public void dispose() -
draw
- Angegeben von:
drawin KlasseGraphics2D
-
drawImage
- Angegeben von:
drawImagein KlasseGraphics2D
-
drawRenderedImage
- Angegeben von:
drawRenderedImagein KlasseGraphics2D
-
drawRenderableImage
- Angegeben von:
drawRenderableImagein KlasseGraphics2D
-
drawString
- Angegeben von:
drawStringin KlasseGraphics2D
-
drawString
- Angegeben von:
drawStringin KlasseGraphics2D
-
drawString
- Angegeben von:
drawStringin KlasseGraphics2D
-
drawImage
-
drawImage
-
drawImage
-
drawImage
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) -
drawImage
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) -
drawImage
- Angegeben von:
drawImagein KlasseGraphics2D
-
drawImage
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) -
drawString
- Angegeben von:
drawStringin KlasseGraphics2D
-
drawGlyphVector
- Angegeben von:
drawGlyphVectorin KlasseGraphics2D
-
fill
- Angegeben von:
fillin KlasseGraphics2D
-
hit
- Angegeben von:
hitin KlasseGraphics2D
-
getDeviceConfiguration
- Angegeben von:
getDeviceConfigurationin KlasseGraphics2D
-
setComposite
- Angegeben von:
setCompositein KlasseGraphics2D
-
setPaint
- Angegeben von:
setPaintin KlasseGraphics2D
-
setStroke
- Angegeben von:
setStrokein KlasseGraphics2D
-
setRenderingHint
- Angegeben von:
setRenderingHintin KlasseGraphics2D
-
getRenderingHint
- Angegeben von:
getRenderingHintin KlasseGraphics2D
-
setRenderingHints
- Angegeben von:
setRenderingHintsin KlasseGraphics2D
-
addRenderingHints
- Angegeben von:
addRenderingHintsin KlasseGraphics2D
-
getRenderingHints
- Angegeben von:
getRenderingHintsin KlasseGraphics2D
-
create
Creates a copy of this graphics object. Please calldispose()always on the copy after you have finished drawing with it.
Never draw both in this copy and its parent graphics at the same time, as they all write to the same content stream. This will create a broken PDF content stream. You should get anIllegalStateExceptionif you do so, but better just don't try.
The copy allows you to have different transforms, paints, etc. than the parent graphics context without affecting the parent. You may also call create() on a copy, but always remember to calldispose()in reverse order. -
drawInMarkedContentSequence
public void drawInMarkedContentSequence(org.apache.pdfbox.cos.COSName tagName, IPdfBoxGraphics2DMarkedContentDrawer drawer) Draw on the Graphics2D and enclose the drawing command with a BMC/EMC content marking pair. See the PDF Spec about "Marked Content" for details.- Parameter:
tagName- A COSName for to tag the marked contentdrawer- is called with a (child) graphics to draw on. Please do *not* dispose() this graphics. Just draw on it. Any state changes on the given graphics will be reset after the drawing is finished
-
drawInMarkedContentSequence
public void drawInMarkedContentSequence(org.apache.pdfbox.cos.COSName tagName, org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDPropertyList properties, IPdfBoxGraphics2DMarkedContentDrawer drawer) Draw on the Graphics2D and enclose the drawing command with a BDC/EMC content marking pair. See the PDF Spec about "Marked Content" for details.- Parameter:
tagName- A COSName for to tag the marked contentproperties- The properties to put by the marked sequencedrawer- is called with a (child) graphics to draw on. Please do *not* dispose() this graphics. Just draw on it. Any state changes on the given graphics will be reset after the drawing is finished
-
create
-
translate
public void translate(int x, int y) - Angegeben von:
translatein KlasseGraphics2D
-
getColor
-
setColor
-
setPaintMode
public void setPaintMode()- Angegeben von:
setPaintModein KlasseGraphics
-
setXORMode
XOR Mode is currently not implemented as it's not possible in PDF. This mode is ignored.- Angegeben von:
setXORModein KlasseGraphics- Parameter:
c1- the XORMode Color
-
getFont
-
setFont
-
getFontMetrics
- Angegeben von:
getFontMetricsin KlasseGraphics
-
getClipBounds
- Angegeben von:
getClipBoundsin KlasseGraphics
-
clipRect
public void clipRect(int x, int y, int width, int height) -
setClip
public void setClip(int x, int y, int width, int height) -
getClip
-
setClip
-
copyArea
public void copyArea(int x, int y, int width, int height, int dx, int dy) -
drawLine
public void drawLine(int x1, int y1, int x2, int y2) -
fillRect
public void fillRect(int x, int y, int width, int height) -
drawRect
public void drawRect(int x, int y, int width, int height) -
clearRect
public void clearRect(int x, int y, int width, int height) -
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) - Angegeben von:
drawRoundRectin KlasseGraphics
-
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) - Angegeben von:
fillRoundRectin KlasseGraphics
-
drawOval
public void drawOval(int x, int y, int width, int height) -
fillOval
public void fillOval(int x, int y, int width, int height) -
drawArc
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) -
fillArc
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) -
drawPolyline
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) - Angegeben von:
drawPolylinein KlasseGraphics
-
drawPolygon
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) - Angegeben von:
drawPolygonin KlasseGraphics
-
fillPolygon
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) - Angegeben von:
fillPolygonin KlasseGraphics
-
translate
public void translate(double tx, double ty) - Angegeben von:
translatein KlasseGraphics2D
-
rotate
public void rotate(double theta) - Angegeben von:
rotatein KlasseGraphics2D
-
rotate
public void rotate(double theta, double x, double y) - Angegeben von:
rotatein KlasseGraphics2D
-
scale
public void scale(double sx, double sy) - Angegeben von:
scalein KlasseGraphics2D
-
shear
public void shear(double shx, double shy) - Angegeben von:
shearin KlasseGraphics2D
-
transform
- Angegeben von:
transformin KlasseGraphics2D
-
setTransform
- Angegeben von:
setTransformin KlasseGraphics2D
-
getTransform
- Angegeben von:
getTransformin KlasseGraphics2D
-
getPaint
- Angegeben von:
getPaintin KlasseGraphics2D
-
getComposite
- Angegeben von:
getCompositein KlasseGraphics2D
-
setBackground
- Angegeben von:
setBackgroundin KlasseGraphics2D
-
getBackground
- Angegeben von:
getBackgroundin KlasseGraphics2D
-
getStroke
- Angegeben von:
getStrokein KlasseGraphics2D
-
clip
- Angegeben von:
clipin KlasseGraphics2D
-
getFontRenderContext
- Angegeben von:
getFontRenderContextin KlasseGraphics2D
-