How to create axial gradient including three color.ie.from red to yellow,then to blue

Product:PDFNetC

Product Version:11.7

Please give a brief summary of your issue:
how to create axial gradient including three color.ie.from red to yellow,then to blue.

Please describe your issue and provide steps to reproduce it:

in the sample “PatternTest”,only have two colors gradient.how to create axial gradient including three color.ie.from red to yellow,then to blue.

Please provide a link to a minimal sample where the issue is reproducible:

Hello, I’m AiRon, an automated tech support bot :robot:
While you wait for one of our customer support representatives, I can help you with your question.


To create an axial gradient with more than two colors in PDFNetC, you need to define multiple color stops along the gradient’s axis. This involves specifying the colors and their positions along the gradient line. PDFNet allows you to define custom color spaces and use them in your gradients.

Some things you can try:

  • Use the Shading class in PDFNet to define an axial shading pattern with multiple colors.

  • Create a color space that includes the colors red, yellow, and blue, and set their corresponding positions.

  • Use the CreateAxialShading method to define the start and end points of the gradient and include the color stops between them.

  • Apply this shading pattern to a shape or a path in your PDF document.




Here are some resources that might help you:



Hopefully, this helps you solve your problem while you wait for a human to get back to you.

how to define multiple color stops along the gradient’s axis? please give a sample

Apologies for the delay. You may define multiple color stops along the gradients axis by defining a stitching function. For more information on this, you can refer to the PDF Spec Chapter 7.10.4 Type 3 (Stitiching) Functions.

I have attached some sample code below on how to do this. Note that you may stitch multiple sub functions together.
PatternTest.cs (4.4 KB)