I'm trying to create a new spot color space for the purpose of adding a spot color to a semi transparent fill on a low-res image in a pdf (to show low-res). Using code previously posted on this forum (I'm using vb);
First create the color space;
Private Shared Function CreateSpotColorSpace(ByVal doc As PDFDoc) As ColorSpace
' create spot color space
Dim sep_cs As Object = doc.CreateIndirectArray()
sep_cs.PushBackName("Seperation")
sep_cs.PushBackName("LogoGreen")
sep_cs.PushBackName("DeviceCMYK")
Dim ps_funct As String = "{ dup 0.84 mul exch 0.00 exch dup 0.44 mul exch 0.21 mul }"
Dim tint_funct As Object = doc.CreateIndirectStream(New System.Text.UTF8Encoding().GetBytes(ps_funct))
tint_funct.PutNumber("Function Type", 4)
Dim tint_domain As Object = tint_funct.PutArray("Domain")
tint_domain.PushBackNumber(0) ' gray
tint_domain.PushBackNumber(1)
Dim tint_range As Object = tint_funct.PutArray("Range")
tint_range.PushBackNumber(0) ' C
tint_range.PushBackNumber(1)
tint_range.PushBackNumber(0) ' M
tint_range.PushBackNumber(1)
tint_range.PushBackNumber(0) ' Y
tint_range.PushBackNumber(1)
tint_range.PushBackNumber(0) ' K
tint_range.PushBackNumber(1)
sep_cs.PushBack(tint_funct)
Return New ColorSpace(sep_cs)
End Function
then call this function;
...
...
If element.GetType() = Element.Type.e_image Then
writer.Begin(itr.Current)
Dim imagewidth As Integer = element.GetImageWidth()
Dim imageheight As Integer = element.GetImageHeight()
Dim mtx = element.GetCTM()
Dim xRes As Integer = imagewidth / mtx.m_a * 72
Dim yRes As Integer = imageheight / mtx.m_d * 72
If xRes < 1000 Or yRes < 1000 Then
' get spot color space
Dim cs As ColorSpace = CreateSpotColorSpace(doc)
'create and place colored semi-transparent fill over image
Dim bbox As Rect = New Rect
Dim imagebox = element.GetBBox(bbox)
Dim imagefill As Element = eb.CreateRect(bbox.x1, bbox.y1, bbox.x2 - bbox.x1, bbox.y2 - bbox.y1)
imagefill.SetPathFill(True)
Dim gstate = imagefill.GetGState()
gstate.SetFillColorSpace(cs)
gstate.SetFillColor(New ColorPt(1))
gstate.SetFillOpacity(0.5)
writer.WriteElement(imagefill)
End If
End If
...
...
I'm getting an Invalid Color space error on this line;
gstate.SetFillColorSpace(cs)
Any ideas why?