Skip to content

Commit

Permalink
Updated document loading essentials exmaples
Browse files Browse the repository at this point in the history
  • Loading branch information
muqarrab-aspose committed Apr 16, 2024
1 parent 839edc2 commit 2e6acca
Show file tree
Hide file tree
Showing 9 changed files with 498 additions and 300 deletions.
10 changes: 9 additions & 1 deletion content/english/net/document-loading-essentials/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ url: /net/document-loading-essentials/

## Document Loading Essentials Tutorials
### [Load Document from Amazon S3](./load-document-from-amazon-s3/)
Learn how to annotate documents programmatically with Groupdocs.Annotation for .NET. Step-by-step tutorial for seamless integration.
### [Load Document from Azure](./load-document-from-azure/)
Learn how to annotate documents in .NET using GroupDocs.Annotation. Step-by-step tutorial for seamless integration with Azure Blob Storage.
### [Load Document from FTP](./load-document-from-ftp/)
Enhance your .NET applications with GroupDocs.Annotation for seamless document annotation. Step-by-step tutorial included.
### [Load Document from Local Disk](./load-document-from-local-disk/)
Unlock the power of document annotation with GroupDocs.Annotation for .NET. Seamlessly integrate annotation features into your .NET applications.
### [Load Document from Stream](./load-document-from-stream/)
Learn how to annotate documents in .NET effortlessly with GroupDocs.Annotation. Enhance collaboration and productivity.
### [Load Document from URL](./load-document-from-url/)
Learn how to annotate PDF documents programmatically using GroupDocs.Annotation for .NET. Step-by-step tutorial with code examples.
### [Loading Annotated Document Version](./loading-annotated-document-version/)
### [Load Password Protected Documents](./load-password-protected-documents/)
Learn how to effortlessly load annotated document versions using GroupDocs.Annotation for .NET. Simplify collaboration and review processes.
### [Load Password Protected Documents](./load-password-protected-documents/)
Enhance collaboration & document review with GroupDocs.Annotation for .NET. Annotate PDF & more seamlessly in your .NET apps.
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,77 @@
title: Load Document from Amazon S3
linktitle: Load Document from Amazon S3
second_title: GroupDocs.Annotation .NET API
description:
description: Learn how to annotate documents programmatically with Groupdocs.Annotation for .NET. Step-by-step tutorial for seamless integration.
type: docs
weight: 10
url: /net/document-loading-essentials/load-document-from-amazon-s3/
---
## Introduction
In today's digital age, document management is crucial for businesses and individuals alike. Groupdocs.Annotation for .NET provides a powerful solution for annotating documents programmatically, enabling developers to enhance document collaboration and streamline workflows. In this tutorial, we will delve into the fundamentals of using Groupdocs.Annotation for .NET, breaking down each example into multiple steps to guide you through the process seamlessly.
## Prerequisites
Before we dive into the tutorial, ensure you have the following prerequisites in place:
1. Basic Knowledge of C#: Familiarity with C# programming language is essential to understand the code examples.
2. Installation of Groupdocs.Annotation for .NET: Download and install Groupdocs.Annotation for .NET from the [website](https://releases.groupdocs.com/annotation/net/).
3. Access to an Amazon S3 Bucket: You'll need access to an Amazon S3 bucket to load documents for annotation.

## Import Namespaces
Let's start by importing the necessary namespaces to begin coding:

## Complete Source Code
```csharp
#if !NETCOREAPP
using Amazon.S3;
using Amazon.S3.Model;
using GroupDocs.Annotation.Models;
using GroupDocs.Annotation.Models.AnnotationModels;
using System;
using System.IO;
```

namespace GroupDocs.Annotation.Examples.CSharp.AdvancedUsage.Loading
{
/// <summary>
/// This example demonstrates loading document from Amazon S3 storage.
/// </summary>
class LoadDocumentFromAmazonS3
{
public static void Run()
{
string outputPath = Path.Combine(Constants.GetOutputDirectoryPath(), "result" + Path.GetExtension("input.pdf"));

string key = "sample.pdf";
using (Annotator annotator = new Annotator(DownloadFile(key)))
{
AreaAnnotation area = new AreaAnnotation()
{
Box = new Rectangle(100, 100, 100, 100),
BackgroundColor = 65535,
};
annotator.Add(area);
annotator.Save(outputPath);
}
Console.WriteLine($"\nDocument saved successfully.\nCheck output in {outputPath}.");
}

private static Stream DownloadFile(string key)
{
AmazonS3Client client = new AmazonS3Client();
string bucketName = "my-bucket";
GetObjectRequest request = new GetObjectRequest
{
Key = key,
BucketName = bucketName
};
using (GetObjectResponse response = client.GetObject(request))
{
MemoryStream stream = new MemoryStream();
response.ResponseStream.CopyTo(stream);
stream.Position = 0;
return stream;
}
}
}
}
#endif
Now, let's walk through the process of loading a document from an Amazon S3 bucket and annotating it using Groupdocs.Annotation for .NET.
## Step 1: Define Output Path
```csharp
string outputPath = Path.Combine(Constants.GetOutputDirectoryPath(), "result" + Path.GetExtension("input.pdf"));
```
## Step 2: Specify Document Key
```csharp
string key = "sample.pdf";
```
## Step 3: Initialize Annotator
```csharp
using (Annotator annotator = new Annotator(DownloadFile(key)))
{
```
## Step 4: Create Area Annotation
```csharp
AreaAnnotation area = new AreaAnnotation()
{
Box = new Rectangle(100, 100, 100, 100),
BackgroundColor = 65535,
};
```
## Step 5: Add Annotation to Document
```csharp
annotator.Add(area);
```
## Step 6: Save Annotated Document
```csharp
annotator.Save(outputPath);
```
## Step 7: Display Success Message
```csharp
Console.WriteLine($"\nDocument saved successfully.\nCheck output in {outputPath}.");
```

## Conclusion
Groupdocs.Annotation for .NET empowers developers to integrate advanced document annotation capabilities into their applications effortlessly. By following this step-by-step tutorial, you can leverage the power of Groupdocs.Annotation to enhance document collaboration and productivity within your projects.
## FAQ's
### Is Groupdocs.Annotation for .NET compatible with all document formats?
Groupdocs.Annotation for .NET supports a wide range of document formats, including PDF, DOCX, PPTX, and more.
### Can I try Groupdocs.Annotation for .NET before purchasing?
Yes, you can explore the features of Groupdocs.Annotation for .NET by accessing the free trial version available [here](https://releases.groupdocs.com/).
### Where can I find documentation for Groupdocs.Annotation for .NET?
Comprehensive documentation for Groupdocs.Annotation for .NET is available [here](https://reference.groupdocs.com/annotation/net/).
### Do I need a temporary license to evaluate Groupdocs.Annotation for .NET?
You can obtain a temporary license for evaluation purposes from [here](https://purchase.groupdocs.com/temporary-license/).
### Where can I seek assistance or support for Groupdocs.Annotation for .NET?
For any queries or support-related issues, you can visit the Groupdocs.Annotation forum [here](https://forum.groupdocs.com/c/annotation/10).
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,99 @@
title: Load Document from Azure
linktitle: Load Document from Azure
second_title: GroupDocs.Annotation .NET API
description:
description: Learn how to annotate documents in .NET using GroupDocs.Annotation. Step-by-step tutorial for seamless integration with Azure Blob Storage.
type: docs
weight: 11
url: /net/document-loading-essentials/load-document-from-azure/
---
## Introduction
In the realm of document management and collaboration, GroupDocs.Annotation for .NET emerges as a robust solution, facilitating seamless annotation and markup functionalities within .NET applications. This tutorial delves into the intricacies of leveraging GroupDocs.Annotation for .NET to annotate documents, offering step-by-step guidance from prerequisites to advanced usage.
## Prerequisites
Before diving into GroupDocs.Annotation for .NET, ensure you have the following prerequisites in place:
1. Installation of .NET Framework: GroupDocs.Annotation for .NET requires a compatible .NET runtime environment. Ensure that you have the .NET Framework installed on your system.
2. Access to GroupDocs.Annotation Library: Obtain access to the GroupDocs.Annotation for .NET library either by downloading it from the website or through package managers like NuGet.
3. Document to Annotate: Prepare the document (e.g., PDF) that you intend to annotate. Ensure that the document is accessible either locally or via a cloud storage service like Azure Blob Storage.

## Complete Source Code
## Import Namespaces
To begin annotating documents using GroupDocs.Annotation for .NET, import the necessary namespaces into your project. This step ensures that you have access to the required classes and functionalities.
```csharp
#if !NETCOREAPP
using GroupDocs.Annotation.Models;
using GroupDocs.Annotation.Models.AnnotationModels;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
using System;
using System.IO;
```

namespace GroupDocs.Annotation.Examples.CSharp.AdvancedUsage.Loading
## Load Document from Azure
To annotate a document stored in Azure Blob Storage, follow these steps:
### Step 1: Set Output Path
Define the output path where the annotated document will be saved.
```csharp
string outputPath = Path.Combine(Constants.GetOutputDirectoryPath(), "result" + Path.GetExtension("input.pdf"));
```
### Step 2: Download Document
Retrieve the document from Azure Blob Storage by invoking the `DownloadFile` method.
```csharp
using (Annotator annotator = new Annotator(DownloadFile(blobName)))
{
/// <summary>
/// This example demonstrates loading document from Azure.
/// </summary>
class LoadDocumentFromAzure
{
public static void Run()
{
string outputPath = Path.Combine(Constants.GetOutputDirectoryPath(), "result" + Path.GetExtension("input.pdf"));

string blobName = "sample.pdf";
using (Annotator annotator = new Annotator(DownloadFile(blobName)))
{
AreaAnnotation area = new AreaAnnotation()
{
Box = new Rectangle(100, 100, 100, 100),
BackgroundColor = 65535,
};
annotator.Add(area);
annotator.Save(outputPath);
}
Console.WriteLine($"\nDocument saved successfully.\nCheck output in {outputPath}.");
}

public static Stream DownloadFile(string blobName)
{
CloudBlobContainer container = GetContainer();
CloudBlob blob = container.GetBlobReference(blobName);
MemoryStream memoryStream = new MemoryStream();
blob.DownloadToStream(memoryStream);
memoryStream.Position = 0;
return memoryStream;
}

private static CloudBlobContainer GetContainer()
{
string accountName = "***";
string accountKey = "***";
string endpoint = $"https://{accountName}.blob.core.windows.net/";
string containerName = "***";
StorageCredentials storageCredentials = new StorageCredentials(accountName, accountKey);
CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(
storageCredentials, new Uri(endpoint), null, null, null);
CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
CloudBlobContainer container = cloudBlobClient.GetContainerReference(containerName);
container.CreateIfNotExists();
return container;
}
}
// Annotation Logic
annotator.Save(outputPath);
}
#endif
```
## Download File from Azure Blob Storage
To download the document from Azure Blob Storage, implement the `DownloadFile` method.
### Step 1: Retrieve Blob
Access the Azure Blob Storage container and retrieve the desired blob.
```csharp
CloudBlobContainer container = GetContainer();
CloudBlob blob = container.GetBlobReference(blobName);
```
### Step 2: Download Blob Content
Download the blob content into a memory stream.
```csharp
MemoryStream memoryStream = new MemoryStream();
blob.DownloadToStream(memoryStream);
memoryStream.Position = 0;
return memoryStream;
```
## Get Azure Blob Storage Container
To interact with Azure Blob Storage, implement the `GetContainer` method.
### Step 1: Initialize Storage Credentials
Provide the necessary account credentials and endpoint information.
```csharp
string accountName = "***";
string accountKey = "***";
string endpoint = $"https://{accountName}.blob.core.windows.net/";
```
### Step 2: Create Blob Client
Create a client to interact with Azure Blob Storage.
```csharp
CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(storageCredentials, new Uri(endpoint), null, null, null);
CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
```
### Step 3: Retrieve Container Reference
Obtain a reference to the specified container.
```csharp
CloudBlobContainer container = cloudBlobClient.GetContainerReference(containerName);
```
### Step 4: Create Container if Not Exists
Ensure that the container exists, and create it if not.
```csharp
container.CreateIfNotExists();
```

## Conclusion
GroupDocs.Annotation for .NET empowers developers with robust document annotation capabilities, seamlessly integrating into .NET applications. By following the steps outlined in this tutorial, you can effectively leverage the functionalities of GroupDocs.Annotation to annotate documents stored in Azure Blob Storage.
#### FAQ's
### Is GroupDocs.Annotation for .NET compatible with all document formats?
GroupDocs.Annotation supports a wide range of document formats, including PDF, DOCX, PPTX, and more.
### Can annotations be customized according to specific requirements?
Yes, GroupDocs.Annotation offers extensive customization options for annotations, allowing users to modify appearance, behavior, and metadata.
### Is GroupDocs.Annotation suitable for collaborative document annotation?
Absolutely! GroupDocs.Annotation facilitates collaborative document annotation by enabling multiple users to add, edit, and review annotations simultaneously.
### Does GroupDocs.Annotation offer cross-platform compatibility?
Yes, GroupDocs.Annotation is designed to work seamlessly across various platforms, including Windows, Linux, and macOS.
### Is technical support available for GroupDocs.Annotation users?
Yes, GroupDocs provides comprehensive technical support through its forums and dedicated support channels.
Loading

0 comments on commit 2e6acca

Please sign in to comment.