Get Page Margin

Hi Team

I would like to get the page margin from a pdf
I tried the following code
Aspose.Pdf.Page pdfPage = pdfDocument.Pages[1];
var info = pdfPage.PageInfo;
var left = info.Margin.Left;

in which I receive the output as default value Left 90, Right 90, Top 72, Bottom 72

but this is not the correct values



Thanks in Advance
Bala


Hi Bala,


Thanks for your inquiry. Please note PageInfo object is used for creating a new PDF document. However I have logged an investigation ticket PDFNEWNET-38385 in our issue tracking system to get margins of Page in existing PDF document. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience caused.

Best Regards,

I just wanted to add my vote for developing this feature.


We are in a similar situation of needing to determine the page margins of a pdf file supplied to us by our customers.

As a workaround, I’ve been looking into the possibility of rendering the pages to png and getting the surrounding whitespace from the image, as described in Aspose.PDF for .NET Documentation|Aspose.PDF for .NET . It seems like it should work, but it also seems like an expensive solution, especially for larger numbers of pages.

Are there any other workarounds that people have tried or would recommend?

Thanks

Jim Wiegand

Hi Jim,


Thanks for your inquiry. We have recorded your interest for the requested feature. I am afraid currently we have the only workaround to get whitespace(margin) from the page, that you already noticed. However we will notify you as soon as we made some significant progress towards the implementation of the feature.

We are sorry for the inconvenience caused.

Best Regards,

In order to add my vote, just let you know we have waited this feature for 2 years.

Hi Caifang,


Thanks for your request. We have logged your concern and will let you know as soon as the feature is implemented.

Thanks for your patience and cooperation.

Best Regards,

Hi Bala/Jim/Caifang,


Thanks for your patience. Our product team has investigated the issue and need to know which exact margin value you want to obtain as there are different types of margin of PDF page.


Size of the page (page rectangle) could be obtained using Page.Rect property.
Also, Page.MediaBox, Page.CropBox, Page.TrimBox etc can be obtained.

The media box defines the boundaries of the physical medium on which the page is to be printed. It may include any extended area surrounding the finished page for bleed, printing marks, or other such purposes. It may also include areas close to the edges of the medium that cannot be marked because of physical limitations of the output device. Content falling outside this boundary may safely be discarded without affecting the meaning of the PDF file.

The crop box defines the region to which the contents of the page shall be clipped (cropped) when displayed or printed. Unlike the other boxes, the crop box has no defined meaning in terms of physical page geometry or intended use; it merely imposes clipping on the page contents. However, in the absence of additional information (such as imposition instructions specified in a JDF or PJTF job ticket), the crop box determines how the page’s contents shall be positioned on the output medium. The default value is the page’s media box.

The bleed box (PDF 1.3) defines the region to which the contents of the page shall be clipped when output in a production environment. This may include any extra bleed area needed to accommodate the physical limitations of cutting, folding, and trimming equipment. The actual printed page may include printing marks that fall outside the bleed box. The default value is the page’s crop box.

(from PDF specification, 14.11.2Page Boundaries)


We are sorry for the inconvenience caused.


Best Regards,