Skip to main content

Group of Elements

Version: 12.0

Grouping Page Elements

Group page elements so they are treated as a group when applying a transformation, transparency, or anchoring using DynamicPDF Core Suite for .NET. The following examples illustrate.

How to Add Group to PDF​

The following steps and C# sample code illustrate adding a Group to a PDF document using DynamicPDF Core Suite for .NET.

Steps for Adding Group to a PDF Document​

  1. Create a Document object.
  2. Create a Page object and add it to Document instance.
  3. Create a Group object.
  4. Add the required elements to the group.
  5. Add the Group instance to the Page instance.
  6. Add the Document object's Draw method to draw and save the PDF document.

Sample Code - C#​

Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
Group mygroup = new Group();

mygroup.Add( new Rectangle( 0, 0, 200, 200, 3 ) );
mygroup.Add( new Line( 0, 100, 100, 0, 3 ) );
mygroup.Add( new Line( 100, 0, 200, 100, 3 ) );
mygroup.Add( new Line( 200, 100, 100, 200, 3 ) );
mygroup.Add( new Line( 100, 200, 0, 100, 3 ) );

page.Elements.Add( mygroup );
document.Draw("Output.pdf");

How to Add Anchor Group to PDF​

The following steps and C# sample code illustrate adding an AnchorGroup to a PDF document using DynamicPDF Core Suite for .NET.

Steps for Adding Anchor Group to a PDF Document​

  1. Create a Document object.
  2. Create a Page object and add it to Document instance.
  3. Create an AnchorGroup object.
  4. Add elements to the group.
  5. Add the AnchorGroup instance to the Page instance.
  6. Add the Document object's Draw method to draw and save the PDF document.

Sample Code - C#​

Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
AnchorGroup group = new AnchorGroup(200,200,Align.Center,VAlign.Center);
group.Add(new Rectangle(0, 0, 200, 200, 3));
group.Add(new Line(0, 100, 100, 0, 3));
group.Add(new Line(100, 0, 200, 100, 3));
group.Add(new Line(200, 100, 100, 200, 3));
group.Add(new Line(100, 200, 0, 100, 3));
page.Elements.Add(group);
document.Draw("Output.pdf");

How to Add AreaGroup to PDF​

The following steps and C# sample code add an AreaGroup to a PDF document using DynamicPDF Core Suite for .NET.

Steps for Adding an AreaGroup to a PDF Document​

  1. Create a Document object.
  2. Create a Page object and add it to Document instance.
  3. Create a AreaGroup object.
  4. Add needed elements to the AreaGroup.
  5. Add the AreaGroup instance to the Page instance.
  6. Add the Document object's Draw method to draw and save the PDF document.

Sample Code - C#​

Document document = new Document();
Page page = new Page();
document.Pages.Add(page);

AreaGroup group1 = new AreaGroup(200, 200);
group1.Add(new Rectangle(0, 0, 200, 200, 3));
group1.Add(new Line(0, 100, 100, 0, 3));
group1.Add(new Line(100, 0, 200, 100, 3));
group1.Add(new Line(200, 100, 100, 200, 3));
group1.Add(new Line(100, 200, 0, 100, 3));

page.Elements.Add(group1);
document.Draw("Output.pdf");

How to Add TransformationGroup to PDF in C#​

The following steps and C# sample code illustrate adding a TransformationGroup to a PDF document using DynamicPDF Core Suite for .NET.

Steps for Adding TransformationGroup to PDF Document​

  1. Create a Document object.
  2. Create a Page object and add it to Document instance.
  3. Create a TransformationGroup object and add the Rectangle object and Label object to it.
  4. Vertically scale the group.
  5. Add the TransformationGroup instance to the Document instance.
  6. Add the Document object's Draw method to draw and save the PDF document.

Sample Code - C#​

Document document = new Document();

Page page = new Page();
document.Pages.Add(page);

TransformationGroup group1 = new TransformationGroup(100, 100, 200, 200, 30);
group1.Add(new Rectangle(0, 0, 75, 75, RgbColor.Blue, RgbColor.Blue));
group1.Add(new Label("This text is inside a TransformationGroup.", 0, 100, 300, 12));
group1.ScaleY = 2;

page.Elements.Add(group1);
document.Draw("Output.pdf");

How to Add TransparencyGroup to PDF​

The following steps and C# sample code illustrate adding a TransparencyGroup to a PDF document using DynamicPDF Core Suite for .NET.

Steps for Adding a TransparencyGroup to a PDF Document​

  1. Create a Document object.
  2. Create a Page object and add it to the Document instance.
  3. Create a TransparencyGroup object and add a Rectangle object.
  4. Add a Label to the Page instance.
  5. Vertically scale the group.
  6. Add the TransparencyGroup instance to the Page instance.
  7. Add the Document object's Draw method to draw and save the PDF document.

Sample Code - C#​

Document document = new Document();
Page page = new Page();
document.Pages.Add(page);

TransparencyGroup group1 = new TransparencyGroup(0.5f);
group1.Add(new Rectangle(0, 0, 75, 75, RgbColor.Blue, RgbColor.Blue));
group1.Add(new Label("This text is inside a TransparencyGroup.", 0, 100, 300, 12));

page.Elements.Add(group1);
document.Draw("Output.pdf");

GitHub Project​

Examples are provided in C# and VB.NET. Clone or view the example project at GitHub. This example code above is in the following files.

View source on GitHub: Core Suite .NET Core Examples

Getting Started​

Get started easily by installing DynamicPDF Core Suite for .NET through NuGet or manually. Then, refer to the documentation for more information on using and purchasing.

NuGet Package​

The easiest way to install DynamicPDF Core Suite is by obtaining the NuGet package using Visual Studio's Package Manager. You can also obtain the NuGet package by downloading it directly. Refer to the installation documentation for more information.

Get ceTe.DynamicPDF.CoreSuite.NET from NuGet

DynamicPDF Core Suite Information​

DynamicPDF Core Suite for .NET combines creating, merging, and visual report creation into one powerful product for creating PDF documents. It is ideal for anyone who needs to generate PDF documents or reports or work with existing PDFs in their applications. With a free Evaluation Edition to try and with flexible and royalty-free licensing options, why not start using DynamicPDF Core Suite for .NET today!

More Information on Groups​

Available on Other Platforms​

DynamicPDF Core Suite is also available for the Java and COM/ActiveX platforms. Refer to the respective product pages for more details.