How do I embed a vectorized image such as EPS, center text?

Q: I am able to do everything I need to do with PDFNet library except
I cannot embed a vectorized image such as EPS.

A: PDFNet does not support EPS, however you can scale and place one
PDF page on top of another PDF page. PDF can contain vector art, text,
and images (EPS graphics can be easily converted to PDF using
Distiller or some other tool).
For a concrete sample code please take a look at the ImpositionTest
sample project (

The code may look along the following lines:

Page existing_page = ...

ElementBuilder builder = new ElementBuilder(); ElementWriter writer
= new ElementWriter();

// To write the page behind the (static) content of existing page pass
// as the second parameter to writer.Begin(existing_page, true).

Element element = builder.CreateForm(import_page, existing_page_doc);
double scale = Math.Min(existing_page.GetPageWidth()/
element.GetGState().SetTransform(scale, 0, 0, scale, pos_x, pos_y);


Q: The embedded PDF as a vectorized image works beautifully. Thank

I have been wracking my brains out trying to center Unicode and I
could not find any examples or explanations of how to really do this.
Here is what I have (in C++):

Font fnt;
fnt = Font::CreateCIDTrueTypeFont( doc, "MSMINCHO.TTF", true, true );
Element element = eb.CreateTextBegin( fnt, 1 );

element = eb.CreateUnicodeTextRun( uUnicodeString, iStringLength);
element.SetTextMatrix( 10, 0, 0, 10, ((8.5*72)-
element.GetTextLength())/2.0, 250 );

This is what the examples say to do, but element.GetTextLength() seems
to return half the string length.
A: The problem is due to text scaling (which is not reflected in
GetTextLength()). To fix this issue specify the font text size in
CreateTextBegin(), and set the scaling component in SetTextMatrix() to
1. Alternatively you can keep the code as before, but then you would
need to multiply the return value from GetTextLength() by the scaling
component (i.e. 10 in you case).

Element element = eb.CreateTextBegin(fnt, 10);
writer.WriteElement(element); // iStringLength - number of Unicode
element = eb.CreateUnicodeTextRun(uUnicodeString, iStringLength);
element.SetTextMatrix(1, 0, 0, 1, (page.GetPageWidth()-
element.GetTextLength())/2.0, 250);

Thank you for your help.

The text does render properly. I think I guessed the solution. I
dumbly multiplied the font size by what I get from

  fntsize = 12;
  element = eb.CreateUnicodeTextRun( uUnicodeString, (iStringLength*2)/
  element.SetTextMatrix( fntsize, 0, 0, fntsize, ((8.5*72)-
element.GetTextLength()*fntsize)/2.0, iVerticalStart -
iVerticalOffset );
  writer.WriteElement( element );

I didn't think this would work with a variable font like MSMINCHO but
the results look good.

Thank you for your help.