PageInfo and PageRect are returning completely different dimensions for the same PDF

I am trying to decorate the attached PDF using Aspose.PDF 23.2, although when I add a rectangle to it, I get an OutOfMemory error (after a long time). Previously I was able to draw FloatingBoxes using the pageRect dimensions:

var doc = new Document("demo.pdf");
var page = doc.getPages().get_Item(1);
page.getPageInfo().setMargin(new MarginInfo(0,0,0,0));
var pageRect = page.getPageRect(true);

var graph = new Graph((float) pageRect.getWidth(), (float) pageRect.getHeight());
var rectangle = new Rectangle(791, 545, 50, 50);

Checking the page dimensions, I observed that PageInfo is bringing coordinates as if the document was rotated, apart from the decimals difference:

  • 841.680000 x 595.440000
  • 595.000000 x 842.000000

If I create the Graph using the PageInfo coordinates, the OutOfMemory error do not occur, but then the rectangle is not drawn into the right place.

If I set PageInfo dimensions based on PageRect dimensions, the error goes away and the rectangle appears in the right positions.

Questions are:

  1. Is setting PageInfo with/height a valid work around? How does it impact the document itself?
  2. Why do we have such dimension difference if PageInfo returns false for Landscape and Page returns 0 for the rotation?demo.pdf (28.8 KB)


I ran your code and after 5 minutes I just stopped it. It looks like a memory loop.

I will be creating a ticket for the dev team.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-53942

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

The issues you have found earlier (filed as PDFNET-53942) have been fixed in Aspose.PDF for .NET 23.7.