@@ -495,22 +495,19 @@ protected virtual void ProcessFormXObject(StreamToken formStream, NameToken xObj
495495 $ "Invalid Transparency Group XObject, '{ NameToken . S } ' token is not set or not equal to '{ NameToken . Transparency } '.") ;
496496 }
497497
498- /* blend mode
499- * A conforming reader shall implicitly reset this parameter to its initial value at the beginning of execution of a
500- * transparency group XObject (see 11.6.6, "Transparency Group XObjects"). Initial value: Normal.
501- */
502- //startState.BlendMode = BlendMode.Normal;
503-
504- /* soft mask
505- * A conforming reader shall implicitly reset this parameter implicitly reset to its initial value at the beginning
506- * of execution of a transparency group XObject (see 11.6.6, "Transparency Group XObjects"). Initial value: None.
507- */
508- // TODO
509-
510- /* alpha constant
511- * A conforming reader shall implicitly reset this parameter to its initial value at the beginning of execution of a
512- * transparency group XObject (see 11.6.6, "Transparency Group XObjects"). Initial value: 1.0.
513- */
498+ // Blend mode
499+ // A conforming reader shall implicitly reset this parameter to its initial value at the beginning of execution of a
500+ // transparency group XObject (see 11.6.6, "Transparency Group XObjects"). Initial value: Normal.
501+ startState . BlendMode = BlendMode . Normal ;
502+
503+ // Soft mask
504+ // A conforming reader shall implicitly reset this parameter implicitly reset to its initial value at the beginning
505+ // of execution of a transparency group XObject (see 11.6.6, "Transparency Group XObjects"). Initial value: None.
506+ startState . SoftMask = null ;
507+
508+ // Alpha constant
509+ // A conforming reader shall implicitly reset this parameter to its initial value at the beginning of execution of a
510+ // transparency group XObject (see 11.6.6, "Transparency Group XObjects"). Initial value: 1.0.
514511 startState . AlphaConstantNonStroking = 1.0 ;
515512 startState . AlphaConstantStroking = 1.0 ;
516513
@@ -765,6 +762,49 @@ public virtual void SetNamedGraphicsState(NameToken stateName)
765762 // (see Section 6.5.4, “Automatic Stroke Adjustment”).
766763 currentGraphicsState . StrokeAdjustment = saToken . Data ;
767764 }
765+
766+ // (PDF 1.4, array is deprecated in PDF 2.0) The current blend mode that shall be
767+ // used in the transparent imaging model (see 11.3.5, "Blend mode"). A PDF reader
768+ // shall implicitly reset this parameter to its initial value at the (array is
769+ // deprecated beginning of execution of a transparency group XObject
770+ // (see 11.6.6, in PDF 2.0) "Transparency group XObjects"). The value shall be
771+ // either a name object, designating one of the standard blend modes listed in
772+ // "Table 134 — Standard separable blend modes" and "Table 135 — Standard
773+ // non-separable blend modes" in 11.3.5, "Blend mode", or an array of such names.
774+ // In the latter case, the PDF reader shall use the first blend mode in the array
775+ // that it recognises (or Normal if it recognises none of them).
776+ //
777+ // Initial value: Normal.
778+ if ( state . TryGet ( NameToken . Bm , PdfScanner , out NameToken ? bmToken ) )
779+ {
780+ currentGraphicsState . BlendMode = bmToken . Data . ToBlendMode ( ) ?? BlendMode . Normal ;
781+ }
782+ else if ( state . TryGet ( NameToken . Bm , PdfScanner , out ArrayToken ? bmArrayToken ) )
783+ {
784+ // The PDF reader shall use the first blend mode in the array that it
785+ // recognises (or Normal if it recognises none of them).
786+
787+ currentGraphicsState . BlendMode = BlendMode . Normal ;
788+
789+ foreach ( var token in bmArrayToken . Data . OfType < NameToken > ( ) )
790+ {
791+ var bm = token . Data . ToBlendMode ( ) ;
792+ if ( bm . HasValue )
793+ {
794+ currentGraphicsState . BlendMode = bm . Value ;
795+ break ;
796+ }
797+ }
798+ }
799+
800+ if ( state . TryGet ( NameToken . Smask , PdfScanner , out NameToken ? smToken ) && smToken . Equals ( NameToken . None ) )
801+ {
802+ currentGraphicsState . SoftMask = null ;
803+ }
804+ else if ( state . TryGet ( NameToken . Smask , PdfScanner , out DictionaryToken ? smDictToken ) )
805+ {
806+ currentGraphicsState . SoftMask = SoftMask . Parse ( smDictToken , PdfScanner , FilterProvider ) ;
807+ }
768808 }
769809
770810 /// <inheritdoc/>
0 commit comments