|
2 | 2 | using Syncfusion.Pdf; |
3 | 3 | using Syncfusion.Drawing; |
4 | 4 |
|
5 | | -// Create a new PDF document. |
| 5 | +// Create a new PDF document. |
6 | 6 | PdfDocument document = new PdfDocument(); |
7 | 7 |
|
8 | 8 | // Add a page to the document. |
|
24 | 24 | PdfPath path = new PdfPath(); |
25 | 25 | path.AddRectangle(new RectangleF(rectX, rectY, rectWidth, rectHeight)); |
26 | 26 |
|
27 | | -// Define gradient colors. |
| 27 | +// Define gradient colors using RGB (byte values from 0 to 255). |
28 | 28 | List<PdfColor> finalGradientColors = new List<PdfColor> |
29 | | - { |
30 | | - new PdfColor(0, 0.247058809f, 1, 0), |
31 | | - new PdfColor(0, 0.247058809f, 1, 0), |
32 | | - new PdfColor(1, 0, 0.545454562f, 80), |
33 | | - new PdfColor(1, 0, 0.545454562f, 80) |
34 | | - }; |
| 29 | +{ |
| 30 | + new PdfColor(0, 63, 255), // Blue-ish |
| 31 | + new PdfColor(0, 63, 255), // Same blue |
| 32 | + new PdfColor(255, 0, 139), // Reddish-purple |
| 33 | + new PdfColor(255, 0, 139) // Same reddish-purple |
| 34 | +}; |
35 | 35 |
|
36 | 36 | // Define positions for the gradient colors. |
37 | 37 | List<float> finalGradientPositions = new List<float> { 0, 0.2f, 0.8f, 1 }; |
|
60 | 60 | // Draw the gradient-filled rectangle. |
61 | 61 | graphics.DrawPath(rectangleGradientBrush, path); |
62 | 62 |
|
63 | | -// Save the PDF document to a file using a file stream. |
64 | | -using (FileStream fs = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.Write)) |
| 63 | +//Create file stream. |
| 64 | +using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) |
65 | 65 | { |
66 | | - document.Save(fs); |
| 66 | + document.Save(outputFileStream); |
67 | 67 | } |
68 | 68 |
|
69 | 69 | // Close the document and release resources. |
|
0 commit comments