// Creates some text and associate it with the text layer static Obj CreateGroup3(PDFDoc doc, Obj layer) { using (ElementWriter writer = new ElementWriter()) using (ElementBuilder builder = new ElementBuilder()) { writer.Begin(doc); // Begin writing a block of text Element element = builder.CreateTextBegin(Font.Create(doc, Font.StandardType1Font.e_times_roman), 120); writer.WriteElement(element); element = builder.CreateTextRun("A text layer!"); // Rotate text 45 degrees, than translate 180 pts horizontally and 100 pts vertically. Matrix2D transform = Matrix2D.RotationMatrix(-45 * (3.1415 / 180.0)); transform.Concat(1, 0, 0, 1, 180, 100); element.SetTextMatrix(transform); writer.WriteElement(element); writer.WriteElement(builder.CreateTextEnd()); Obj grp_obj = writer.End(); // Indicate that this form (content group) belongs to the given layer (OCG). grp_obj.PutName("Subtype", "Form"); grp_obj.Put("OC", layer); grp_obj.PutRect("BBox", 0, 0, 1000, 1000); // Set the clip box for the content. return(grp_obj); } }