Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

DynaPDF.CreateExtGState

Creates an extended graphics state object from the structure GS.

Component Version macOS Windows Linux Server iOS SDK
DynaPDF 14.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "DynaPDF.CreateExtGState"; PDF; JSON )   More

Parameters

Parameter Description Example
PDF The PDF reference returned from DynaPDF.New. $pdf
JSON The JSON describing the entries you like to initiaize.

Result

Returns OK or error.

Description

Creates an extended graphics state object from the structure GS.
An extended graphics state can be used to adjust certain properties which are not part of the normal graphics state. Such properties can only be modified with a special PDF object called the Extended Graphics State.
The most important properties of an extended graphics state are the transparency settings (PDF 1.4) and the overprint control (PDF 1.2 or 1.3, see below).
The function creates an internal graphics state object and returns the handle of it. The extended graphics state can now be applied with DynaPDF.SetExtGState.
Note that there is only way to restore the values of an extended graphics state, you must set a second extended graphics state that restores the values changed before. See DynaPDF.SaveGraphicsState and DynaPDF.RestoreGraphicsState.

The following values are allowed in the JSON:

KeyvaluePDF Versiondefault
AlphaIsShape0 or 1PDF 1.4unknown, does nothing
AutoStrokeAdjust0 or 1PDF 1.40
BlendModeNumber of BlendModePDF 1.4Normal
FlatnessTol0.0..1.0allnone
FillAlpha0.0..1.0PDF 1.41.0
OverPrintFill0 or 1PDF 1.2 if used alone, PDF 1.3 otherwise0
OverPrintStroke0 or 1PDF 1.30
OverPrintMode0 or 1PDF 1.30
RenderingIntentsee RenderingIntentsPDF 1.1RelativeColorimetric
SmoothnessTol0.0..1.0PDF 1.3none
StrokeAlpha0.0..1.0PDF 1.41.0
TextKnockout0 or 1PDF 1.41
SoftMaskNonetrue or falseallfalse

A value that should not be modified must not be changed.

If an image should be inserted with transparency it is usually best to disable image transparency which based on color key masking (see DynaPDF.SetUseTransparency). Images use the fill alpha constant as alpha channel. Blend modes can be applied too. However, the result of blend modes depends strongly on the used color space. If the image is not defined in an ICC based color space then the result depends on the color management settings.
Whenever transparency related settings are changed (FillAlpha, StrokeAlpha, or BlendMode) it is strongly recommended to attach an ICC profile of the output color space for which the file was created with DynaPDF.AddOutputIntent.
If no output intent was specified, Adobe's Acrobat or Reader simulate a default CMYK color space as output color space if transparency is used on a page, also if the page uses RGB colors only! This differs from normal RGB files which use no transparency and causes often unwanted color changes.
Note that this rule applies also to images which contain an alpha channel!
If the PDF file uses RGB colors only, then attach an sRGB profile to the file. Such a profile is very small but it makes a huge difference whether the profile is present or not.

If the function succeeds the return value is the extended graphics state handle, a value greater or equal zero. If the function fails the return value is an error.

Rendering intents:

AbsoluteColorimetric0
Perceptual1,
RelativeColorimetric2
Saturation3

Blend modes:

NotSet0
Normal1
Color2
ColorBurn3
ColorDodge4
Darken5
Difference6
Exclusion7
HardLight8
Hue9
Lighten10
Luminosity11
Multiply12
Overlay13
Saturation14
Screen15
SoftLight16

See also CreateExtGState function in DynaPDF manual.

Examples

Set transparency:

Set Variable [ $json ; Value: JSONSetElement ( JSONSetElement ( "{}" ; "FillAlpha" ; .5 ; JSONNumber ) ; "StrokeAlpha" ; .5 ; JSONNumber ) ]
Set Variable [ $gs ; Value: MBS("DynaPDF.CreateExtGState"; $pdf; $json) ]
Set Variable [ $r ; Value: MBS("DynaPDF.SetExtGState"; $pdf; $gs) ]

Enable overprint fill:

Set Variable [ $json ; Value: JSONSetElement ( JSONSetElement ( "{}" ; "OverPrintFill" ; 1; JSONNumber ) ; "OverPrintMode" ; 1 ; JSONNumber ) ]
Set Variable [ $gs ; Value: MBS("DynaPDF.CreateExtGState"; $pdf; $json) ]
Set Variable [ $r ; Value: MBS("DynaPDF.SetExtGState"; $pdf; $gs) ]

See also

Release notes

Blog Entries

This function checks for a license.

Created 4th September 2024, last changed 4th September 2024


DynaPDF.CreateDeviceNColorSpace - DynaPDF.CreateGeospatialMeasure