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

Free Support Forum - aspose.com

How to set opacity in Drawing Graph?

I want to set opacity option in my rectangle.

but I can’t find the option

How can I set opacity?

here is my code

                    Aspose.Pdf.Drawing.Graph graph1 = new Aspose.Pdf.Drawing.Graph(Convert.ToSingle(page.PageInfo.Width), Convert.ToSingle(page.PageInfo.Height))
                    {
                        IsChangePosition = false,
                        Left = 0 - page.PageInfo.Margin.Left,
                        Top = 0 - page.PageInfo.Margin.Top
                    };
                    // Add a rectangle inside the "graph"
                    Aspose.Pdf.Drawing.Rectangle rect1 = new Aspose.Pdf.Drawing.Rectangle(0, 0, Convert.ToSingle(page.PageInfo.Width), Convert.ToSingle(page.PageInfo.Height));
                    // Set rectangle fill color                            
                    // Color of graph object

                    
                    rect1.GraphInfo.FillColor = Aspose.Pdf.Color.Blue;
                    // Add rectangle to shapes collection of graph instance
                    graph1.Shapes.Add(rect1);
                    // Set Z-Index for rectangle object
                    graph1.ZIndex = 1;
                    // Add graph to paragraphs collection of page object
                    page.Paragraphs.Add(graph1);

@yeonkyu

You can set Alpha Color to Graph in order to make it transparent. You can control the transparency by changing color values:

For example:

// Create color object from Alpha channel
rect1.GraphInfo.FillColor = Aspose.Pdf.Color.FromArgb(30, 0, 255, 0);

oh~ Thank you veryveryvery much~~~~~~~~~!!!

1 Like