Shape jumping to the next page

Hi,

I am trying to draw rectangles on a PDF page, but when I draw the last one near the page borders, it gets moved to the next page at the same position.
image.png (1.8 KB)

var graph = new Aspose.Pdf.Drawing.Graph((double)width, (double)height)
{
// Can we change the position of graph instance
IsChangePosition = false,
// Set Left coordinate position for Graph instance
Left = x,
// Set Top coordinate position for Graph object
Top = page.PageInfo.Height - y - height,
};

this is my code:

Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(0, 0, width, height);
rect.GraphInfo.Color = Aspose.Pdf.Color.FromRgb(color.getRgbColor());
rect.GraphInfo.LineWidth = linewidth;

graph.Shapes.Add(rect);
graph.GraphInfo.RotationAngle = angle;

page.Paragraphs.Add(graph);

What am I doing wrong?

@SC85

The issue looks related to the specifications of margins. Please honor the margins for both Graph as well as page while adding Rectangle. In case issue still persists, please share the values that you are using so that we can also test and address the issue accordingly.