public class PdfCanvas extends Object
Modifier and Type | Field and Description |
---|---|
protected PdfStream |
contentStream
the content stream for this canvas object.
|
protected CanvasGraphicsState |
currentGs
the current graphics state.
|
protected PdfDocument |
document
the document that the resulting content stream of this canvas will be written to.
|
protected Stack<CanvasGraphicsState> |
gsStack
a LIFO stack of graphics state saved states.
|
protected List<Integer> |
layerDepth
The list where we save/restore the layer depth.
|
protected int |
mcDepth
a counter variable for the marked content stack.
|
protected PdfResources |
resources
the resources for the page that this canvas belongs to.
|
Constructor and Description |
---|
PdfCanvas(PdfDocument doc,
int pageNum)
Convenience method for fast PdfCanvas creation by a certain page.
|
PdfCanvas(PdfFormXObject xObj,
PdfDocument document)
Creates a PdfCanvas from a PdfFormXObject.
|
PdfCanvas(PdfPage page)
Convenience method for fast PdfCanvas creation by a certain page.
|
PdfCanvas(PdfPage page,
boolean wrapOldContent)
Convenience method for fast PdfCanvas creation by a certain page.
|
PdfCanvas(PdfStream contentStream,
PdfResources resources,
PdfDocument document)
Creates PdfCanvas from content stream of page, form XObject, pattern etc.
|
Modifier and Type | Method and Description |
---|---|
PdfXObject |
addImageAt(ImageData image,
float x,
float y,
boolean asInline)
Creates
PdfImageXObject from image and adds it to the specified position. |
PdfXObject |
addImageFittedIntoRectangle(ImageData image,
Rectangle rect,
boolean asInline)
Creates
PdfImageXObject from image and fitted into specific rectangle on canvas. |
PdfXObject |
addImageWithTransformationMatrix(ImageData image,
float a,
float b,
float c,
float d,
float e,
float f)
Creates
PdfImageXObject from image and adds it to canvas. |
PdfXObject |
addImageWithTransformationMatrix(ImageData image,
float a,
float b,
float c,
float d,
float e,
float f,
boolean asInline)
Creates
PdfImageXObject from image and adds it to canvas. |
protected void |
addInlineImage(PdfImageXObject imageXObject,
float a,
float b,
float c,
float d,
float e,
float f)
Adds
PdfImageXObject to canvas. |
PdfCanvas |
addXObject(PdfXObject xObject)
Adds
PdfXObject on canvas. |
PdfCanvas |
addXObjectAt(PdfXObject xObject,
float x,
float y)
Adds
PdfXObject to the specified position. |
PdfCanvas |
addXObjectFittedIntoRectangle(PdfXObject xObject,
Rectangle rect)
Adds
PdfXObject fitted into specific rectangle on canvas. |
PdfCanvas |
addXObjectWithTransformationMatrix(PdfXObject xObject,
float a,
float b,
float c,
float d,
float e,
float f)
Adds
PdfXObject to canvas. |
PdfCanvas |
arc(double x1,
double y1,
double x2,
double y2,
double startAng,
double extent)
Draws a partial ellipse inscribed within the rectangle x1,y1,x2,y2,
starting at startAng degrees and covering extent degrees.
|
PdfCanvas |
arcContinuous(double x1,
double y1,
double x2,
double y2,
double startAng,
double extent)
Draws a partial ellipse with the preceding line to the start of the arc to prevent path
broking.
|
void |
attachContentStream(PdfStream contentStream)
Attaches new content stream to the canvas.
|
PdfCanvas |
beginLayer(IPdfOCG layer)
Begins a graphic block whose visibility is controlled by the
layer . |
PdfCanvas |
beginMarkedContent(PdfName tag)
Manually start a Marked Content sequence.
|
PdfCanvas |
beginMarkedContent(PdfName tag,
PdfDictionary properties)
Manually start a Marked Content sequence with properties.
|
PdfCanvas |
beginText()
Begins text block (PDF BT operator).
|
PdfCanvas |
beginVariableText()
Begins variable text block
|
static List<double[]> |
bezierArc(double x1,
double y1,
double x2,
double y2,
double startAng,
double extent)
Generates an array of bezier curves to draw an arc.
|
PdfCanvas |
circle(double x,
double y,
double r)
Draws a circle.
|
PdfCanvas |
clip()
Modify the current clipping path by intersecting it with the current path, using the
nonzero winding rule to determine which regions lie inside the clipping path.
|
PdfCanvas |
closePath()
Closes the current subpath by appending a straight line segment from the current point
to the starting point of the subpath.
|
PdfCanvas |
closePathEoFillStroke()
Closes the path, fills it using the even-odd rule to determine the region to fill and strokes it.
|
PdfCanvas |
closePathFillStroke()
Closes the path, fills it using the non-zero winding number rule to determine the region to fill and strokes it.
|
PdfCanvas |
closePathStroke()
Closes the path and strokes it.
|
PdfCanvas |
closeTag()
Manually close a tag, ending a Marked Content sequence.
|
PdfCanvas |
concatMatrix(AffineTransform transform)
Concatenates the affine transformation matrix to the current matrix
in the content stream managed by this Canvas.
|
PdfCanvas |
concatMatrix(double a,
double b,
double c,
double d,
double e,
double f)
Concatenates the 2x3 affine transformation matrix to the current matrix
in the content stream managed by this Canvas.
|
PdfCanvas |
concatMatrix(PdfArray array)
Concatenates the 2x3 affine transformation matrix to the current matrix
in the content stream managed by this Canvas.
|
PdfCanvas |
curveFromTo(double x1,
double y1,
double x3,
double y3)
Appends a Bezier curve to the path, starting from the current point.
|
PdfCanvas |
curveTo(double x2,
double y2,
double x3,
double y3)
Appends a Bezier curve to the path, starting from the current point.
|
PdfCanvas |
curveTo(double x1,
double y1,
double x2,
double y2,
double x3,
double y3)
Appends a Bêzier curve to the path, starting from the current point.
|
PdfCanvas |
ellipse(double x1,
double y1,
double x2,
double y2)
Draws an ellipse inscribed within the rectangle x1,y1,x2,y2.
|
PdfCanvas |
endLayer()
Ends OCG layer.
|
PdfCanvas |
endMarkedContent()
Manually end a Marked Content sequence.
|
PdfCanvas |
endPath()
Ends the path without filling or stroking it.
|
PdfCanvas |
endText()
Ends text block (PDF ET operator).
|
PdfCanvas |
endVariableText()
Ends variable text block
|
PdfCanvas |
eoClip()
Modify the current clipping path by intersecting it with the current path, using the
even-odd rule to determine which regions lie inside the clipping path.
|
PdfCanvas |
eoFill()
EOFills current path.
|
PdfCanvas |
eoFillStroke()
Fills the path, using the even-odd rule to determine the region to fill and strokes it.
|
PdfCanvas |
fill()
Fills current path.
|
PdfCanvas |
fillStroke()
Fills the path using the non-zero winding number rule to determine the region to fill and strokes it.
|
PdfStream |
getContentStream()
Please, use this method with caution and only if you know what you are doing.
|
PdfDocument |
getDocument()
Get the document this canvas belongs to
|
CanvasGraphicsState |
getGraphicsState()
Gets current
CanvasGraphicsState . |
PdfResources |
getResources()
Get the resources of the page that this canvas belongs to..
|
PdfCanvas |
lineTo(double x,
double y)
Appends a straight line segment from the current point (x, y).
|
PdfCanvas |
moveText(double x,
double y)
Moves text by shifting text line matrix (PDF Td operator).
|
PdfCanvas |
moveTextWithLeading(float x,
float y)
Moves to the start of the next line, offset from the start of the current line.
|
PdfCanvas |
moveTo(double x,
double y)
Move the current point (x, y), omitting any connecting line segment.
|
PdfCanvas |
newlineShowText(float wordSpacing,
float charSpacing,
String text)
Moves to the next line and shows text string, using the given values of the character and word spacing parameters.
|
PdfCanvas |
newlineShowText(String text)
Moves to the next line and shows
text . |
PdfCanvas |
newlineText()
Moves to the start of the next line.
|
PdfCanvas |
openTag(CanvasTag tag)
Manually open a canvas tag, beginning a Marked Content sequence.
|
PdfCanvas |
openTag(TagReference tagReference)
Open a tag, beginning a Marked Content sequence.
|
PdfCanvas |
paintShading(PdfShading shading)
Paints a shading object and adds it to the resources of this canvas
|
PdfCanvas |
rectangle(double x,
double y,
double width,
double height)
Draws a rectangle.
|
PdfCanvas |
rectangle(Rectangle rectangle)
Draws a rectangle.
|
void |
release()
Releases the canvas.
|
PdfCanvas |
resetFillColorCmyk()
Changes the current color for filling paths to black.
|
PdfCanvas |
resetFillColorGray()
Changes the current color for filling paths to black.
|
PdfCanvas |
resetFillColorRgb()
Changes the current color for filling paths to black.
|
PdfCanvas |
resetStrokeColorCmyk()
Changes the current color for stroking paths to black.
|
PdfCanvas |
resetStrokeColorGray()
Changes the current color for stroking paths to black.
|
PdfCanvas |
resetStrokeColorRgb()
Changes the current color for stroking paths to black.
|
PdfCanvas |
restoreState()
Restores graphics state.
|
PdfCanvas |
roundRectangle(double x,
double y,
double width,
double height,
double radius)
Draws rounded rectangle.
|
PdfCanvas |
saveState()
Saves graphics state.
|
PdfCanvas |
setCharacterSpacing(float charSpacing)
Sets the character spacing parameter.
|
PdfCanvas |
setColor(Color color,
boolean fill)
Changes the current color for paths.
|
PdfCanvas |
setColor(PdfColorSpace colorSpace,
float[] colorValue,
boolean fill)
Changes the current color for paths.
|
PdfCanvas |
setColor(PdfColorSpace colorSpace,
float[] colorValue,
PdfPattern pattern,
boolean fill)
Changes the current color for paths with an explicitly defined pattern.
|
PdfExtGState |
setExtGState(PdfDictionary extGState)
Sets the ExtGState dictionary for the current graphics state
|
PdfCanvas |
setExtGState(PdfExtGState extGState)
Sets the ExtGState dictionary for the current graphics state
|
PdfCanvas |
setFillColor(Color color)
Changes the current color for filling paths.
|
PdfCanvas |
setFillColorCmyk(float c,
float m,
float y,
float k)
Changes the current color for filling paths to a CMYK value.
|
PdfCanvas |
setFillColorGray(float g)
Changes the current color for filling paths to a grayscale value.
|
PdfCanvas |
setFillColorRgb(float r,
float g,
float b)
Changes the current color for filling paths to an RGB value.
|
PdfCanvas |
setFillColorShading(PdfPattern.Shading shading)
Adds or changes the shading of the current fill color path.
|
PdfCanvas |
setFlatnessTolerance(float flatnessTolerance)
Changes the Flatness.
|
PdfCanvas |
setFontAndSize(PdfFont font,
float size)
Sets font and size (PDF Tf operator).
|
PdfCanvas |
setHorizontalScaling(float scale)
Sets the horizontal scaling parameter.
|
PdfCanvas |
setLeading(float leading)
Sets the text leading parameter.
|
PdfCanvas |
setLineCapStyle(int lineCapStyle)
Sets the line cap style, the shape to be used at the ends of open subpaths
when they are stroked.
|
PdfCanvas |
setLineDash(float phase)
Changes the value of the line dash pattern.
|
PdfCanvas |
setLineDash(float[] array,
float phase)
Changes the value of the line dash pattern.
|
PdfCanvas |
setLineDash(float unitsOn,
float phase)
Changes the value of the line dash pattern.
|
PdfCanvas |
setLineDash(float unitsOn,
float unitsOff,
float phase)
Changes the value of the line dash pattern.
|
PdfCanvas |
setLineJoinStyle(int lineJoinStyle)
Sets the line join style, the shape to be used at the corners of paths
when they are stroked.
|
PdfCanvas |
setLineWidth(float lineWidth)
Sets line width.
|
PdfCanvas |
setMiterLimit(float miterLimit)
Sets the miter limit, a parameter specifying the maximum length a miter join
may extend beyond the join point, relative to the angle of the line segments.
|
PdfCanvas |
setRenderingIntent(PdfName renderingIntent)
Set the rendering intent.
|
PdfCanvas |
setStrokeColor(Color color)
Changes the current color for stroking paths.
|
PdfCanvas |
setStrokeColorCmyk(float c,
float m,
float y,
float k)
Changes the current color for stroking paths to a CMYK value.
|
PdfCanvas |
setStrokeColorGray(float g)
Changes the current color for stroking paths to a grayscale value.
|
PdfCanvas |
setStrokeColorRgb(float r,
float g,
float b)
Changes the current color for stroking paths to an RGB value.
|
PdfCanvas |
setStrokeColorShading(PdfPattern.Shading shading)
Adds or changes the shading of the current stroke color path.
|
PdfCanvas |
setTextMatrix(AffineTransform transform)
Replaces the text matrix.
|
PdfCanvas |
setTextMatrix(float x,
float y)
Changes the text matrix.
|
PdfCanvas |
setTextMatrix(float a,
float b,
float c,
float d,
float x,
float y)
Replaces the text matrix.
|
PdfCanvas |
setTextRenderingMode(int textRenderingMode)
Sets text rendering mode.
|
PdfCanvas |
setTextRise(float textRise)
Sets the text rise parameter.
|
PdfCanvas |
setWordSpacing(float wordSpacing)
Sets the word spacing parameter.
|
PdfCanvas |
showText(GlyphLine text)
Shows text (operator Tj).
|
PdfCanvas |
showText(GlyphLine text,
Iterator<GlyphLine.GlyphLinePart> iterator)
Shows text (operator Tj).
|
PdfCanvas |
showText(PdfArray textArray)
Shows text (operator TJ)
|
PdfCanvas |
showText(String text)
Shows text (operator Tj).
|
PdfCanvas |
stroke()
Strokes the path.
|
PdfCanvas |
writeLiteral(char c)
Outputs a
char directly to the content. |
PdfCanvas |
writeLiteral(float n)
Outputs a
float directly to the content. |
PdfCanvas |
writeLiteral(String s)
Outputs a
String directly to the content. |
protected Stack<CanvasGraphicsState> gsStack
protected CanvasGraphicsState currentGs
protected PdfStream contentStream
protected PdfResources resources
PdfResources
protected PdfDocument document
protected int mcDepth
public PdfCanvas(PdfStream contentStream, PdfResources resources, PdfDocument document)
contentStream
- The content streamresources
- The resources, a specialized dictionary that can be used by PDF instructions in the content streamdocument
- The document that the resulting content stream will be written topublic PdfCanvas(PdfPage page)
page
- page to create canvas from.public PdfCanvas(PdfPage page, boolean wrapOldContent)
page
- page to create canvas from.wrapOldContent
- true to wrap all old content streams into q/Q operators so that the state of old
content streams would not affect the new onepublic PdfCanvas(PdfFormXObject xObj, PdfDocument document)
xObj
- the PdfFormXObject used to create the PdfCanvasdocument
- the document to which the resulting content stream will be writtenpublic PdfCanvas(PdfDocument doc, int pageNum)
doc
- The documentpageNum
- The page numberpublic PdfResources getResources()
public PdfDocument getDocument()
public void attachContentStream(PdfStream contentStream)
contentStream
- a content stream to attach.public CanvasGraphicsState getGraphicsState()
CanvasGraphicsState
.public void release()
public PdfCanvas saveState()
public PdfCanvas restoreState()
public PdfCanvas concatMatrix(double a, double b, double c, double d, double e, double f)
setTextMatrix(float, float, float, float, float, float)
a
- operand 1,1 in the matrix.b
- operand 1,2 in the matrix.c
- operand 2,1 in the matrix.d
- operand 2,2 in the matrix.e
- operand 3,1 in the matrix.f
- operand 3,2 in the matrix.public PdfCanvas concatMatrix(PdfArray array)
array
- affine transformation stored as a PdfArray with 6 valuespublic PdfCanvas concatMatrix(AffineTransform transform)
transform
- affine transformation matrix to be concatenated to the current matrixconcatMatrix(double, double, double, double, double, double)
public PdfCanvas beginText()
public PdfCanvas endText()
public PdfCanvas beginVariableText()
public PdfCanvas endVariableText()
public PdfCanvas setFontAndSize(PdfFont font, float size)
font
- The fontsize
- The font size.public PdfCanvas moveText(double x, double y)
x
- x coordinate.y
- y coordinate.public PdfCanvas setLeading(float leading)
leading
- the new leading.public PdfCanvas moveTextWithLeading(float x, float y)
x
- offset of the new current pointy
- y-coordinate of the new current pointpublic PdfCanvas newlineText()
public PdfCanvas newlineShowText(String text)
text
.text
- the text to writepublic PdfCanvas newlineShowText(float wordSpacing, float charSpacing, String text)
wordSpacing
- a parametercharSpacing
- a parametertext
- the text to writepublic PdfCanvas setTextRenderingMode(int textRenderingMode)
textRenderingMode
- text rendering mode @see PdfCanvasConstants.public PdfCanvas setTextRise(float textRise)
textRise
- a parameterpublic PdfCanvas setWordSpacing(float wordSpacing)
wordSpacing
- a parameterpublic PdfCanvas setCharacterSpacing(float charSpacing)
charSpacing
- a parameterpublic PdfCanvas setHorizontalScaling(float scale)
scale
- a parameter.public PdfCanvas setTextMatrix(float a, float b, float c, float d, float x, float y)
concatMatrix(double, double, double, double, double, double)
a
- operand 1,1 in the matrix.b
- operand 1,2 in the matrix.c
- operand 2,1 in the matrix.d
- operand 2,2 in the matrix.x
- operand 3,1 in the matrix.y
- operand 3,2 in the matrix.public PdfCanvas setTextMatrix(AffineTransform transform)
concatMatrix(double, double, double, double, double, double)
transform
- new textmatrix as transformationpublic PdfCanvas setTextMatrix(float x, float y)
x
- operand 3,1 in the matrix.y
- operand 3,2 in the matrix.public PdfCanvas showText(String text)
text
- text to show.public PdfCanvas showText(GlyphLine text)
text
- text to show.public PdfCanvas showText(GlyphLine text, Iterator<GlyphLine.GlyphLinePart> iterator)
text
- text to show.iterator
- iterator over parts of the glyph line that should be wrapped into some marked content groups,
e.g. /ActualText or /ReversedCharspublic PdfCanvas showText(PdfArray textArray)
textArray
- the text array. Each element of array can be a string or a number.
If the element is a string, this operator shows the string.
If it is a number, the operator adjusts the text position by that amount.
The number is expressed in thousandths of a unit of text space.
This amount is subtracted from the current horizontal or vertical coordinate, depending on the writing mode.public PdfCanvas moveTo(double x, double y)
x
- x coordinate.y
- y coordinate.public PdfCanvas lineTo(double x, double y)
x
- x coordinate.y
- y coordinate.public PdfCanvas curveTo(double x1, double y1, double x2, double y2, double x3, double y3)
x1
- x coordinate of the first control point.y1
- y coordinate of the first control point.x2
- x coordinate of the second control point.y2
- y coordinate of the second control point.x3
- x coordinate of the ending point.y3
- y coordinate of the ending point.public PdfCanvas curveTo(double x2, double y2, double x3, double y3)
x2
- x coordinate of the second control point.y2
- y coordinate of the second control point.x3
- x coordinate of the ending point.y3
- y coordinate of the ending point.public PdfCanvas curveFromTo(double x1, double y1, double x3, double y3)
x1
- x coordinate of the first control point.y1
- y coordinate of the first control point.x3
- x coordinate of the ending point.y3
- y coordinate of the ending point.public PdfCanvas arc(double x1, double y1, double x2, double y2, double startAng, double extent)
x1
- a corner of the enclosing rectangle.y1
- a corner of the enclosing rectangle.x2
- a corner of the enclosing rectangle.y2
- a corner of the enclosing rectangle.startAng
- starting angle in degrees.extent
- angle extent in degrees.public PdfCanvas arcContinuous(double x1, double y1, double x2, double y2, double startAng, double extent)
x1
- a corner of the enclosing rectangley1
- a corner of the enclosing rectanglex2
- a corner of the enclosing rectangley2
- a corner of the enclosing rectanglestartAng
- starting angle in degreesextent
- angle extent in degreespublic PdfCanvas ellipse(double x1, double y1, double x2, double y2)
x1
- a corner of the enclosing rectangley1
- a corner of the enclosing rectanglex2
- a corner of the enclosing rectangley2
- a corner of the enclosing rectanglepublic static List<double[]> bezierArc(double x1, double y1, double x2, double y2, double startAng, double extent)
x1
- a corner of the enclosing rectangle.y1
- a corner of the enclosing rectangle.x2
- a corner of the enclosing rectangle.y2
- a corner of the enclosing rectangle.startAng
- starting angle in degrees.extent
- angle extent in degrees.public PdfCanvas rectangle(double x, double y, double width, double height)
x
- x coordinate of the starting point.y
- y coordinate of the starting point.width
- width.height
- height.public PdfCanvas rectangle(Rectangle rectangle)
rectangle
- a rectangle to be drawnpublic PdfCanvas roundRectangle(double x, double y, double width, double height, double radius)
x
- x coordinate of the starting point.y
- y coordinate of the starting point.width
- width.height
- height.radius
- radius of the arc corner.public PdfCanvas circle(double x, double y, double r)
x
- x center of circle.y
- y center of circle.r
- radius of circle.public PdfCanvas paintShading(PdfShading shading)
shading
- a shading object to be paintedpublic PdfCanvas closePath()
public PdfCanvas closePathEoFillStroke()
public PdfCanvas closePathFillStroke()
public PdfCanvas endPath()
public PdfCanvas stroke()
public PdfCanvas clip()
public PdfCanvas eoClip()
public PdfCanvas closePathStroke()
public PdfCanvas fill()
public PdfCanvas fillStroke()
public PdfCanvas eoFill()
public PdfCanvas eoFillStroke()
public PdfCanvas setLineWidth(float lineWidth)
lineWidth
- line width.public PdfCanvas setLineCapStyle(int lineCapStyle)
lineCapStyle
- a line cap style to be setfor possible values.
public PdfCanvas setLineJoinStyle(int lineJoinStyle)
lineJoinStyle
- a line join style to be setfor possible values.
public PdfCanvas setMiterLimit(float miterLimit)
miterLimit
- a miter limit to be setpublic PdfCanvas setLineDash(float phase)
phase
- the value of the phasepublic PdfCanvas setLineDash(float unitsOn, float phase)
phase
- the value of the phaseunitsOn
- the number of units that must be 'on' (equals the number of units that must be 'off').public PdfCanvas setLineDash(float unitsOn, float unitsOff, float phase)
phase
- the value of the phaseunitsOn
- the number of units that must be 'on'unitsOff
- the number of units that must be 'off'public PdfCanvas setLineDash(float[] array, float phase)
array
- length of the alternating dashes and gapsphase
- the value of the phasepublic PdfCanvas setRenderingIntent(PdfName renderingIntent)
renderingIntent
- a PdfName containing a color metricpublic PdfCanvas setFlatnessTolerance(float flatnessTolerance)
Flatness sets the maximum permitted distance in device pixels between the mathematically correct path and an approximation constructed from straight line segments.
flatnessTolerance
- a valuepublic PdfCanvas setFillColor(Color color)
color
- fill color.public PdfCanvas setStrokeColor(Color color)
color
- stroke color.public PdfCanvas setColor(Color color, boolean fill)
color
- the new color.fill
- set fill color (true
) or stroke color (false
)public PdfCanvas setColor(PdfColorSpace colorSpace, float[] colorValue, boolean fill)
colorSpace
- the color space of the new colorcolorValue
- a list of numerical values with a length corresponding to the specs of the color space. Values should be in the range [0,1]fill
- set fill color (true
) or stroke color (false
)public PdfCanvas setColor(PdfColorSpace colorSpace, float[] colorValue, PdfPattern pattern, boolean fill)
colorSpace
- the color space of the new colorcolorValue
- a list of numerical values with a length corresponding to the specs of the color space. Values should be in the range [0,1]pattern
- a pattern for the colored line or areafill
- set fill color (true
) or stroke color (false
)public PdfCanvas setFillColorGray(float g)
g
- a grayscale value in the range [0,1]public PdfCanvas setStrokeColorGray(float g)
g
- a grayscale value in the range [0,1]public PdfCanvas resetFillColorGray()
public PdfCanvas resetStrokeColorGray()
public PdfCanvas setFillColorRgb(float r, float g, float b)
r
- a red value in the range [0,1]g
- a green value in the range [0,1]b
- a blue value in the range [0,1]public PdfCanvas setStrokeColorRgb(float r, float g, float b)
r
- a red value in the range [0,1]g
- a green value in the range [0,1]b
- a blue value in the range [0,1]public PdfCanvas setFillColorShading(PdfPattern.Shading shading)
shading
- the shadingpublic PdfCanvas setStrokeColorShading(PdfPattern.Shading shading)
shading
- the shadingpublic PdfCanvas resetFillColorRgb()
public PdfCanvas resetStrokeColorRgb()
public PdfCanvas setFillColorCmyk(float c, float m, float y, float k)
c
- a cyan value in the range [0,1]m
- a magenta value in the range [0,1]y
- a yellow value in the range [0,1]k
- a key (black) value in the range [0,1]public PdfCanvas setStrokeColorCmyk(float c, float m, float y, float k)
c
- a cyan value in the range [0,1]m
- a magenta value in the range [0,1]y
- a yellow value in the range [0,1]k
- a key (black) value in the range [0,1]public PdfCanvas resetFillColorCmyk()
public PdfCanvas resetStrokeColorCmyk()
public PdfCanvas beginLayer(IPdfOCG layer)
layer
.
Blocks can be nested. Each block must be terminated by an endLayer()
.
Note that nested layers with PdfLayer.addChild(PdfLayer)
only require a single
call to this method and a single call to endLayer()
; all the nesting control
is built in.
layer
- The layer to beginpublic PdfCanvas endLayer()
public PdfXObject addImageWithTransformationMatrix(ImageData image, float a, float b, float c, float d, float e, float f)
PdfImageXObject
from image and adds it to canvas.
The float arguments will be used in concatenating the transformation matrix as operands.
image
- the image from which PdfImageXObject
will be createda
- an element of the transformation matrixb
- an element of the transformation matrixc
- an element of the transformation matrixd
- an element of the transformation matrixe
- an element of the transformation matrixf
- an element of the transformation matrixconcatMatrix(double, double, double, double, double, double)
public PdfXObject addImageWithTransformationMatrix(ImageData image, float a, float b, float c, float d, float e, float f, boolean asInline)
PdfImageXObject
from image and adds it to canvas.
The float arguments will be used in concatenating the transformation matrix as operands.
image
- the image from which PdfImageXObject
will be createda
- an element of the transformation matrixb
- an element of the transformation matrixc
- an element of the transformation matrixd
- an element of the transformation matrixe
- an element of the transformation matrixf
- an element of the transformation matrixasInline
- true if to add image as in-lineconcatMatrix(double, double, double, double, double, double)
public PdfXObject addImageFittedIntoRectangle(ImageData image, Rectangle rect, boolean asInline)
PdfImageXObject
from image and fitted into specific rectangle on canvas.
The created imageXObject will be fit inside on the specified rectangle without preserving aspect ratio.
The x, y, width and height parameters of the rectangle will be used in concatenating the transformation matrix as operands.
image
- the image from which PdfImageXObject
will be createdrect
- the rectangle in which the created imageXObject will be fitasInline
- true if to add image as in-lineconcatMatrix(double, double, double, double, double, double)
,
PdfXObject.calculateProportionallyFitRectangleWithWidth(PdfXObject, float, float, float)
,
PdfXObject.calculateProportionallyFitRectangleWithHeight(PdfXObject, float, float, float)
public PdfXObject addImageAt(ImageData image, float x, float y, boolean asInline)
PdfImageXObject
from image and adds it to the specified position.image
- the image from which PdfImageXObject
will be createdx
- the horizontal position of the imageXObjecty
- the vertical position of the imageXObjectasInline
- true if to add image as in-linepublic PdfCanvas addXObjectWithTransformationMatrix(PdfXObject xObject, float a, float b, float c, float d, float e, float f)
PdfXObject
to canvas.
The float arguments will be used in concatenating the transformation matrix as operands.
xObject
- the xObject to adda
- an element of the transformation matrixb
- an element of the transformation matrixc
- an element of the transformation matrixd
- an element of the transformation matrixe
- an element of the transformation matrixf
- an element of the transformation matrixconcatMatrix(double, double, double, double, double, double)
public PdfCanvas addXObjectAt(PdfXObject xObject, float x, float y)
PdfXObject
to the specified position.xObject
- the xObject to addx
- the horizontal position of the xObjecty
- the vertical position of the xObjectpublic PdfCanvas addXObjectFittedIntoRectangle(PdfXObject xObject, Rectangle rect)
PdfXObject
fitted into specific rectangle on canvas.xObject
- the xObject to addrect
- the rectangle in which the xObject will be fittedPdfXObject.calculateProportionallyFitRectangleWithWidth(PdfXObject, float, float, float)
,
PdfXObject.calculateProportionallyFitRectangleWithHeight(PdfXObject, float, float, float)
public PdfCanvas addXObject(PdfXObject xObject)
PdfXObject
on canvas.
Note: the PdfImageXObject
will be placed at coordinates (0, 0) with its
original width and height, the PdfFormXObject
will be fitted in its bBox.
xObject
- the xObject to addpublic PdfCanvas setExtGState(PdfExtGState extGState)
extGState
- a dictionary that maps resource names to graphics state parameter dictionariespublic PdfExtGState setExtGState(PdfDictionary extGState)
extGState
- a dictionary that maps resource names to graphics state parameter dictionariespublic PdfCanvas beginMarkedContent(PdfName tag)
tag
- the type of content containedpublic PdfCanvas beginMarkedContent(PdfName tag, PdfDictionary properties)
tag
- the type of content that will be containedproperties
- the properties of the content, including Marked Content ID. If null, the PDF marker is BMC, else it is BDCpublic PdfCanvas endMarkedContent()
public PdfCanvas openTag(CanvasTag tag)
tag
- the type of content that will be containedpublic PdfCanvas openTag(TagReference tagReference)
tagReference
- reference to the tag from the document logical structurepublic PdfCanvas closeTag()
public PdfCanvas writeLiteral(String s)
String
directly to the content.s
- the String
public PdfCanvas writeLiteral(char c)
char
directly to the content.c
- the char
public PdfCanvas writeLiteral(float n)
float
directly to the content.n
- the float
public PdfStream getContentStream()
protected void addInlineImage(PdfImageXObject imageXObject, float a, float b, float c, float d, float e, float f)
PdfImageXObject
to canvas.imageXObject
- the PdfImageXObject
objecta
- an element of the transformation matrixb
- an element of the transformation matrixc
- an element of the transformation matrixd
- an element of the transformation matrixe
- an element of the transformation matrixf
- an element of the transformation matrixCopyright © 1998–2023 Apryse Group NV. All rights reserved.