This is a migrated thread and some comments may be shown as answers.

Create Linear Gradient

4 Answers 72 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Gustav
Top achievements
Rank 1
Gustav asked on 07 Jul 2015, 07:45 AM

Dear Sirs, 

I'm seaching for a pdf solution and found your product. Now I'm evaluating. 

In the documentation there is an example for creating a gradient:

 http://docs.telerik.com/devtools/aspnet-ajax/controls/pdfprocessing/concepts/colors-and-color-spaces

1.FixedContentEditor containerEditor = new FixedContentEditor(container);
2.LinearGradient linearGradient = new LinearGradient(new Point(0, 0), new Point(30, 30));
3.linearGradient.GradientStops.Add(new GradientStop(new RgbColor(0, 207, 0), 0));
4.linearGradient.GradientStops.Add(new GradientStop(new RgbColor(0, 102, 204), 0));
5. 
6.containerEditor.GraphicProperties.FillColor = linearGradient;
7.containerEditor.DrawRectangle(new Rect(10, 10, 48, 29));

If I copy these code I just get a monochrome rectangle filled with the color (0,102,204). 

 Any help would be fine.

 

many thanks in advance

 

Gustav Meier

4 Answers, 1 is accepted

Sort by
0
Nikolay Demirev
Telerik team
answered on 09 Jul 2015, 08:50 AM
Hello Gustav,

Thank you for writing.

I have modified the code for generating a linear gradient:
FixedContentEditor containerEditor = new FixedContentEditor(document.Pages.First());
LinearGradient linearGradient = new LinearGradient(new Point(0, 0), new Point(30, 30));
linearGradient.GradientStops.Add(new GradientStop(new RgbColor(0, 207, 0), 0));
linearGradient.GradientStops.Add(new GradientStop(new RgbColor(0, 102, 204), 1));
 
containerEditor.GraphicProperties.FillColor = linearGradient;
containerEditor.DrawRectangle(new Rect(10, 10, 48, 29));

We will update the code snippet in the help article as soon as possible.

As a token of our appreciation for reporting this I am updating your Telerik Points.

Regards,
Nikolay Demirev
Telerik
0
Peter
Top achievements
Rank 1
answered on 01 Mar 2018, 01:16 AM
This code change doesn't appear to make a difference. The fill color in the pdf is still a solid color of the second color. Is this a bug? Is there a work around?
0
Peshito
Telerik team
answered on 05 Mar 2018, 02:25 PM
Hi Peter,

I just tried the snippet from the previous reply and it worked fine. Could you share the code you have used in order to create the LinearGradient?

Regards,
Peshito
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Peter
Top achievements
Rank 1
answered on 05 Mar 2018, 10:11 PM
Thanks. I've discovered my mistake. I had used Position.Translate to position the rectangle but it looks like the gradient points are not affected by Position.Translate
Tags
PdfProcessing
Asked by
Gustav
Top achievements
Rank 1
Answers by
Nikolay Demirev
Telerik team
Peter
Top achievements
Rank 1
Peshito
Telerik team
Share this question
or