How do I apply a matrix to a page?

Q: I would like to apply a matrix in order to rotate/scale or shift page contents. How can I do this with the SDK?

A: Its possible to use the ElementBuilder API to create a Form Xobject from a page, and apply any transformation matrix to that. For example, please see the following code on how to horizontally reflect a page:

using (PDFDoc doc = new PDFDoc(@"original.pdf"))
using (ElementBuilder eb = new ElementBuilder())        // ElementBuilder is used to build new Element objects
using (ElementWriter writer = new ElementWriter())  // ElementWriter is used to write Elements to the page    
{
    Page src = doc.GetPage(1);
    Page page = doc.PageCreate(src.GetMediaBox());

    writer.Begin(page);    // begin writing to this page

    Element element = eb.CreateForm(src);
    element.GetGState().SetTransform(-1, 0, 0, 1, src.GetPageWidth(), 0);
    writer.WritePlacedElement(element);
    writer.End();
    doc.PagePushBack(page);
    doc.Save(@"original-reflected.pdf", SDFDoc.SaveOptions.e_linearized);
}

Also, take a look at the ImpositionTest sample.