Thanks for your inquiry. You can add a filled rectangle with the help of PolygonAnnotation. Please check following code snippet for the purpose. Please note gradient fill is not supported at the moment.
Document pdf = new
Document(myDir + "HelloWorld.pdf");
Page page=pdf.Pages[1];
LineInfo lineinfo = new LineInfo();
lineinfo.VerticeCoordinate = new float[] { 300,
700, 300, 750, 400, 750,400,700,300,700 };
lineinfo.Visibility = true;
int length = lineinfo.VerticeCoordinate.Length / 2;
Aspose.Pdf.Point[]
gesture = new Aspose.Pdf.Point[length];
for (int i = 0; i <
length; i++)
{
gesture[i] = new Aspose.Pdf.Point(lineinfo.VerticeCoordinate[2 * i], lineinfo.VerticeCoordinate[2
* i + 1]);
}
PolygonAnnotation polyAnnot = new PolygonAnnotation(page,
new Aspose.Pdf.Rectangle(0,
0, 0, 0), gesture);
polyAnnot.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red);
polyAnnot.InteriorColor = Aspose.Pdf.Color.YellowGreen;
Border border = new Border(polyAnnot);
// border.Dash = new Dash(2, 1);
// border.Style =
Aspose.Pdf.InteractiveFeatures.Annotations.BorderStyle.Dashed;
border.Width = 2;
polyAnnot.Border = border;
polyAnnot.Opacity = .8;
page.Annotations.Add(polyAnnot);
pdf.Save(myDir+"polygon_out.pdf");
Please feel free to contact us for any further assistance.
Best Regards,