« Use text fields for n… | Home | MBS Xojo Plugins, ver… »

DynaPDF with gradients in DeviceN colorspace

We got a new example for our MBS Xojo DynaPDF Plugin for using DynaPDFMBS class to create a gradient with DeviceN color space. We use DynaPDFExtGStateMBS to set the extended graphics state and enable overprint mode. Then we create the DevcieN colorspace based on a CMYK fallback. And within that colorspace we define an axial shading to get a gradient to fill an area in the PDF page. Here is the new sample code:

// Draw something in background so that we can see whether it works Call pdf.SetColorSpace(pdf.kcsDeviceCMYK) Call pdf.SetFillColor(PDF.CMYK(0, 0, 255, 0)) Call pdf.Rectangle(0.0, 0.0, 595.0, 842.0, pdf.kfmFill) Dim gs As New DynaPDFExtGStateMBS gs.OverPrintMode = 1 gs.OverPrintFill = 1 Dim gsHandle As Integer = pdf.CreateExtGState(gs) Call pdf.SetExtGState(gsHandle) // In this example, we emulate a CMYK color space with a DeviceN color space. // The required Postscript calculator function is super simple, it consists of only two braces"{}". Dim cls() As String = Array("Cyan", "Magenta", "Yellow", "Black") Dim cs As Integer = pdf.CreateDeviceNColorSpace(cls, "{}", pdf.kesDeviceCMYK, -1) Call pdf.SetExtFillColorSpace(cs) Dim sh As Integer = pdf.CreateAxialShading( 50.0, 50.0, 550.0, 50.0, 0.5, PDF.CMYK(60, 0, 0, 0), PDF.CMYK(255, 0, 0, 0), False, False) Call pdf.ApplyShading(sh)

This needs a DynaPDF Pro license from us for the plugin. Feel free to try the example project included with future MBS Plugin releases and send us questions.

09 10 21 - 10:50