How do I rescale and resize a PDF page? How do I place the page on another PDF page?

Q: I am having a problem attempting to copy a pdf page to a new pdf
document and translate it. What I have is an input document, let's
say it is 8.5" x 11". I am creating a new document, let's say 10" x
12". I want to copy the input pdf page to the new document and center
it on the new, larger page. Possibly scale it either larger or
smaller. I cannot find a way to do this without simply moving the
mediabox, as the example in the user manual states, which will screw
up my bounding boxes. I'm sure there is a way to specify where you
want to place the input content. Please advise.

A: In case you would like to completely move/place pages from the
input PDF to a target page in a destination document you can use the
same technique shown in the ImpositionTest sample project (http:// Basically you would
create a form XObject from an existing PDF page (using
element_builder.CreateForm(input_page, doc)) and would place the
resulting element on the target page. The positioning, scaling, and
rotation of the source page on the target page can be fully controlled
using element.GetGState().SetTransform(...).

Another option is to copy page elements from one page to another using
ElementReader/ElementWriter (similar to ElementEdit sample project -

In case you would prefer to modify existing page(s) and then save the
document under a different name you can modify page crop & media box
and possibly rescale the content using page.Scale(zoom) method. For

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

RectTest sample project (
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;

crop_box.x1 -= hinc;
crop_box.x1 -= vinc;
crop_box.x2 += hinc;
crop_box.xy += vinc;