Search code examples
pdfpdf-generation

Assigning an ExtGState to a stroke in a PDF does not work


I am trying to assign a ExtGState object to a stroke in a image stream in a pdf. The ExtGState should set the Blend Mode of the stroke. But no matter what, it does not work and the PDF Specification does not help. I hope somebody here knows what to do.

Here is my ExtGState Object:

    5 0 obj
      << /Type /ExtGState
         /BM Multiply
      >>
    endobj

My Proc Set of the Page:

4 0 obj
  << /ProcSet [/PDF /Text]
     /ExtGState << /GS1 5 0 R
                >>
  >>
endobj

And finally the image stream

6 0 obj
  <<   >>
stream
 3 w
 0 0 0 RG
 1 J
 1 j
 178 2658 m
 310 2322 l 
 S


 10 w
0.13725490196078433 0.4196078431372549 0.5568627450980392 RG
 1 J
 1 j
 /GS1 gs
 [3 5] 6 d
 152 2423 m
 400 2600 l
 S
endstream

endobj

I am using /GS1 gs in order to assign the ExtGState Object to my second stroke. The first stroke is just for checking, if the blend mode works (which does not).

Here you can find my whole pdf: https://pastebin.com/nwGBb7vB

It is supposed to look like this:

enter image description here


Solution

  • You have a syntax error in your graphics state dictionary:

    5 0 obj
      << /Type /ExtGState
         /BM Multiply
      >>
    endobj
    

    The Multiply needs to be a PDF name object. In particular it has to start with a slash:

    5 0 obj
      << /Type /ExtGState
         /BM /Multiply
      >>
    endobj
    

    After this change you get:

    screenshot