How to crop page if it contains annotations

Q: We need to crop pages (page.SetCropBox(...)), removing top and
bottom margin on each page. (blank paragraph). Our method is ok for
pages containing Text and Image elements. But, some page are modified
with ink annotations. (ToolMode.e_ink_create).
For these elements our method failed and can’t get the good Rect,
even if we use the GetBBox method.

Is there another way to get the {x1,x2,y1,y2} values for these kind of
annotations. (I think the type is e_path).

A: In PDF annotations are stored separately from page content. You can
access annotations using page.GetAnnot(idx) as shown in Annotation
sample project (
samplecode.html#Annotation). You can obtain a bounding box for each
annotation using annot.GetRect().