How do I create / process Form XObjects in PDF?

Q: Do you have any c# code sample dealing with XObjects ?

The idea is to achieve this functionality (from Adobe PDF reference)

"A form XObject may be painted multiple times--either on several pages
or at several locations on the same page--and produces the same results
each time, subject only to the graphics state at the time it is
invoked. Not only is this shared definition economical to represent in
the PDF file, but under suitable circumstances the PDF consumer
application can optimize execution by caching the results of rendering
the form XObject for repeated reuse.
(A form XObject is a PDF content stream that is a self-contained
description of any sequence of graphics objects (including path
objects, text objects, and sampled images). "

The resulting PDF must be compatible with an Adobe RIP.
A: Using PDFNet SDK ( you can both create and
process Form XObject. For an example of how to process Form XObject-s
please take a look at ElementReader sample project (http:// and specifically
code that handles element of type 'Element.Type.e_form'.

To create a Form XObject from scratch you can use ElementBuilder/
ElementWriter. For example:

// In C#
Obj CreateFormXObject(string image_path)
ElementWriter writer = new ElementWriter();
ElementBuilder eb = new ElementBuilder();

Image img = Image.Create(pdfdoc.GetSDFDoc(), image_path);
Element img_element = eb.CreateImage(img, 0, 0, img.GetImageWidth(),
// ... add more content? ... please see ElementBuilder sample project
Obj form_xobject = writer.End();
// Add a clip rect.
form_xobject.PutRect("BBox", 0, 0, img.GetImageWidth(),
return form_xobject;

To place a Form XObject on a new or an existing PDF page you need to
create a form page element from form xobject. For example:

ElementWriter writer = new ElementWriter();
ElementBuilder eb = new ElementBuilder();
Obj form_xobject = CreateFormXObject("my.jpg");
Element element = eb.CreateForm(form_xobject);
// for relevant sample code, please see ElementBuilder sample project
// (

Also, a form element can also be created from an existing page:

Element element = eb.CreateForm(page, pdfdoc);

Q: Do you have a complete c# example for the following:

"A form element can also be created from an existing page:
  Element element = eb.CreateForm(page, pdfdoc);"

Thank you. Your product is impressive !
A: You may want to take a look a Imposition sample project:

In this sample builder.CreateForm(page) is used to convert a existing
PDF page to a Form XObject element which is then placed on the target
page for imposition purposes.