Skip to content

Commit

Permalink
Updated document components examples
Browse files Browse the repository at this point in the history
  • Loading branch information
muqarrab-aspose committed Apr 16, 2024
1 parent 04b3435 commit 839edc2
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 127 deletions.
5 changes: 4 additions & 1 deletion content/english/net/document-components/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ url: /net/document-components/

## Document Components Tutorials
### [Add Button Component to PDF Document](./add-button-component-to-pdf/)
Enhance your PDF documents with interactive button components using Groupdocs.Annotation for .NET. Follow our step-by-step tutorial for seamless integration.
### [Add Checkbox Component to PDF Document](./add-checkbox-component-to-pdf/)
### [Add Dropdown Component to PDF Document](./add-dropdown-component-to-pdf/)
Learn how to add a Checkbox Component to PDF documents using Groupdocs.Annotation for .NET. Enhance your PDFs with interactive elements.
### [Add Dropdown Component to PDF Document](./add-dropdown-component-to-pdf/)
Learn how to add dropdown components to PDFs using GroupDocs.Annotation for .NET. Follow our step-by-step guide for seamless integration.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@
title: Add Button Component to PDF Document
linktitle: Add Button Component to PDF Document
second_title: GroupDocs.Annotation .NET API
description:
description: Enhance your PDF documents with interactive button components using Groupdocs.Annotation for .NET. Follow our step-by-step tutorial for seamless integration.
type: docs
weight: 10
url: /net/document-components/add-button-component-to-pdf/
---
## Introduction
In this tutorial, we will guide you through the process of adding a Button Component to a PDF document using Groupdocs.Annotation for .NET. This step-by-step guide will ensure that you can easily integrate this feature into your project.
## Prerequisites
Before you begin, ensure you have the following prerequisites in place:
1. Groupdocs.Annotation for .NET: Make sure you have installed Groupdocs.Annotation for .NET library. You can download it from [here](https://releases.groupdocs.com/annotation/net/).
2. Development Environment: Have a suitable development environment set up with .NET framework installed.

## Complete Source Code
## Import Namespaces
Before proceeding, import the necessary namespaces into your project:
```csharp
using System;
using System.Collections.Generic;
Expand All @@ -17,51 +24,60 @@ using GroupDocs.Annotation.Models;
using GroupDocs.Annotation.Models.AnnotationModels;
using GroupDocs.Annotation.Models.FormatSpecificComponents.Pdf;
using GroupDocs.Annotation.Options;

namespace GroupDocs.Annotation.Examples.CSharp.BasicUsage.AddAnnotationToTheDocument
```
## Step 1: Initialize Output Path
```csharp
string outputPath = Path.Combine(Constants.GetOutputDirectoryPath(), "result" + Path.GetExtension("input.pdf"));
```
## Step 2: Add Button Component
```csharp
using (Annotator annotator = new Annotator("input.pdf"))
{
/// <summary>
/// This example demonstrates adding button component.
/// </summary>
class AddButtonComponent
ButtonComponent button = new ButtonComponent
{
public static void Run()
Box = new Rectangle(100, 100, 100, 100),
PenColor = 65535,
Style = BorderStyle.Dashed,
BorderWidth = 0,
BorderColor = 0,
AlternateName = "Name",
PartialName = "Patial Name",
NormalCaption = "Caption",
ButtonColor = 16761035,
Replies = new List<Reply>
{
string outputPath = Path.Combine(Constants.GetOutputDirectoryPath(), "result" + Path.GetExtension("input.pdf"));

using (Annotator annotator = new Annotator("input.pdf"))
new Reply
{
ButtonComponent button = new ButtonComponent
{
Box = new Rectangle(100, 100, 100, 100),
PenColor = 65535,
Style = BorderStyle.Dashed,
BorderWidth = 0,
BorderColor = 0,
AlternateName = "Name",
PartialName = "Patial Name",
NormalCaption = "Caption",
ButtonColor = 16761035,
Replies = new List<Reply>
{
new Reply
{
Comment = "First comment",
RepliedOn = DateTime.Now
},
new Reply
{
Comment = "Second comment",
RepliedOn = DateTime.Now
}
}
};
annotator.Add(button);
annotator.Save("result.pdf");
Comment = "First comment",
RepliedOn = DateTime.Now
},
new Reply
{
Comment = "Second comment",
RepliedOn = DateTime.Now
}

Console.WriteLine($"\nDocument saved successfully.\nCheck output in {outputPath}.");
}
}
};
annotator.Add(button);
annotator.Save("result.pdf");
}
```
## Step 3: Display Output Path
```csharp
Console.WriteLine($"\nDocument saved successfully.\nCheck output in {outputPath}.");
```
Congratulations! You have successfully added a Button Component to a PDF document using Groupdocs.Annotation for .NET.

## Conclusion
In this tutorial, we have demonstrated how to incorporate Button Components into PDF documents using Groupdocs.Annotation for .NET. By following these steps, you can enhance your PDF documents with interactive features.
## FAQ's
### Can I customize the appearance of the button?
Yes, you can customize various properties such as size, color, and style of the button component according to your requirements.
### Is Groupdocs.Annotation for .NET compatible with all PDF versions?
Groupdocs.Annotation for .NET supports a wide range of PDF versions, ensuring compatibility with most documents.
### Can I add multiple button components to a single PDF document?
Absolutely, you can add as many button components as needed to a PDF document using Groupdocs.Annotation for .NET.
### Does Groupdocs.Annotation for .NET offer support for other file formats?
Yes, in addition to PDF, Groupdocs.Annotation for .NET supports various other document formats including DOCX, PPTX, and XLSX.
### Is there a trial version available for testing purposes?
Yes, you can access a free trial of Groupdocs.Annotation for .NET from [here](https://releases.groupdocs.com/).
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
title: Add Checkbox Component to PDF Document
linktitle: Add Checkbox Component to PDF Document
second_title: GroupDocs.Annotation .NET API
description:
description: Learn how to add a Checkbox Component to PDF documents using Groupdocs.Annotation for .NET. Enhance your PDFs with interactive elements.
type: docs
weight: 11
url: /net/document-components/add-checkbox-component-to-pdf/
---
## Introduction
In this tutorial, we'll guide you through the process of adding a Checkbox Component to a PDF document using Groupdocs.Annotation for .NET.
## Prerequisites
Before we begin, ensure you have the following:
1. Groupdocs.Annotation for .NET SDK: You can download it from [here](https://releases.groupdocs.com/annotation/net/).
2. Development Environment: Make sure you have a .NET development environment set up.

## Complete Source Code
## Import Namespaces
```csharp
using System;
using System.Collections.Generic;
Expand All @@ -17,46 +23,68 @@ using GroupDocs.Annotation.Models;
using GroupDocs.Annotation.Models.AnnotationModels;
using GroupDocs.Annotation.Models.FormatSpecificComponents.Pdf;
using GroupDocs.Annotation.Options;

namespace GroupDocs.Annotation.Examples.CSharp.BasicUsage.AddAnnotationToTheDocument
```
Now, let's break down the example into multiple steps:
## Step 1: Define Output Path
```csharp
string outputPath = Path.Combine(Constants.GetOutputDirectoryPath(), "result" + Path.GetExtension("input.pdf"));
```
Here, we define the output path where the modified PDF document will be saved.
## Step 2: Initialize Annotator
```csharp
using (Annotator annotator = new Annotator("input.pdf"))
```
Initialize the `Annotator` object by passing the input PDF document path.
## Step 3: Create Checkbox Component
```csharp
CheckBoxComponent checkBox = new CheckBoxComponent
{
/// <summary>
/// This example demonstrates adding checkBox component.
/// </summary>
class AddCheckBoxComponent
Checked = true,
Box = new Rectangle(100, 100, 100, 100),
PenColor = 65535,
Style = BoxStyle.Star,
Replies = new List<Reply>
{
public static void Run()
new Reply
{
string outputPath = Path.Combine(Constants.GetOutputDirectoryPath(), "result" + Path.GetExtension("input.pdf"));

using (Annotator annotator = new Annotator("input.pdf"))
{
CheckBoxComponent checkBox = new CheckBoxComponent
{
Checked = true,
Box = new Rectangle(100, 100, 100, 100),
PenColor = 65535,
Style = BoxStyle.Star,
Replies = new List<Reply>
{
new Reply
{
Comment = "First comment",
RepliedOn = DateTime.Now
},
new Reply
{
Comment = "Second comment",
RepliedOn = DateTime.Now
}
}
};
annotator.Add(checkBox);
annotator.Save("result.pdf");
}

Console.WriteLine($"\nDocument saved successfully.\nCheck output in {outputPath}.");
Comment = "First comment",
RepliedOn = DateTime.Now
},
new Reply
{
Comment = "Second comment",
RepliedOn = DateTime.Now
}
}
}
};
```
Create a `CheckBoxComponent` object and customize its properties like `Checked`, `Box` dimensions, `PenColor`, `Style`, and add some replies.
## Step 4: Add Checkbox Component
```csharp
annotator.Add(checkBox);
```
Add the created checkbox component to the PDF document.
## Step 5: Save Document
```csharp
annotator.Save("result.pdf");
```
Save the modified PDF document with the checkbox component.
## Step 6: Display Output Path
```csharp
Console.WriteLine($"\nDocument saved successfully.\nCheck output in {outputPath}.");
```
Display the path where the modified PDF document is saved.

## Conclusion
In this tutorial, we've learned how to add a Checkbox Component to a PDF document using Groupdocs.Annotation for .NET. With this knowledge, you can enhance your PDF documents with interactive elements.
## FAQ's
### Can I customize the appearance of the checkbox?
Yes, you can customize various properties such as color, style, and size according to your requirements.
### Is Groupdocs.Annotation for .NET suitable for commercial use?
Yes, Groupdocs.Annotation for .NET offers commercial licenses for businesses.
### Can I try Groupdocs.Annotation for .NET before purchasing?
Yes, you can avail of a free trial from [here](https://releases.groupdocs.com/).
### Where can I find support for Groupdocs.Annotation for .NET?
You can find support and resources on the [Groupdocs forum](https://forum.groupdocs.com/c/annotation/10).
### Do I need a temporary license for testing purposes?
You can obtain a temporary license for testing from [here](https://purchase.groupdocs.com/temporary-license/).
Loading

0 comments on commit 839edc2

Please sign in to comment.