Hello,
I am printing multiple boxes on a page. I want to set different gradient color for each box. Though setting gradient color works properly for single rectangle in page but for multiple rectangles on a page it doesn’t work properly. Please check below code and let me know if I have missed something.
var section = pdfDocument.Pages.Add();
var pageSize = PageSize.A0;
section.SetPageSize(pageSize.Width, pageSize.Height);
section.PageInfo.Margin = new MarginInfo
{
Left = 36,
Top = 36,
Right = 36,
Bottom = 36,
};
section.PageInfo.IsLandscape = true;
var canvas = new Graph(2000, 2000)
{
Top = 0,
Left = 0,
Border = new BorderInfo(BorderSide.All,1),
};
section.Paragraphs.Add(canvas);
//Box 1 - adding
var boxShape = new Aspose.Pdf.Drawing.Rectangle(
500
, 500, 400, 400)
{
//RoundedCornerRadius = 3,
};
var gradientColor = new Color
{
PatternColorSpace =
new GradientAxialShading(
Color.AliceBlue,
Color.Black)
{
Start = new Point(boxShape.Left, boxShape.Bottom),
End = new Point(boxShape.Left + boxShape.Width, boxShape.Bottom + boxShape.Height)
}
};
boxShape.GraphInfo.FillColor = gradientColor;
boxShape.GraphInfo.LineWidth = 4;
boxShape.GraphInfo.Color = Color.Red;
canvas.Shapes.Add(boxShape);
//Box 2 Adding
var boxShape2 = new Aspose.Pdf.Drawing.Rectangle(
100
, 100, 400, 400)
{
//RoundedCornerRadius = 3,
};
var gradientColor2 = new Color
{
PatternColorSpace =
new GradientAxialShading(
Color.Blue,
Color.Black)
{
Start = new Point(boxShape2.Left, boxShape2.Bottom),
End = new Point(boxShape2.Left + boxShape2.Width, boxShape2.Bottom + boxShape2.Height)
}
};
boxShape2.GraphInfo.FillColor = gradientColor2;
boxShape2.GraphInfo.LineWidth = 1;
boxShape2.GraphInfo.Color = Color.Blue;
canvas.Shapes.Add(boxShape2);
Regards,
Sandeep