Makes a FormXObject out of the page.

 

   

Syntax
 

[C#]
FormXObject MakeFormXObject()

 

   

Params
 
Name Description
return The newly created FormXObject.

 

   

Notes
 

Makes a FormXObject out of the page.

This process involves copying the page content stream to a new Form XObject and referencing any required resources. The current page is left unaltered.

The returned FormXObject shares the same ObjectSoup as its source Page and can be added to other pages using AddXObject or similar methods.

Form XObjects do not have Annotations so any annotation based markup will be lost unless you Annotation.Stamp the visual appearance into the page before calling this function.

The boundaries of the Form XObject are taken to be the CropBox of the page. If you wish to use a different page bounding box you can adjust the FormXObject.BBox after the MakeFormXObject method has been called.

The page is converted without any page rotation effects. If you wish to rotate the Form XObject this can be done by adjusting the FormXObject.Matrix after the MakeFormXObject method has been called.

The page UserUnit property may be used to scale a page for mapping PDF coordinates to physical coordinates. There is no equivalent for the FormXObject so this value is discarded.

 

   

Example
 

This example shows how to take a page, convert it into a separate drawing object and then draw it, scaled, onto the page it came from.

 

using var doc = new Doc(); doc.Read("../mypics/HyperX.pdf"); var page1 = doc.ObjectSoup[doc.Page] as Page; var form = page1.MakeFormXObject(); doc.Transform.Magnify(0.5, 0.5, 0, 0); doc.Page = doc.AddPage(); var page2 = doc.ObjectSoup[doc.Page] as Page; string name = page2.AddResource(form, "XObject", "Iabc"); // Here we create our own layer for the purposes of the demonstration. // However a simpler approach would be to use Doc.AddXObject. var layer = new StreamObject(doc.ObjectSoup); layer.SetText(String.Format("q {0} cm /{1} Do Q ", doc.Transform.ToString(), name)); page2.AddLayer(layer); doc.Save("exampleformxobject.pdf");


exampleformxobject.pdf [Page 1]


exampleformxobject.pdf [Page 2]