Class: GState

PDFNet. GState


new GState()

GState is a class that keeps track of a number of style attributes used to visually define graphical Elements. Each PDF::Element has an associated GState that can be used to query or set various graphics properties.

Methods


<static> getRenderingIntentType(name)

A utility function that maps a string representing a rendering intent to RenderingIntent type.

Parameters:
Name Type Description
name string

string that represents the rendering intent to get.

Returns:

A promise that resolves to the color rendering intent type matching the specified string

Type
number
Example
Return value enum:
<pre>
PDFNet.GState.RenderingIntent = {
	e_absolute_colorimetric : 0
	e_relative_colorimetric : 1
	e_saturation : 2
	e_perceptual : 3
}
</pre>

concat(a, b, c, d, h, v)

Concatenate the given matrix expressed in its values to the transformation matrix of this element.

Parameters:
Name Type Description
a number

horizontal 'scaling' component of the new text matrix.

b number

'rotation' component of the new text matrix.

c number

vertical 'scaling' component of the new text matrix.

d number

'rotation' component of the new text matrix.

h number

horizontal translation component of the new text matrix.

v number

vertical translation component of the new text matrix.


concatMatrix(mtx)

Concatenate the given matrix to the transformation matrix of this element.

Parameters:
Name Type Description
mtx PDFNet.matrix2d

Matrix2D object to concatenate the current matrix with.


getAISFlag()

Returns:

A promise that resolves to the alpha source flag ('alpha is shape'), specifying whether the current soft mask and alpha constant are to be interpreted as shape values (true) or opacity values (false).

Type
boolean

getAutoStrokeAdjust()

Returns:

A promise that resolves to a flag specifying whether stroke adjustment is enabled in the graphics state. Corresponds to the /SA key within the ExtGState's dictionary.

Type
boolean

getBlackGenFunct()

Returns:

A promise that resolves to currently selected black-generation function (NULL by default) used during conversion between DeviceRGB and DeviceCMYK. Corresponds to the /BG key within the ExtGState's dictionary.

Type
PDFNet.Obj

getBlendMode()

Returns:

A promise that resolves to the current blend mode to be used in the transparent imaging model. Corresponds to the /BM key within the ExtGState's dictionary.

Type
number
Example
Return value enum:
<pre>
PDFNet.GState.BlendMode = {
	e_bl_compatible : 0
	e_bl_normal : 1
	e_bl_multiply : 2
	e_bl_screen : 3
	e_bl_difference : 4
	e_bl_darken : 5
	e_bl_lighten : 6
	e_bl_color_dodge : 7
	e_bl_color_burn : 8
	e_bl_exclusion : 9
	e_bl_hard_light : 10
	e_bl_overlay : 11
	e_bl_soft_light : 12
	e_bl_luminosity : 13
	e_bl_hue : 14
	e_bl_saturation : 15
	e_bl_color : 16
}
</pre>

getCharSpacing()

Returns:

A promise that resolves to currently selected character spacing.

The character spacing parameter is a number specified in unscaled text space units. When the glyph for each character in the string is rendered, the character spacing is added to the horizontal or vertical component of the glyph's displacement, depending on the writing mode. See Section 5.2.1 in PDF Reference Manual for details.

Type
number

getFillColor()

Returns:

A promise that resolves to a color value/point represented in the current fill color space

Type
PDFNet.colorpt

getFillColorSpace()

Returns:

A promise that resolves to color space used for filling

Type
PDFNet.ColorSpace

getFillOpacity()

Returns:

A promise that resolves to the opacity value for painting operations other than stroking. Returns the value of the /ca key in the ExtGState dictionary. If the value is not found, the default value of 1 is returned.

Type
number

getFillOverprint()

Returns:

A promise that resolves to whether overprint is enabled for fill painting operations. Corresponds to the /op key within the ExtGState's dictionary.

Type
boolean

getFillPattern()

Returns:

A promise that resolves to the pattern color of currently selected pattern color space used for filling.

Type
PDFNet.PatternColor

getFlatness()

Returns:

A promise that resolves to current value of flatness tolerance

Flatness is a number in the range 0 to 100; a value of 0 specifies the output device's default flatness tolerance.

The flatness tolerance controls the maximum permitted distance in device pixels between the mathematically correct path and an approximation constructed from straight line segments.

Type
number

getFont()

Returns:

A promise that resolves to currently selected font

Type
PDFNet.Font

getFontSize()

Returns:

A promise that resolves to the font size

Type
number

getHalftone()

Returns:

A promise that resolves to currently selected halftone dictionary or stream (NULL by default). Corresponds to the /HT key within the ExtGState's dictionary. Halftoning is a process by which continuous-tone colors are approximated on an output device that can achieve only a limited number of discrete colors.

Type
PDFNet.Obj

getHorizontalScale()

Returns:

A promise that resolves to currently selected horizontal scale

The horizontal scaling parameter adjusts the width of glyphs by stretching or compressing them in the horizontal direction. Its value is specified as a percentage of the normal width of the glyphs, with 100 being the normal width. The scaling always applies to the horizontal coordinate in text space, independently of the writing mode. See Section 5.2.3 in PDF Reference Manual for details.

Type
number

getLeading()

Returns:

A promise that resolves to currently selected leading parameter

The leading parameter is measured in unscaled text space units. It specifies the vertical distance between the baselines of adjacent lines of text. See Section 5.2.4 in PDF Reference Manual for details.

Type
number

getLineCap()

Returns:

A promise that resolves to currently selected LineCap style

The line cap style specifies the shape to be used at the ends of open sub-paths (and dashes, if any) when they are stroked.

Type
number
Example
Return value enum:
<pre>
PDFNet.GState.LineCap = {
	e_butt_cap : 0
	e_round_cap : 1
	e_square_cap : 2
}
</pre>

getLineJoin()

Returns:

A promise that resolves to currently selected LineJoin style

The line join style specifies the shape to be used at the corners of paths that are stroked.

Type
number
Example
Return value enum:
<pre>
PDFNet.GState.LineJoin = {
	e_miter_join : 0
	e_round_join : 1
	e_bevel_join : 2
}
</pre>

getLineWidth()

Returns:

A promise that resolves to the thickness of the line used to stroke a path.

Type
number

getMiterLimit()

Returns:

A promise that resolves to current value of miter limit.

The miter limit imposes a maximum on the ratio of the miter length to the line width. When the limit is exceeded, the join is converted from a miter to a bevel.

Type
number

getOverprintMode()

Returns:

A promise that resolves to the overprint mode used by this graphics state. Corresponds to the /OPM key within the ExtGState's dictionary.

Type
number

getPhase()

Returns:

A promise that resolves to the phase of the currently selected dash pattern. dash phase is expressed in user space units.

Type
number

getRenderingIntent()

Returns:

A promise that resolves to the color intent to be used for rendering the Element

Type
number
Example
Return value enum:
<pre>
PDFNet.GState.RenderingIntent = {
	e_absolute_colorimetric : 0
	e_relative_colorimetric : 1
	e_saturation : 2
	e_perceptual : 3
}
</pre>

getSmoothnessTolerance()

Returns:

A promise that resolves to the smoothness tolerance used to control the quality of smooth shading. Corresponds to the /SM key within the ExtGState's dictionary. The allowable error (or tolerance) is expressed as a fraction of the range of the color component, from 0.0 to 1.0.

Type
number

getSoftMask()

Returns:

A promise that resolves to associated soft mask. NULL if the soft mask is not selected or SDF dictionary representing the soft mask otherwise.

Type
PDFNet.Obj

getSoftMaskTransform()

Returns:

A promise that resolves to the soft mask transform. This is the transformation matrix at the moment the soft mask is established in the graphics state with the gs operator. This information is only relevant when applying the soft mask that may be specified in the graphics state to the current element.

Type
PDFNet.matrix2d

getStrokeColor()

Returns:

A promise that resolves to a color value/point represented in the current stroke color space

Type
PDFNet.colorpt

getStrokeColorSpace()

Returns:

A promise that resolves to color space used for stroking

Type
PDFNet.ColorSpace

getStrokeOpacity()

Returns:

A promise that resolves to opacity value for stroke painting operations for paths and glyph outlines. Returns the value of the /CA key in the ExtGState dictionary. If the value is not found, the default value of 1 is returned.

Type
number

getStrokeOverprint()

Returns:

A promise that resolves to whether overprint is enabled for stroke painting operations. Corresponds to the /OP key within the ExtGState's dictionary.

Type
boolean

getStrokePattern()

Returns:

A promise that resolves to the SDF pattern object of currently selected PatternColorSpace used for stroking.

Type
PDFNet.PatternColor

getTextRenderMode()

Returns:

A promise that resolves to current text rendering mode.

The text rendering mode determines whether showing text causes glyph outlines to be stroked, filled, used as a clipping boundary, or some combination of the three. See Section 5.2.5 in PDF Reference Manual for details..

Type
number
Example
Return value enum:
<pre>
PDFNet.GState.TextRenderingMode = {
	e_fill_text : 0
	e_stroke_text : 1
	e_fill_stroke_text : 2
	e_invisible_text : 3
	e_fill_clip_text : 4
	e_stroke_clip_text : 5
	e_fill_stroke_clip_text : 6
	e_clip_text : 7
}
</pre>

getTextRise()

Returns:

A promise that resolves to current value of text rise

Text rise specifies the distance, in unscaled text space units, to move the baseline up or down from its default location. Positive values of text rise move the baseline up

Type
number

getTransferFunct()

Returns:

A promise that resolves to currently selected transfer function (NULL by default) used during color conversion process. A transfer function adjusts the values of color components to compensate for nonlinear response in an output device and in the human eye. Corresponds to the /TR key within the ExtGState's dictionary.

Type
PDFNet.Obj

getTransform()

Returns:

A promise that resolves to the transformation matrix for this element.

Type
PDFNet.matrix2d

getUCRFunct()

Returns:

A promise that resolves to currently selected undercolor-removal function (NULL by default) used during conversion between DeviceRGB and DeviceCMYK. Corresponds to the /UCR key within the ExtGState's dictionary.

Type
PDFNet.Obj

getWordSpacing()

Returns:

A promise that resolves to currently selected word spacing

Word spacing works the same way as character spacing, but applies only to the space character (char code 32). See Section 5.2.2 in PDF Reference Manual for details.

Type
number

isTextKnockout()

Returns:

A promise that resolves to a boolean flag that determines the text element is considered elementary objects for purposes of color compositing in the transparent imaging model.

Type
boolean

setAISFlag(AIS)

specifies if the alpha is to be interpreted as a shape or opacity mask. The alpha source flag ('alpha is shape'), specifies whether the current soft mask and alpha constant are to be interpreted as shape values (true) or opacity values (false).

Parameters:
Name Type Description
AIS boolean

true for interpretation as shape values or false for opacity values


setAutoStrokeAdjust(SA)

Specify whether to apply automatic stroke adjustment. Corresponds to the /SA key within the ExtGState's dictionary.

Parameters:
Name Type Description
SA boolean

if true automatic stroke adjustment will be applied.


setBlackGenFunct(BG)

Sets black-generation function used during conversion between DeviceRGB and DeviceCMYK. Corresponds to the /BG key within the ExtGState's dictionary.

Parameters:
Name Type Description
BG PDFNet.Obj

SDF/Cos black-generation function or name


setBlendMode(BM)

Sets the current blend mode to be used in the transparent imaging model. Corresponds to the /BM key within the ExtGState's dictionary.

Parameters:
Name Type Description
BM number/enum
PDFNet.GState.BlendMode = {
	e_bl_compatible : 0
	e_bl_normal : 1
	e_bl_multiply : 2
	e_bl_screen : 3
	e_bl_difference : 4
	e_bl_darken : 5
	e_bl_lighten : 6
	e_bl_color_dodge : 7
	e_bl_color_burn : 8
	e_bl_exclusion : 9
	e_bl_hard_light : 10
	e_bl_overlay : 11
	e_bl_soft_light : 12
	e_bl_luminosity : 13
	e_bl_hue : 14
	e_bl_saturation : 15
	e_bl_color : 16
}

New blending mode type.

// C#
gs.SetBlendMode(GState.BlendMode.e_lighten);

// C++ 
gs->SetBlendMode(GState::e_lighten);

setCharSpacing(char_spacing)

Sets character spacing.

Parameters:
Name Type Description
char_spacing number

a number specified in unscaled text space units. When the glyph for each character in the string is rendered, the character spacing is added to the horizontal or vertical component of the glyph's displacement, depending on the writing mode. See Section 5.2.1 in PDF Reference Manual for details.


setDashPattern(buf_dash_array, phase)

Parameters:
Name Type Description
buf_dash_array Array
phase number

setFillColor(pattern, c)

Set the fill color to the given uncolored tiling pattern.

Parameters:
Name Type Description
pattern PDFNet.PatternColor

PatternColor (PatternType = 1 and PaintType = 2) object.

c PDFNet.colorpt

is a color in the pattern's underlying color space.


setFillColorSpace(cs)

Sets the color space used for filling operations

Parameters:
Name Type Description
cs PDFNet.ColorSpace

ColorSpace object to use for filling operations


setFillColorWithColorPt(c)

Sets the color value/point used for filling operations.

Parameters:
Name Type Description
c PDFNet.colorpt

the color used for filling operations The color value must be represented in the currently selected color space used for filling.


setFillColorWithPattern(pattern)

Set the fill color to the given tiling pattern.

Parameters:
Name Type Description
pattern PDFNet.PatternColor

New pattern color.


setFillOpacity(ca)

Sets the opacity value for painting operations other than stroking. Corresponds to the value of the /ca key in the ExtGState dictionary.

Parameters:
Name Type Description
ca number

value to set fill opacity to


setFillOverprint(op)

specifies if overprint is enabled for fill operations. Corresponds to the /op key within the ExtGState's dictionary.

Parameters:
Name Type Description
op boolean

true to enable overprint for fill, false to disable.


setFlatness(flatness)

Sets the value of flatness tolerance.

Parameters:
Name Type Description
flatness number

is a number in the range 0 to 100; a value of 0 specifies the output device's default flatness tolerance.

The flatness tolerance controls the maximum permitted distance in device pixels between the mathematically correct path and an approximation constructed from straight line segments.


setFont(font, font_sz)

Sets the font and font size used to draw text.

Parameters:
Name Type Description
font PDFNet.Font

Font to draw the text with

font_sz number

size of the font to draw the text with


setHalftone(HT)

Parameters:
Name Type Description
HT PDFNet.Obj

SDF/Cos halftone dictionary, stream, or name

Returns:

currently selected halftone dictionary or stream (NULL by default). Corresponds to the /HT key within the ExtGState's dictionary. Halftoning is a process by which continuous-tone colors are approximated on an output device that can achieve only a limited number of discrete colors.


setHorizontalScale(hscale)

Sets horizontal scale. The horizontal scaling parameter adjusts the width of glyphs by stretching or compressing them in the horizontal direction. Its value is specified as a percentage of the normal width of the glyphs, with 100 being the normal width. The scaling always applies to the horizontal coordinate in text space, independently of the writing mode. See Section 5.2.3 in PDF Reference Manual for details.

Parameters:
Name Type Description
hscale number

value to set horizontal scale to.


setLeading(leading)

Sets the leading parameter.

The leading parameter is measured in unscaled text space units. It specifies the vertical distance between the baselines of adjacent lines of text. See Section 5.2.4 in PDF Reference Manual for details.

Parameters:
Name Type Description
leading number

number representing vertical distance between lines of text


setLineCap(cap)

Sets LineCap style property.

The line cap style specifies the shape to be used at the ends of open subpaths (and dashes, if any) when they are stroked.

Parameters:
Name Type Description
cap number/enum
PDFNet.GState.LineCap = {
	e_butt_cap : 0
	e_round_cap : 1
	e_square_cap : 2
}

setLineJoin(join)

Sets LineJoin style property.

The line join style specifies the shape to be used at the corners of paths that are stroked.

Parameters:
Name Type Description
join number/enum
PDFNet.GState.LineJoin = {
	e_miter_join : 0
	e_round_join : 1
	e_bevel_join : 2
}

setLineWidth(width)

Sets the thickness of the line used to stroke a path.

Parameters:
Name Type Description
width number

a non-negative number expressed in user space units. A line width of 0 denotes the thinnest line that can be rendered at device resolution: 1 device pixel wide.


setMiterLimit(miter_limit)

Sets miter limit.

Parameters:
Name Type Description
miter_limit number

A number that imposes a maximum on the ratio of the miter length to the line width. When the limit is exceeded, the join is converted from a miter to a bevel.


setOverprintMode(OPM)

Sets the overprint mode. Corresponds to the /OPM key within the ExtGState's dictionary.

Parameters:
Name Type Description
OPM number

overprint mode.


setRenderingIntent(intent)

Sets the color intent to be used for rendering the Element.

Parameters:
Name Type Description
intent number/enum
PDFNet.GState.RenderingIntent = {
	e_absolute_colorimetric : 0
	e_relative_colorimetric : 1
	e_saturation : 2
	e_perceptual : 3
}

setSmoothnessTolerance(SM)

Parameters:
Name Type Description
SM number

setSoftMask(SM)

Sets the soft mask of the extended graphics state. Corresponds to the /SMask key within the ExtGState's dictionary.

Parameters:
Name Type Description
SM PDFNet.Obj

SDF/Cos black-generation function or name


setStrokeColor(pattern, c)

Set the stroke color to the given uncolored tiling pattern.

Parameters:
Name Type Description
pattern PDFNet.PatternColor

pattern (PatternType = 1 and PaintType = 2) object.

c PDFNet.colorpt

is a color in the pattern's underlying color space.


setStrokeColorSpace(cs)

Sets the color space used for stroking operations

Parameters:
Name Type Description
cs PDFNet.ColorSpace

ColorSpace object to use for stroking operations


setStrokeColorWithColorPt(c)

Sets the color value/point used for stroking operations.

Parameters:
Name Type Description
c PDFNet.colorpt

is the color used for stroking operations


setStrokeColorWithPattern(pattern)

Set the stroke color to the given tiling pattern.

Parameters:
Name Type Description
pattern PDFNet.PatternColor

SDF pattern object.


setStrokeOpacity(ca)

Sets opacity value for stroke painting operations for paths and glyph outlines. Corresponds to the value of the /CA key in the ExtGState dictionary.

Parameters:
Name Type Description
ca number

value to set stroke opacity to


setStrokeOverprint(OP)

specifies if overprint is enabled for stroke operations. Corresponds to the /OP key within the ExtGState's dictionary.

Parameters:
Name Type Description
OP boolean

true to enable overprint for stroke, false to disable.


setTextKnockout(knockout)

Mark the object as elementary for purposes of color compositing in the transparent imaging model.

Parameters:
Name Type Description
knockout boolean

Whether an object is elementary or not.


setTextRenderMode(rmode)

Sets text rendering mode. The text rendering mode determines whether showing text causes glyph outlines to be stroked, filled, used as a clipping boundary, or some combination of the three. See Section 5.2.5 in PDF Reference Manual for details..

Parameters:
Name Type Description
rmode number/enum
PDFNet.GState.TextRenderingMode = {
	e_fill_text : 0
	e_stroke_text : 1
	e_fill_stroke_text : 2
	e_invisible_text : 3
	e_fill_clip_text : 4
	e_stroke_clip_text : 5
	e_fill_stroke_clip_text : 6
	e_clip_text : 7
}

the mode that text will rendered with. rmode can take the following values: PDFNet.GState.TextRenderingMode = { e_fill_text : 0, e_stroke_text : 1, e_fill_stroke_text : 2, e_invisible_text : 3, e_fill_clip_text : 4, e_stroke_clip_text : 5, e_fill_stroke_clip_text : 6, e_clip_text : 7 }


setTextRise(rise)

Sets text rise. Text rise specifies the distance, in unscaled text space units, to move the baseline up or down from its default location. Positive values of text rise move the baseline up

Parameters:
Name Type Description
rise number

distance to move baseline up. Negative values move baseline down.


setTransferFunct(TR)

Sets transfer function used during color conversion process. A transfer function adjusts the values of color components to compensate for nonlinear response in an output device and in the human eye. Corresponds to the /TR key within the ExtGState's dictionary.

Parameters:
Name Type Description
TR PDFNet.Obj

SDF/Cos transfer function, array, or name


setTransform(a, b, c, d, h, v)

Set the transformation matrix associated with this element.

A transformation matrix in PDF is specified by six numbers, usually in the form of an array containing six elements. In its most general form, this array is denoted [a b c d h v]; it can represent any linear transformation from one coordinate system to another. For more information about PDF matrices please refer to section 4.2.2 'Common Transformations' in PDF Reference Manual, and to documentation for pdftron::Common::Matrix2D class.

Parameters:
Name Type Description
a number

horizontal 'scaling' component of the new text matrix.

b number

'rotation' component of the new text matrix.

c number

vertical 'scaling' component of the new text matrix.

d number

'rotation' component of the new text matrix.

h number

horizontal translation component of the new text matrix.

v number

vertical translation component of the new text matrix.


setTransformMatrix(mtx)

Set the transformation matrix associated with this element.

Parameters:
Name Type Description
mtx PDFNet.matrix2d

The new transformation for this text element.


setUCRFunct(UCR)

Sets undercolor-removal function used during conversion between DeviceRGB and DeviceCMYK. Corresponds to the /UCR key within the ExtGState's dictionary.

Parameters:
Name Type Description
UCR PDFNet.Obj

SDF/Cos undercolor-removal function or name


setWordSpacing(word_spacing)

Sets word spacing.

Parameters:
Name Type Description
word_spacing number

a number specified in unscaled text space units. Word spacing works the same way as character spacing, but applies only to the space character (char code 32). See Section 5.2.2 in PDF Reference Manual for details.