GraphicsState

GraphicsState

Overview

GraphicsState is a class in Aspose.Pdf FOSS for Java. Inherits from: Cloneable.

Tracks the mutable graphics state during PDF page rendering (ISO 32000-1:2008, §8.4).

Properties

NameTypeAccessDescription
cTMMatrixReadReturns the current transformation matrix.
fillColorjava.awt.ColorReadReturns the fill color as an AWT color.
fillPatternNameStringReadReturns the current fill Pattern name (or null for solid colour fill).
strokePatternNameStringReadReturns the current stroke Pattern name (or null).
strokeColorjava.awt.ColorReadReturns the stroke color as an AWT color.
lineWidthdoubleReadReturns the line width in user units.
lineCapintReadReturns the line cap style (0=butt, 1=round, 2=square).
lineJoinintReadReturns the line join style (0=miter, 1=round, 2=bevel).
miterLimitdoubleReadReturns the miter limit.
dashArrayfloat[]ReadReturns the dash array, or null for solid lines.
dashPhasefloatReadReturns the dash phase.
strokingAlphafloatReadReturns the stroking alpha (0..1).
nonStrokingAlphafloatReadReturns the non-stroking (fill) alpha (0..1).
fontNameStringReadReturns the current font resource name (e.g., “F1”).
fontSizedoubleReadReturns the current font size.
charSpacingdoubleReadReturns the character spacing in text-space units.
wordSpacingdoubleReadReturns the word spacing in text-space units.
horizontalScalingdoubleReadReturns the horizontal text scaling (percentage, 100 = normal).
textLeadingdoubleReadReturns the text leading.
textRenderingModeintReadReturns the text rendering mode (0-7).
textRisedoubleReadReturns the text rise.
textMatrixMatrixReadReturns the text matrix (Tm).
textLineMatrixMatrixReadReturns the text line matrix (Tlm).
currentPathGeneralPathReadReturns the current path.
clipPathGeneralPathReadReturns the current clipping path, or null if not set.
pendingClipEvenOddbooleanReadReturns true if the pending clip uses even-odd rule.

Methods

SignatureDescription
GraphicsState()Creates a new graphics state with PDF default values.
clone()GraphicsState
getCTM()MatrixReturns the current transformation matrix.
setCTM(ctm: Matrix)Sets the current transformation matrix.
concatMatrix(matrix: Matrix)Concatenates a matrix onto the CTM: ctm = matrix × ctm.
getFillColor()java.awt.ColorReturns the fill color as an AWT color.
getFillPatternName()StringReturns the current fill Pattern name (or null for solid colour fill).
setFillPatternName(n: String)Stores a Pattern resource name as the fill source.
getStrokePatternName()StringReturns the current stroke Pattern name (or null).
setStrokePatternName(n: String)Stores a Pattern resource name as the stroke source.
setFillColorRGB(r: double, g: double, b: double)Sets the fill color from PDF RGB components (0..1).
setFillColorGray(gray: double)Sets the fill color from a PDF gray value (0..1).
setFillColorCMYK(c: double, m: double, y: double, k: double)Sets the fill color from PDF CMYK components (0..1).
setFillColor(color: java.awt.Color)Sets the fill color directly.
getStrokeColor()java.awt.ColorReturns the stroke color as an AWT color.
setStrokeColorRGB(r: double, g: double, b: double)Sets the stroke color from PDF RGB components (0..1).
setStrokeColorGray(gray: double)Sets the stroke color from a PDF gray value (0..1).
setStrokeColorCMYK(c: double, m: double, y: double, k: double)Sets the stroke color from PDF CMYK components (0..1).
setStrokeColor(color: java.awt.Color)Sets the stroke color directly.
getLineWidth()doubleReturns the line width in user units.
setLineWidth(w: double)Sets the line width.
getLineCap()intReturns the line cap style (0=butt, 1=round, 2=square).
setLineCap(cap: int)Sets the line cap style.
getLineJoin()intReturns the line join style (0=miter, 1=round, 2=bevel).
setLineJoin(join: int)Sets the line join style.
getMiterLimit()doubleReturns the miter limit.
setMiterLimit(limit: double)Sets the miter limit.
getDashArray()float[]Returns the dash array, or null for solid lines.
getDashPhase()floatReturns the dash phase.
setDash(array: float[], phase: float)Sets the dash pattern.
createStroke()BasicStrokeCreates an AWT BasicStroke from the current line style.
getStrokingAlpha()floatReturns the stroking alpha (0..1).
setStrokingAlpha(alpha: float)Sets the stroking alpha.
getNonStrokingAlpha()floatReturns the non-stroking (fill) alpha (0..1).
setNonStrokingAlpha(alpha: float)Sets the non-stroking alpha.
getFontName()StringReturns the current font resource name (e.g., “F1”).
setFont(name: String, size: double)Sets the current font.
getFontSize()doubleReturns the current font size.
getCharSpacing()doubleReturns the character spacing in text-space units.
setCharSpacing(cs: double)Sets the character spacing.
getWordSpacing()doubleReturns the word spacing in text-space units.
setWordSpacing(ws: double)Sets the word spacing.
getHorizontalScaling()doubleReturns the horizontal text scaling (percentage, 100 = normal).
setHorizontalScaling(hs: double)Sets the horizontal text scaling.
getTextLeading()doubleReturns the text leading.
setTextLeading(tl: double)Sets the text leading.
getTextRenderingMode()intReturns the text rendering mode (0-7).
setTextRenderingMode(mode: int)Sets the text rendering mode.
getTextRise()doubleReturns the text rise.
setTextRise(rise: double)Sets the text rise.
getTextMatrix()MatrixReturns the text matrix (Tm).
setTextMatrix(tm: Matrix)Sets the text matrix.
setTextMatrixDirect(tm: Matrix)Sets the text matrix without changing the text line matrix (for glyph advance).
getTextLineMatrix()MatrixReturns the text line matrix (Tlm).
moveTextPosition(tx: double, ty: double)Moves the text position by (tx, ty) — implements Td operator.
nextLine()Moves to the next line — implements T* operator.
beginText()Begins a text object (BT) — resets text matrix and text line matrix to identity.
getCurrentPath()GeneralPathReturns the current path.
moveTo(x: double, y: double)Begins a new subpath at (x, y).
lineTo(x: double, y: double)Appends a line from the current point to (x, y).
curveTo(x1: double, y1: double, x2: double, y2: double, x3: double, y3: double)Appends a cubic Bézier curve (c operator).
curveToV(x2: double, y2: double, x3: double, y3: double)Appends a cubic Bézier curve with first control point = current point (v operator).
curveToY(x1: double, y1: double, x3: double, y3: double)Appends a cubic Bézier curve with final control point = end point (y operator).
rect(x: double, y: double, w: double, h: double)Appends a rectangle (re operator).
closePath()Closes the current subpath (h operator).
clearPath()Clears the current path after painting or no-op.
getClipPath()GeneralPathReturns the current clipping path, or null if not set.
setClipPath(path: GeneralPath)Sets the clipping path directly.
setPendingClip()Marks a pending non-zero winding clip (W operator).
setPendingClipEvenOdd()Marks a pending even-odd clip (W* operator).
hasPendingClip()booleanReturns true if there is a pending clip to apply.
isPendingClipEvenOdd()booleanReturns true if the pending clip uses even-odd rule.
clearPendingClip()Clears the pending clip flag (after it has been applied).

See Also