Skip to content

Commit

Permalink
Updated rendering options
Browse files Browse the repository at this point in the history
  • Loading branch information
muqarrab-aspose committed Mar 14, 2024
1 parent 54d077e commit 3cc8574
Show file tree
Hide file tree
Showing 13 changed files with 751 additions and 325 deletions.
14 changes: 13 additions & 1 deletion content/english/net/rendering-options/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,26 @@ url: /net/rendering-options/

## Rendering Options Tutorials
### [Add Watermark in Document](./add-watermark/)
Learn how to seamlessly add watermarks to documents using GroupDocs.Viewer for .NET. Enhance document security and branding with this easy-to-follow tutorial.
### [Cancel Render with CancellationToken](./cancel-render-cancellation-token/)
Integrate Groupdocs.Viewer for .NET seamlessly into your .NET projects for efficient document viewing.
### [Flip and Rotate Pages](./flip-rotate-pages/)
Learn how to integrate Groupdocs.Viewer for .NET into your applications for seamless document rendering, flipping, and rotation.
### [Render Document with Comments](./render-document-comments/)
Learn how to render documents with comments using GroupDocs.Viewer for .NET. Follow our step-by-step guide for seamless integration.
### [Render Document with Notes](./render-document-notes/)
Learn how to render documents with notes using GroupDocs.Viewer for .NET. Step-by-step tutorial for seamless integration into your .NET applications.
### [Render Hidden Pages](./render-hidden-pages/)
Enhance your .NET application with GroupDocs.Viewer for seamless document rendering. Follow our step-by-step guide to render hidden pages effortlessly.
### [Render N Consecutive Pages](./render-n-consecutive-pages/)
Learn how to integrate GroupDocs.Viewer for .NET into your applications to effortlessly render documents with N consecutive pages.
### [Render Selected Pages](./render-selected-pages/)
Learn how to render selected pages from documents using Groupdocs.Viewer for .NET. Step-by-step tutorial with code examples included.
### [Render with Custom Fonts](./render-custom-fonts/)
Learn how to render documents with custom fonts using GroupDocs.Viewer for .NET. Enhance visual presentations effortlessly.
### [Reorder Pages in Document](./reorder-pages/)
Learn how to reorder pages in a document using GroupDocs.Viewer for .NET. Follow our step-by-step tutorial for seamless document management.
### [Replace Missing Font](./replace-missing-font/)
### [Set Image Size Limits](./set-image-size-limits/)
Learn how to replace missing fonts in .NET documents effortlessly using GroupDocs.Viewer. Ensure accurate rendering with simple steps.
### [Set Image Size Limits](./set-image-size-limits/)
Learn how to set image size limits in .NET applications effortlessly using GroupDocs.Viewer for .NET, enhancing document viewing experiences.
85 changes: 59 additions & 26 deletions content/english/net/rendering-options/add-watermark/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,75 @@
title: Add Watermark in Document
linktitle: Add Watermark in Document
second_title: GroupDocs.Viewer .NET API
description:
description: Learn how to seamlessly add watermarks to documents using GroupDocs.Viewer for .NET. Enhance document security and branding with this easy-to-follow tutorial.
type: docs
weight: 10
url: /net/rendering-options/add-watermark/
---
## Introduction
In today's digital age, managing and viewing various document formats seamlessly is a necessity for many businesses and individuals alike. Fortunately, with tools like GroupDocs.Viewer for .NET, handling documents becomes a breeze. This powerful .NET library enables developers to effortlessly integrate document viewing functionality into their applications, allowing users to view documents without needing the original software that created them.
## Prerequisites
Before diving into using GroupDocs.Viewer for .NET to add watermarks to documents, ensure you have the following:
1. Environment Setup: Have a development environment set up with .NET Framework or .NET Core installed.
2. GroupDocs.Viewer for .NET: Download and install GroupDocs.Viewer for .NET library from the [download page](https://releases.groupdocs.com/viewer/net/).
3. Document Files: Prepare the document files you want to work with, such as DOCX, PDF, or others.
4. Basic Knowledge of C#: Familiarity with C# programming language is necessary to implement the code examples.

## Import Namespaces
Before starting to add watermarks to documents using GroupDocs.Viewer for .NET, make sure to import the required namespaces in your C# code. This step allows you to access the classes and methods provided by the library seamlessly.

## Complete Source Code
```csharp
using System;
using System.IO;
using GroupDocs.Viewer.Options;
```

namespace GroupDocs.Viewer.Examples.CSharp.AdvancedUsage.Rendering.CommonRenderingOptions
Now, let's walk through the process of adding a watermark to a document using GroupDocs.Viewer for .NET. Follow these steps to seamlessly integrate watermarking functionality into your application.
## Step 1: Set Output Directory
```csharp
string outputDirectory = "Your Document Directory";
```
Specify the directory where you want the output files to be saved after applying the watermark.
## Step 2: Define Page File Path Format
```csharp
string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.html");
```
Set the format for the file paths of the rendered pages. In this example, HTML files with page numbers will be generated.
## Step 3: Instantiate Viewer Object
```csharp
using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DOCX))
{
/// <summary>
/// This example demonstrates how to render document and add watermark to each page.
/// </summary>
class AddWatermark
{
public static void Run()
{
string outputDirectory = "Your Document Directory";
string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.html");

using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DOCX))
{
HtmlViewOptions options =
HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat);
options.Watermark = new Watermark("This is a watermark");

viewer.View(options);
}

Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}.");
}
}
// Code continues in the next step...
}

```
Create an instance of the Viewer class, passing the path to the document file as a parameter. In this example, we're using a sample DOCX file.
## Step 4: Configure HTML View Options
```csharp
HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat);
options.Watermark = new Watermark("This is a watermark");
```
Configure the HTML view options, including the watermark text that you want to add to the document.
## Step 5: View Document with Watermark
```csharp
viewer.View(options);
```
Invoke the View method of the Viewer object, passing the configured options. This will render the document with the specified watermark.
## Step 6: Display Output Directory Path
```csharp
Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}.");
```
Inform the user about the successful rendering of the document and indicate the directory where the output files are saved.

## Conclusion
GroupDocs.Viewer for .NET provides a convenient way to add watermarks to documents programmatically. By following the steps outlined in this tutorial, you can seamlessly integrate watermarking functionality into your .NET applications, enhancing document security and branding.
## FAQ's
### Can I customize the appearance of the watermark?
Yes, you can customize various properties of the watermark, such as text, font, color, size, and position.
### Does GroupDocs.Viewer support viewing documents from remote sources?
Yes, GroupDocs.Viewer supports viewing documents from local storage as well as remote URLs.
### Is there a trial version available for GroupDocs.Viewer for .NET?
Yes, you can download a free trial version from [here](https://releases.groupdocs.com/).
### Can I add watermarks to multiple pages of a document?
Absolutely, GroupDocs.Viewer allows adding watermarks to individual pages or all pages of a document.
### How can I get support or assistance if I encounter any issues?
You can seek help and support from the GroupDocs community forums [here](https://forum.groupdocs.com/c/viewer/9).
Original file line number Diff line number Diff line change
@@ -1,53 +1,88 @@
---
title: Cancel Render with CancellationToken
linktitle: Cancel Render with CancellationToken
title: Cancel Render with Cancellation Token
linktitle: Cancel Render with Cancellation Token
second_title: GroupDocs.Viewer .NET API
description:
description: Integrate Groupdocs.Viewer for .NET seamlessly into your .NET projects for efficient document viewing.
type: docs
weight: 11
url: /net/rendering-options/cancel-render-cancellation-token/
---
## Introduction
Groupdocs.Viewer for .NET is a powerful tool designed to simplify document viewing and processing within .NET applications. Whether you're dealing with PDFs, Microsoft Office documents, or other common formats, this library offers robust functionality to seamlessly integrate document viewing capabilities into your .NET projects.
## Prerequisites
Before diving into the integration of Groupdocs.Viewer for .NET, ensure you have the following prerequisites in place:
1. Installation: Download and install the Groupdocs.Viewer for .NET library from the provided [download link](https://releases.groupdocs.com/viewer/net/).

2. License: Obtain a license from [Groupdocs](https://purchase.groupdocs.com/buy) to unlock the full potential of the library. Alternatively, you can start with a free trial using the [temporary license](https://purchase.groupdocs.com/temporary-license/).

3. Development Environment: Ensure you have a compatible development environment set up, including Visual Studio or any other .NET IDE of your choice.

## Import Namespaces
In order to utilize Groupdocs.Viewer for .NET effectively, you need to import the necessary namespaces into your project. Follow these steps:

## Complete Source Code
```csharp
#if NETCOREAPP
using System;
using System.IO;
using GroupDocs.Viewer.Options;
using System.Threading.Tasks;
using System.Threading;
```

namespace GroupDocs.Viewer.Examples.CSharp.AdvancedUsage.Rendering.CommonRenderingOptions
Now, let's break down the provided example into multiple steps for better understanding and implementation:
## Step 1: Define Output Directory
```csharp
string outputDirectory = "Your Document Directory";
```
This step sets the directory where the rendered document pages will be stored.
## Step 2: Define Page File Path Format
```csharp
string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.html");
```
Here, we define the format for the file paths of individual document pages.
## Step 3: Initialize CancellationTokenSource
```csharp
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
```
CancellationTokenSource is used to generate CancellationToken instances that can be used to cancel asynchronous operations.
## Step 4: Obtain CancellationToken
```csharp
CancellationToken cancellationToken = cancellationTokenSource.Token;
```
This step retrieves the token from the CancellationTokenSource, which will be used to cancel the rendering operation.
## Step 5: Render Document Pages
```csharp
Task.Run(() =>
{
/// <summary>
/// Cancel render with cancellation token (for .NET Standard only!).
/// </summary>
class CancelRenderWithCancellationToken
using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DOCX, new ViewerSettings(new GroupDocs.Viewer.Logging.ConsoleLogger())))
{
public static void Run()
{
string outputDirectory = "Your Document Directory";
string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.html");

CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
CancellationToken cancellationToken = cancellationTokenSource.Token;

Task.Run(() =>
{
using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DOCX, new ViewerSettings(new GroupDocs.Viewer.Logging.ConsoleLogger())))
{
HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat);
options.RenderComments = true;

viewer.View(options, cancellationToken);
}
}, cancellationToken);

cancellationTokenSource.CancelAfter(10);

Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}.");
}
HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat);
options.RenderComments = true;
viewer.View(options, cancellationToken);
}
}
#endif
}, cancellationToken);
```
Here, we initiate the rendering of document pages asynchronously using Task.Run(). The Viewer instance is created with the specified document file (SAMPLE_DOCX), and rendering options are configured. The rendering process is then started using the View method of the Viewer class.
## Step 6: Set Render Timeout
```csharp
cancellationTokenSource.CancelAfter(10);
```
This step sets a timeout of 10 milliseconds for the rendering operation. If the operation exceeds this timeout, it will be automatically canceled.
## Step 7: Display Success Message
```csharp
Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}.");
```
Finally, a success message is displayed indicating that the document has been rendered successfully.

## Conclusion
In this tutorial, we've covered the basics of integrating Groupdocs.Viewer for .NET into your projects. By following the steps outlined above, you can seamlessly incorporate document viewing capabilities into your .NET applications, enhancing user experience and productivity.
## FAQ's
### Is Groupdocs.Viewer for .NET compatible with all document formats?
Groupdocs.Viewer for .NET supports a wide range of document formats, including PDF, Microsoft Office documents, images, and more.
### Can I customize the appearance of the rendered document pages?
Yes, you can customize various aspects of the rendering process, including page size, quality, watermarking, and more.
### Does Groupdocs.Viewer for .NET require internet connectivity?
No, Groupdocs.Viewer for .NET operates locally within your .NET environment and does not require internet connectivity for document viewing.
### Is technical support available for Groupdocs.Viewer for .NET?
Yes, technical support is available through the [Groupdocs forum](https://forum.groupdocs.com/c/viewer/9), where you can ask questions, report issues, and interact with the community.
### Can I try Groupdocs.Viewer for .NET before purchasing?
Yes, you can start with a free trial using the provided [trial version](https://releases.groupdocs.com/).
78 changes: 51 additions & 27 deletions content/english/net/rendering-options/flip-rotate-pages/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,65 @@
title: Flip and Rotate Pages
linktitle: Flip and Rotate Pages
second_title: GroupDocs.Viewer .NET API
description:
description: Learn how to integrate Groupdocs.Viewer for .NET into your applications for seamless document rendering, flipping, and rotation.
type: docs
weight: 12
url: /net/rendering-options/flip-rotate-pages/
---
## Introduction
In this tutorial, we will delve into the functionalities of Groupdocs.Viewer for .NET, specifically focusing on flipping and rotating pages. Groupdocs.Viewer for .NET is a powerful tool designed to render documents in various formats within .NET applications. Whether you're developing a document management system or need to integrate document viewing capabilities into your software, Groupdocs.Viewer for .NET provides an efficient solution.
## Prerequisites
Before we begin, ensure you have the following prerequisites set up:
### Installing Groupdocs.Viewer for .NET
To use Groupdocs.Viewer for .NET, you need to install the package via NuGet Package Manager. You can find detailed installation instructions in the [documentation](https://reference.groupdocs.com/viewer/net/).

## Complete Source Code
## Import Namespaces
Ensure you have the necessary namespaces imported in your project to utilize Groupdocs.Viewer for .NET effectively.
```csharp
using System;
using System.IO;
using GroupDocs.Viewer.Options;
```

namespace GroupDocs.Viewer.Examples.CSharp.AdvancedUsage.Rendering.CommonRenderingOptions
{
/// <summary>
/// This example demonstrates how to rotate the first page 90-degree clockwise.
/// </summary>
class FlipRotatePages
{
public static void Run()
{
string outputDirectory = "Your Document Directory";
string outputFilePath = Path.Combine(outputDirectory, "output.pdf");

using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DOCX))
{
PdfViewOptions viewOptions = new PdfViewOptions(outputFilePath);
viewOptions.RotatePage(1, Rotation.On90Degree);

viewer.View(viewOptions);
}

Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}.");
}
}
}

Let's break down the process of flipping and rotating pages using Groupdocs.Viewer for .NET into simple steps:
## Step 1: Set Output Directory and File Path
Define the directory where you want the output file to be saved and specify the output file path.
```csharp
string outputDirectory = "Your Document Directory";
string outputFilePath = Path.Combine(outputDirectory, "output.pdf");
```
## Step 2: Initialize Viewer Object
Create an instance of the Viewer class by passing the path to the document you want to view.
```csharp
using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DOCX))
```
## Step 3: Configure View Options
Set up the view options, such as specifying the output file format and any additional settings like page rotation.
```csharp
PdfViewOptions viewOptions = new PdfViewOptions(outputFilePath);
viewOptions.RotatePage(1, Rotation.On90Degree);
```
## Step 4: Render Document
Invoke the View method of the Viewer object and pass the view options.
```csharp
viewer.View(viewOptions);
```
## Step 5: Display Success Message
Inform the user that the document has been successfully rendered and specify the output directory for verification.
```csharp
Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}.");
```

## Conclusion
In conclusion, Groupdocs.Viewer for .NET offers powerful capabilities for rendering documents, including flipping and rotating pages. By following the steps outlined in this tutorial, you can seamlessly integrate these features into your .NET applications, enhancing document viewing experiences for your users.
## FAQ's
### Is Groupdocs.Viewer for .NET compatible with all document formats?
Yes, Groupdocs.Viewer for .NET supports a wide range of document formats, including DOCX, PDF, PPTX, and more.
### Can I customize the viewing options beyond flipping and rotating pages?
Absolutely, Groupdocs.Viewer for .NET provides various customization options for viewing documents, allowing you to tailor the experience according to your requirements.
### Is there a free trial available for Groupdocs.Viewer for .NET?
Yes, you can avail of a free trial of Groupdocs.Viewer for .NET by visiting the [website](https://releases.groupdocs.com/).
### How can I get support for Groupdocs.Viewer for .NET?
You can seek assistance and engage with the community through the [Groupdocs.Viewer forum](https://forum.groupdocs.com/c/viewer/9).
### Where can I obtain a temporary license for Groupdocs.Viewer for .NET?
Temporary licenses for Groupdocs.Viewer for .NET can be obtained from the [purchase page](https://purchase.groupdocs.com/temporary-license/).
Loading

0 comments on commit 3cc8574

Please sign in to comment.