Examples

How to Add Group to PDF in C#

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

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 (rectangle, line, etc.,).
  5. Add the Group instance to the Page instance.
  6. 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 in C#

Multiple page elements can be added to an Anchor Group and the group to the PDF document. The following steps and sample code illustrate adding a Group to a PDF document using DynamicPDF Core Suite.

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 (rectangle, line, etc.,).
  5. Add the AnchorGroup instance to the Page instance.
  6. 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 in C#

Adding an AreaGroup to a PDF using DynamicPDF Core Suite is straightforward. The following steps and sample code add an AreaGroup to a PDF document using DynamicPDF Core Suite.

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 (rectangle, line, etc.,).
  5. Add the AreaGroup instance to the Page instance.
  6. 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#

Adding TransformationGroup to PDF using DynamicPDF Core Suite is straightforward. The following steps and sample code illustrate adding a TransformationGroup to a PDF document using DynamicPDF Core Suite.

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. 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 in C#

Adding a TransparencyGroup to a PDF using DynamicPDF Core Suite is straightforward. The following steps and sample code illustrate adding a TransparencyGroup to a PDF document using DynamicPDF Core Suite.

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. 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

Clone or view the example project at GitHub. This example code above is in the Examples/GroupExample.cs file.

Clone or View Example Project on GitHub

Getting Started

NuGet Package

DynamicPDF Generator is available on NuGet and is part of the ceTe.DynamicPDF.CoreSuite.NET package. The easiest way to install the package is using the Visual Studio Package Manager, but you can also download the package directly from NuGet.

NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

DynamicPDF Core Suite Information

More information on DynamicPDF Core Suite can be found on its website.

Available on Other Platforms

DynamicPDF Core Suite is available for the following platforms. Refer to the respective product pages for more details.

Why Choose DynamicPDF?

  • Transparent Pricing
  • Lots of Features
  • Easy to Use
  • Great Support
  • Efficient Performance
  • Product Maturity (Over 22 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

We’re Not The Only Ones That Think We’re Great!