How do I write barcode to a PDF document using PDFNet SDK?

Q: How do I write barcode to a PDF document using PDFNet SDK?
----
A: Working with barcode is exactly the same as with any other font.
To create barcode you would need a barcode font. PDFNet can read any
TrueType, OpenType, or Type1 font so you will have lots of choice when
selecting the font. There are many free barcode fonts on the Net; for
purposes of this sample I used FRE3OF9X.TTF - from
http://www.barcodesinc.com/free-barcode-font/free3of9.zip).

The following code snippet writes two barcodes on the page (one
horizontal and another rotated 90 degrees).

PDFDoc doc;
ElementBuilder eb; // ElementBuilder is used to build new Element
objects
ElementWriter writer; // ElementWriter is used to write Elements to
the page

Element* element;

// Start a new page ------------------------------------
Page page = doc.PageCreate(Rect(0, 0, 612, 794));

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

// Begin writing a block of text
element = eb.CreateTextBegin(Font::CreateTrueTypeFont(doc,
"FRE3OF9X.TTF", true, false), 12);
writer.WriteElement(element);

// Draw 'Hello World' in Barcode font.
element = eb.CreateTextRun("Hello World!");
element->SetTextMatrix(10, 0, 0, 10, 0, 600);
writer.WriteElement(element);

// Draw another text run (rotated 90 degrees)
element = eb.CreateTextRun("1234567890");
Matrix2D txt_mtx = Matrix2D(1, 0, 0, 1, 100, 100) * // Translation
  Matrix2D::RotationMatrix(90 * deg2rad); // Rotation
element->SetTextMatrix(txt_mtx);
writer.WriteElement(element);

// Finish the block of text.
writer.WriteElement(eb.CreateTextEnd());

writer.End();
doc.PagePushBack(page);

doc.Save((output_path + "out.pdf").c_str(), Doc::e_linearized, NULL);