Modify Color Fill Value fails

Help
Hakan
2013-09-20
2013-09-20
  • Hakan
    Hakan
    2013-09-20

    Can anyone explain why the following code runs with no errors, the debug shows correct DeviceGray values, consistent with the content of the PDF, but yet the OUTPUT has no change.

    My goal is to change "fill" values of content objects.

    thank you

        Dim outputfile As String = "C:\output.pdf"
        Dim file As New File("C:\inputfile.pdf")
        Dim document As Document = file.Document
    
        For Each page As Page In document.Pages
            Dim contents As Contents = page.Contents
    
            For Each obj As ContentObject In contents
                AdjustFillValue(obj)
            Next
    
            contents.Flush()
    
        Next
    
        Serialize(file, outputfile)
    

    end

    Private Sub AdjustFillValue(content As ContentObject)

        If TypeOf content Is ContainerObject Then
            For Each obj As ContentObject In DirectCast(content, ContainerObject).Objects
                AdjustFillValue(obj)
            Next
    
        ElseIf TypeOf content Is SetDeviceCMYKFillColor Then
            '... to implement
    
        ElseIf TypeOf content Is SetDeviceGrayFillColor Then
    
            Dim FillColor As SetDeviceGrayFillColor = DirectCast(content, SetDeviceGrayFillColor)
            Debug.WriteLine("GrayFill=" & FillColor.ToString()) 'VALUES RETURN OK (0 to 1 range) 
            'DEBUG PROVES INPUT PDF HAS DEVICEGRAY COLOR CONTENT
            FillColor = New SetDeviceGrayFillColor(New colorSpaces.DeviceGrayColor(0.1)) 'NO IMPACT ON OUTPUT
            content = New SetDeviceGrayFillColor(New colorSpaces.DeviceGrayColor(0.1)) 'NO IMPACT ON OUTPUT
        *How can I set new fillcolor ?*
    
        ElseIf TypeOf content Is SetDeviceRGBFillColor Then
            'to implement
    
        ElseIf TypeOf content Is SetFillColor Then
            'to implement
    
        End If
    
    End Sub
    
     
  • Hakan
    Hakan
    2013-09-20

    never mind, I figured this one out myself
    assigning the fill object to a new objects breaks it
    FillColor.Components(0) = .... works fine