How to I resize the content of the page without resize the entire page?

Q:
I would like to scale down the content within the page without
shrinking the page. We are developing a process that goes through each
page of the document and strips out content as well as adding new
content. The problem is that some of the content that already exists
in the page spills over the margins, so when the document is printed
part content is cut off. Therefore, instead of shrinking the page, I
need to shrink the content of the page.
I found page.Scale() method, but it is resizing the entire page.
-----
A:

To resize page content without affecting the page you can use the
following code snippet:

Rect crop_box = page.GetCropBox();
Rect media_box = page.GetMediaBox();
page.Scale(0.5);
page.SetCropBox(crop_box);
page.SetMediaBox(media_box);

RectTest sample project (www.pdftron.com/net/samplecode.html#Rect)
shows how to adjust page media and crop box. The sample code is
shifting the media box rectangle, but you can also resize and rescale
the page rectangle. For example:

Rect crop_box = page.GetMediaBox();
Rect media_box = page.GetMediaBox();

double hinc = crop_box.Width() * 0.10;
double vinc = crop_box.Height() * 0.10;

media_box.x1 -= hinc;
media_box.x1 -= vinc;
media_box.x2 += hinc;
media_box.xy += vinc;
media_box.Update();

crop_box.x1 -= hinc;
crop_box.x1 -= vinc;
crop_box.x2 += hinc;
crop_box.xy += vinc;
crop_box.Update();