We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Setting gradient color for multiple rectangles doesn't work

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

@sgarg.saba

We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as PDFNET-51255. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Any time expected for getting this resolved. Because of this we are not able to migrate to new version of Aspose.

@sgarg.saba

Your issue is pending for analysis and is in the queue. Once we complete the analysis of your issue, we will then be able to provide you an estimate.

Can we get timeframe now? Already 9 months we are waiting on it…

@sgarg.saba

We regret to share with you that your issue is still pending for analysis. We will inform you via this forum thread once there is an update available on it.