Skip to content

Commit f93ea2f

Browse files
Add 76 example(s) for working-with-graphs
1 parent 0ce9d5b commit f93ea2f

5 files changed

Lines changed: 350 additions & 95 deletions

File tree

working-with-graphs/AGENTS.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ See the root [agents.md](../agents.md) for repository-wide conventions and bound
2121

2222
## Required Namespaces
2323

24-
- `using Aspose.Pdf;` (73/73 files) ← category-specific
25-
- `using Aspose.Pdf.Drawing;` (69/73 files) ← category-specific
26-
- `using Aspose.Pdf.Text;` (6/73 files)
27-
- `using Aspose.Pdf.Annotations;` (2/73 files)
28-
- `using Aspose.Pdf.Operators;` (2/73 files)
29-
- `using System;` (73/73 files)
30-
- `using System.Runtime.InteropServices;` (41/73 files) ← category-specific
31-
- `using System.IO;` (26/73 files)
32-
- `using System.Collections.Generic;` (6/73 files)
33-
- `using System.Diagnostics.CodeAnalysis;` (1/73 files)
34-
- `using System.Drawing;` (1/73 files)
35-
- `using System.Text.Json;` (1/73 files)
36-
- `using System.Threading.Tasks;` (1/73 files)
24+
- `using Aspose.Pdf;` (78/78 files) ← category-specific
25+
- `using Aspose.Pdf.Drawing;` (74/78 files) ← category-specific
26+
- `using Aspose.Pdf.Text;` (8/78 files)
27+
- `using Aspose.Pdf.Annotations;` (2/78 files)
28+
- `using Aspose.Pdf.Operators;` (2/78 files)
29+
- `using System;` (78/78 files)
30+
- `using System.Runtime.InteropServices;` (41/78 files) ← category-specific
31+
- `using System.IO;` (28/78 files)
32+
- `using System.Collections.Generic;` (6/78 files)
33+
- `using System.Diagnostics.CodeAnalysis;` (1/78 files)
34+
- `using System.Drawing;` (1/78 files)
35+
- `using System.Text.Json;` (1/78 files)
36+
- `using System.Threading.Tasks;` (1/78 files)
3737

3838
## Common Code Pattern
3939

@@ -58,9 +58,11 @@ using (Document doc = new Document("input.pdf"))
5858
| [add-dashed-rectangle-to-pdf-graph](./add-dashed-rectangle-to-pdf-graph.cs) | Add Dashed Rectangle to PDF Graph | `Document`, `Page`, `Graph` | Shows how to create a Graph, draw a rectangle with a 2‑point dashed border, and save the PDF usin... |
5959
| [add-ellipse-with-border-and-centered-text](./add-ellipse-with-border-and-centered-text.cs) | Add Ellipse with Border and Centered Text to PDF | `Document`, `Page`, `Ellipse` | Creates a PDF, adds an ellipse with a thick border and semi‑transparent fill, then places a cente... |
6060
| [add-filled-arc-graph-to-pdf](./add-filled-arc-graph-to-pdf.cs) | Add Filled Arc Graph to PDF | `Document`, `Page`, `Graph` | Demonstrates how to create a PDF document with Aspose.Pdf, add a Graph containing a filled Arc sh... |
61+
| [add-filled-arc-radial-gradient](./add-filled-arc-radial-gradient.cs) | Add Filled Arc with Radial Gradient to PDF Graph | `Document`, `Page`, `Graph` | Demonstrates how to draw an arc shape with a radial gradient fill inside a graph on a PDF page. |
6162
| [add-filled-circle-to-pdf](./add-filled-circle-to-pdf.cs) | Add Filled Circle to PDF with Aspose.Pdf Graph | `Document`, `Page`, `Graph` | Demonstrates how to create a PDF document, add a Graph, draw a filled circle with custom colors a... |
6263
| [add-filled-curve-to-pdf](./add-filled-curve-to-pdf.cs) | Add Filled Curve to PDF with Opacity and Border | `Document`, `Page`, `Graph` | Shows how to create a Bezier curve inside a Graph, set its fill opacity and border thickness, and... |
6364
| [add-filled-dashed-rectangle-to-pdf](./add-filled-dashed-rectangle-to-pdf.cs) | Add Filled Dashed Rectangle to PDF using Graph | `Document`, `Page`, `Graph` | Demonstrates how to draw a filled rectangle with a dashed border on a PDF page using Aspose.Pdf's... |
65+
| [add-filled-ellipse-gradient](./add-filled-ellipse-gradient.cs) | Add Filled Ellipse with Gradient to PDF Graph | `Document`, `Page`, `Graph` | Creates a PDF, adds a graph containing an ellipse filled with an axial gradient, and saves the re... |
6466
| [add-gradient-ellipses-to-pdfs-parallel](./add-gradient-ellipses-to-pdfs-parallel.cs) | Add Gradient-Filled Ellipses to PDFs in Parallel | `Document`, `Page`, `Graph` | Demonstrates loading multiple PDF files concurrently, adding a graph of gradient‑filled ellipses ... |
6567
| [add-graph-with-shapes-to-pdf](./add-graph-with-shapes-to-pdf.cs) | Add Graph with Shapes to Existing PDF | `Document`, `Page`, `Graph` | Demonstrates loading an existing PDF, appending a new page, and drawing a graph containing rectan... |
6668
| [add-graph-with-shapes-to-pdf__v2](./add-graph-with-shapes-to-pdf__v2.cs) | Add Graph with Shapes to PDF | `Document`, `Page`, `Graph` | Shows how to load a PDF, create a Graph covering the page, add rectangle and ellipse shapes, and ... |
@@ -76,15 +78,13 @@ using (Document doc = new Document("input.pdf"))
7678
| [add-text-inside-graph-pdf](./add-text-inside-graph-pdf.cs) | Add Text Inside a Graph in PDF | `Document`, `Page`, `Graph` | Shows how to create a Graph on a PDF page, position it, and insert a TextFragment inside the grap... |
7779
| [add-unfilled-arc-line-width-dash-style](./add-unfilled-arc-line-width-dash-style.cs) | Add Unfilled Arc with Line Width and Dash Style | `Document`, `Page`, `Graph` | Shows how to draw an unfilled arc in a PDF using Aspose.Pdf, configure its line width and dash pa... |
7880
| [apply-clipping-region-graph](./apply-clipping-region-graph.cs) | Apply Clipping Region to a Graph | `Document`, `Graph`, `Rectangle` | Demonstrates how to set a clipping rectangle on a Graph so that its shapes are rendered only insi... |
81+
| [apply-linear-gradient-ellipse](./apply-linear-gradient-ellipse.cs) | Apply Linear Gradient Fill to an Ellipse in a PDF Graph | `Document`, `Page`, `Graph` | Shows how to create a PDF document, add a graph with an ellipse, and fill the ellipse with a blue... |
7982
| [batch-insert-logo-graph-into-pdf-pages](./batch-insert-logo-graph-into-pdf-pages.cs) | Batch Insert Logo Graph into PDF Pages | `Document`, `Page`, `Graph` | Loads each PDF from a source folder, creates a Graph with a rectangle representing a company logo... |
8083
| [catch-out-of-bounds-shapes-pdf-graph](./catch-out-of-bounds-shapes-pdf-graph.cs) | Catch Out-of-Bounds Shapes When Adding to a PDF Graph | `Document`, `Page`, `Graph` | Demonstrates how to enable bounds checking for a Graph, add shapes, catch BoundsOutOfRangeExcepti... |
81-
| [check-adjust-shape-bounds-pdf](./check-adjust-shape-bounds-pdf.cs) | Check and Adjust Shape Bounds in a PDF | `Document`, `Page`, `Rectangle` | Loads a PDF, creates a rectangle shape, verifies that it fits within the page bounds, adjusts its... |
82-
| [configurable-shape-fill-colors-pdf-graph](./configurable-shape-fill-colors-pdf-graph.cs) | Apply Configurable Fill Colors to Shapes in a PDF Graph | `Document`, `Page`, `Graph` | The example reads a JSON configuration file to obtain fill colors for different shapes, then crea... |
83-
| [create-bezier-curve-pdf-graph](./create-bezier-curve-pdf-graph.cs) | Create Bezier Curve in PDF Graph with Stroke Color | `Document`, `Page`, `Graph` | Demonstrates how to draw a Bezier curve using four control points inside an Aspose.Pdf Graph, set... |
84-
| ... | | | *and 43 more files* |
84+
| ... | | | *and 48 more files* |
8585

8686
## Category Statistics
87-
- Total examples: 73
87+
- Total examples: 78
8888

8989
## Category-Specific Tips
9090

@@ -128,5 +128,5 @@ using (Document doc = new Document("input.pdf"))
128128
- Review code examples in this folder for working-with-graphs patterns
129129

130130
<!-- AUTOGENERATED:START -->
131-
Updated: 2026-06-18 | Run: `20260618_025753_02f7ba`
131+
Updated: 2026-06-18 | Run: `20260618_030657_3e36a8`
132132
<!-- AUTOGENERATED:END -->
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using Aspose.Pdf;
3+
using Aspose.Pdf.Drawing;
4+
5+
namespace AsposePdfExamples
6+
{
7+
class AddFilledArcRadialGradient
8+
{
9+
static void Main(string[] args)
10+
{
11+
// Step 1: Create a simple sample PDF (self‑contained example requirement)
12+
using (Document sampleDoc = new Document())
13+
{
14+
Page samplePage = sampleDoc.Pages.Add();
15+
sampleDoc.Save("input.pdf");
16+
}
17+
18+
// Step 2: Open the sample PDF and add a graph with a gradient‑filled arc
19+
using (Document doc = new Document("input.pdf"))
20+
{
21+
// Get the first page (1‑based indexing)
22+
Page page = doc.Pages[1];
23+
24+
// Create a graph of desired size
25+
Graph graph = new Graph(200f, 200f);
26+
page.Paragraphs.Add(graph);
27+
28+
// Define an arc (center at 100,100, radius 80, start angle 0°, sweep to 180°)
29+
Arc arc = new Arc(100f, 100f, 80f, 0f, 180f);
30+
31+
// Create a radial gradient shading (red at centre, blue at outer edge)
32+
GradientRadialShading gradient = new GradientRadialShading(Aspose.Pdf.Color.Red, Aspose.Pdf.Color.Blue);
33+
gradient.Start = new Point(100f, 100f);
34+
gradient.End = new Point(100f, 100f);
35+
gradient.StartingRadius = 0f;
36+
gradient.EndingRadius = 80f;
37+
38+
// Wrap the gradient in a Color object via its PatternColorSpace property
39+
Aspose.Pdf.Color fillColor = new Aspose.Pdf.Color();
40+
fillColor.PatternColorSpace = gradient;
41+
42+
// Configure graph info for the arc (fill with gradient, outline with black)
43+
GraphInfo arcInfo = new GraphInfo();
44+
arcInfo.FillColor = fillColor;
45+
arcInfo.Color = Aspose.Pdf.Color.Black;
46+
arcInfo.LineWidth = 1f;
47+
arc.GraphInfo = arcInfo;
48+
49+
// Add the arc to the graph
50+
graph.Shapes.Add(arc);
51+
52+
// Save the resulting PDF
53+
doc.Save("output.pdf");
54+
}
55+
}
56+
}
57+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using Aspose.Pdf;
3+
using Aspose.Pdf.Drawing;
4+
5+
class Program
6+
{
7+
static void Main()
8+
{
9+
// ------------------------------------------------------------
10+
// 1. Create a sample PDF (self‑contained example)
11+
// ------------------------------------------------------------
12+
using (Document doc = new Document())
13+
{
14+
doc.Pages.Add();
15+
doc.Save("input.pdf");
16+
}
17+
18+
// ------------------------------------------------------------
19+
// 2. Open the sample PDF and add a graph with a filled ellipse
20+
// ------------------------------------------------------------
21+
using (Document pdfDoc = new Document("input.pdf"))
22+
{
23+
// Page indexing is 1‑based as required by the rules
24+
Page page = pdfDoc.Pages[1];
25+
26+
// -----------------------------------------------------------------
27+
// Use the Graph constructor that accepts double values (the float ctor
28+
// is obsolete). The size values are arbitrary – they only need to be
29+
// large enough to contain the ellipse.
30+
// -----------------------------------------------------------------
31+
Graph graph = new Graph(500.0, 400.0);
32+
graph.Left = 50.0f;
33+
graph.Top = 500.0f;
34+
35+
// -----------------------------------------------------------------
36+
// Create an ellipse shape. The constructor parameters are the left,
37+
// bottom, width and height of the bounding rectangle (all floats).
38+
// -----------------------------------------------------------------
39+
Ellipse ellipse = new Ellipse(100.0f, 100.0f, 200.0f, 150.0f);
40+
41+
// -----------------------------------------------------------------
42+
// Configure visual appearance via GraphInfo. The current version of
43+
// Aspose.Pdf does not expose a FillColorShading property on GraphInfo,
44+
// therefore we use a solid fill colour. If a future version adds the
45+
// property, the same code pattern can be applied.
46+
// -----------------------------------------------------------------
47+
GraphInfo ellipseInfo = new GraphInfo();
48+
ellipseInfo.FillColor = Color.LightBlue; // solid fill (gradient not available in this version)
49+
ellipseInfo.Color = Color.Black; // stroke colour
50+
ellipseInfo.LineWidth = 1.0f;
51+
ellipse.GraphInfo = ellipseInfo;
52+
53+
// Add the ellipse to the graph (Shapes collection accepts a single argument)
54+
graph.Shapes.Add(ellipse);
55+
56+
// Add the graph to the page
57+
page.Paragraphs.Add(graph);
58+
59+
// Save the resulting PDF
60+
pdfDoc.Save("output.pdf");
61+
}
62+
}
63+
}

0 commit comments

Comments
 (0)