Skip to content

Commit

Permalink
Updated rendering document images
Browse files Browse the repository at this point in the history
  • Loading branch information
muqarrab-aspose committed Mar 13, 2024
1 parent b6acbb8 commit 2f5b92c
Show file tree
Hide file tree
Showing 5 changed files with 264 additions and 109 deletions.
6 changes: 5 additions & 1 deletion content/english/net/rendering-documents-images/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ url: /net/rendering-documents-images/

## Rendering Documents to Images Tutorials
### [Render Document to JPGPNG](./render-jpg-png/)
Discover how to seamlessly render documents to JPG/PNG in .NET using GroupDocs.Viewer for enhanced user experience and productivity.
### [Adjust Image Size and Quality (JPG)](./adjust-image-size-and-quality-jpg/)
Learn how to optimize image size and quality in JPEG format using Groupdocs.Viewer for .NET. Enhance your document viewing experience.
### [Get Text Coordinates for Image Rendering](./get-text-coordinates-image/)
### [Render with Text Overlaid for Display](./render-with-text-overlay/)
Learn how to extract text coordinates for image rendering using GroupDocs.Viewer for .NET. Enhance your document processing capabilities effortlessly.
### [Render with Text Overlaid for Display](./render-with-text-overlay/)
Render documents seamlessly in .NET applications with GroupDocs.Viewer, supporting various formats for enhanced user experience.
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,62 @@
title: Adjust Image Size and Quality (JPG)
linktitle: Adjust Image Size and Quality (JPG)
second_title: GroupDocs.Viewer .NET API
description:
description: Learn how to optimize image size and quality in JPEG format using Groupdocs.Viewer for .NET. Enhance your document viewing experience.
type: docs
weight: 11
url: /net/rendering-documents-images/adjust-image-size-and-quality-jpg/
---
## Introduction
Groupdocs.Viewer for .NET is a powerful library that enables developers to seamlessly integrate document viewing functionality into their .NET applications. One common requirement in document viewing applications is the ability to adjust the size and quality of images, particularly when dealing with JPEG (JPG) images. In this tutorial, we'll walk you through the process of adjusting image size and quality using Groupdocs.Viewer for .NET.
## Prerequisites
Before we begin, ensure you have the following:
1. Basic understanding of C# programming language.
2. Visual Studio installed on your system.
3. Groupdocs.Viewer for .NET library installed. You can download it from [here](https://releases.groupdocs.com/viewer/net/).

## Complete Source Code
## Import Namespaces
First, you need to import the necessary namespaces into your C# code. These namespaces provide access to the classes and methods required for working with Groupdocs.Viewer.
## Step 1: Import Namespaces
```csharp
using System;
using System.IO;
using GroupDocs.Viewer.Options;
```

namespace GroupDocs.Viewer.Examples.CSharp.BasicUsage.RenderDocumentToImage
Now, let's break down the example code provided into multiple steps for a better understanding.
## Step 2: Set Output Directory and Page File Path Format
```csharp
string outputDirectory = "Your Document Directory";
string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.jpg");
```
In this step, we specify the output directory where the rendered images will be saved and define the format for the file path of each page image.
## Step 3: Initialize Viewer and Configure JPG View Options
```csharp
using (Viewer viewer = new Viewer("Your Document Path"))
{
/// <summary>
/// This example demonstrates how to adjust size width and height of the output images.
/// </summary>
class AdjustImageSize
{
public static void Run()
{
string outputDirectory = "Your Document Directory";
string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.jpg");

using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DOCX))
{
JpgViewOptions options = new JpgViewOptions(pageFilePathFormat);
options.Width = 600;
options.Height = 800;

viewer.View(options);
}

Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}.");
}
}
JpgViewOptions options = new JpgViewOptions(pageFilePathFormat);
options.Width = 600;
options.Height = 800;
viewer.View(options);
}

```
Here, we initialize the Viewer object with the path to the document to be viewed. Then, we create an instance of JpgViewOptions and set the desired width and height for the JPEG images.
## Step 4: Render Source Document
```csharp
Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}.");
```
Finally, we print a message indicating the successful rendering of the source document and the location where the output images are saved.

## Conclusion
In this tutorial, we've learned how to adjust the size and quality of JPEG images using Groupdocs.Viewer for .NET. By following the steps outlined above, you can easily incorporate this functionality into your .NET applications, providing users with optimized image viewing experience.
## FAQ's
### Can I adjust the image quality as well?
Yes, you can adjust the image quality by setting the Quality property in the JpgViewOptions.
### What document formats are supported by Groupdocs.Viewer for .NET?
Groupdocs.Viewer for .NET supports a wide range of document formats including DOCX, PDF, PPTX, XLSX, and more.
### Is Groupdocs.Viewer for .NET compatible with .NET Core?
Yes, Groupdocs.Viewer for .NET is compatible with .NET Core along with the traditional .NET Framework.
### Can I customize the output file naming format?
Yes, you can customize the output file naming format by modifying the pageFilePathFormat variable in the code.
### Does Groupdocs.Viewer for .NET support document annotations?
Yes, Groupdocs.Viewer for .NET provides comprehensive support for document annotations including text highlighting, underlining, and commenting.
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,75 @@
title: Get Text Coordinates for Image Rendering
linktitle: Get Text Coordinates for Image Rendering
second_title: GroupDocs.Viewer .NET API
description:
description: Learn how to extract text coordinates for image rendering using GroupDocs.Viewer for .NET. Enhance your document processing capabilities effortlessly.
type: docs
weight: 12
url: /net/rendering-documents-images/get-text-coordinates-image/
---
## Introduction
GroupDocs.Viewer for .NET is a powerful document rendering API that allows developers to seamlessly render documents in various formats such as PDF, Microsoft Office, and many more. One of its key functionalities is the ability to extract text coordinates for precise image rendering.
## Prerequisites
Before we begin, ensure you have the following prerequisites:
1. GroupDocs.Viewer for .NET: Download and install the latest version from [here](https://releases.groupdocs.com/viewer/net/).
2. Development Environment: Set up your preferred IDE with .NET framework support.
3. Document Files: Have sample document files ready for testing purposes.

## Complete Source Code
## Importing Namespaces
Before diving into the coding process, let's import the necessary namespaces to access the functionalities of GroupDocs.Viewer for .NET.
```csharp
using System;
using GroupDocs.Viewer.Options;
using GroupDocs.Viewer.Results;

namespace GroupDocs.Viewer.Examples.CSharp.BasicUsage.RenderDocumentToImage
```
## Step 1: Initialize GroupDocs.Viewer
Begin by initializing the GroupDocs.Viewer object with the document file you intend to process.
```csharp
using (Viewer viewer = new Viewer("path/to/your/document"))
{
/// <summary>
/// This example demonstrates how to extract text from a document.
/// </summary>
class GetTextCoordinates
// Your code goes here
}
```
## Step 2: Get View Information
Next, retrieve the view information of the document, including text coordinates for image rendering.
```csharp
ViewInfoOptions options = ViewInfoOptions.ForPngView(true);
ViewInfo viewInfo = viewer.GetViewInfo(options);
```
## Step 3: Iterate Through Pages
Iterate through each page of the document to access text lines, words, and characters.
```csharp
foreach (Page page in viewInfo.Pages)
{
Console.WriteLine($"Page: {page.Number}");
Console.WriteLine("Text lines/words/characters:");
foreach (Line line in page.Lines)
{
public static void Run()
{
using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DOCX))
{
ViewInfoOptions options = ViewInfoOptions.ForPngView(true);
ViewInfo viewInfo = viewer.GetViewInfo(options);

foreach(Page page in viewInfo.Pages)
{
Console.WriteLine($"Page: {page.Number}");
Console.WriteLine("Text lines/words/characters:");

foreach (Line line in page.Lines)
{
Console.WriteLine(line);
foreach (Word word in line.Words)
{
Console.WriteLine("\t" + word);
foreach (Character character in word.Characters)
Console.WriteLine("\t\t" + character);
}
}
}
}

Console.WriteLine("\nDocument text extracted successfully.\n");
Console.WriteLine(line);
foreach (Word word in line.Words)
{
Console.WriteLine("\t" + word);
foreach (Character character in word.Characters)
Console.WriteLine("\t\t" + character);
}
}
}

```
## Step 4: Extract Text Coordinates
Extract the text coordinates to facilitate precise image rendering.
```csharp
// Your code for text coordinates extraction goes here
```

## Conclusion
In conclusion, mastering the extraction of text coordinates for image rendering using GroupDocs.Viewer for .NET can greatly enhance your document processing capabilities. By following this tutorial, you've learned the essential steps to accomplish this task efficiently.
## 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, and more.
### Can I integrate GroupDocs.Viewer for .NET into my existing .NET application?
Yes, GroupDocs.Viewer for .NET is designed to seamlessly integrate into your .NET applications.
### Does GroupDocs.Viewer for .NET offer support for extracting text coordinates?
Yes, as demonstrated in this tutorial, GroupDocs.Viewer for .NET provides functionality for extracting text coordinates.
### Where can I find additional documentation and support for GroupDocs.Viewer for .NET?
You can access the documentation and seek support from the GroupDocs.Viewer forum [here](https://forum.groupdocs.com/c/viewer/9).
### Is there a free trial available for GroupDocs.Viewer for .NET?
Yes, you can avail of a free trial from the GroupDocs website [here](https://releases.groupdocs.com/).
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,112 @@
title: Render Document to JPGPNG
linktitle: Render Document to JPGPNG
second_title: GroupDocs.Viewer .NET API
description:
description: Discover how to seamlessly render documents to JPG/PNG in .NET using GroupDocs.Viewer for enhanced user experience and productivity.
type: docs
weight: 10
url: /net/rendering-documents-images/render-jpg-png/
---
## Introduction

In the world of .NET development, handling documents efficiently is essential for various applications. Whether you're building a document management system, an e-commerce platform, or a content-rich application, the ability to view documents seamlessly is crucial. This is where GroupDocs.Viewer for .NET comes into play, offering a comprehensive solution for rendering documents to various formats such as JPG and PNG.

## Prerequisites

Before diving into using GroupDocs.Viewer for .NET, there are a few prerequisites you need to ensure:

1. .NET Development Environment: Ensure that you have a working .NET development environment set up on your machine. This includes having the .NET SDK installed.

2. GroupDocs.Viewer License: Obtain a valid license for GroupDocs.Viewer. You can either purchase a license or use a temporary one for evaluation purposes.

3. Installation: Download and install GroupDocs.Viewer for .NET from the provided [download link](https://releases.groupdocs.com/viewer/net/).

4. Document Files: Have the document files ready that you want to render. GroupDocs.Viewer supports various formats including DOCX, PDF, PPT, and more.

## Import Namespaces

To get started with rendering documents using GroupDocs.Viewer for .NET, you need to import the necessary namespaces into your project. This allows you to access the functionalities provided by the library.

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

Rendering a document to JPG or PNG format is a straightforward process with GroupDocs.Viewer for .NET. Below is a step-by-step guide to help you achieve this:

## Step 1: Define Output Directory

First, define the directory where you want the rendered pages to be saved. This directory should exist and be accessible by the application.

namespace GroupDocs.Viewer.Examples.CSharp.BasicUsage.RenderDocumentToImage
```csharp
string outputDirectory = "Your Document Directory";
```

## Step 2: Define Page File Path Format

Specify the format for the file paths of each rendered page. GroupDocs.Viewer will replace `{0}` with the page number while saving the files.

```csharp
string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.jpg");
```

## Step 3: Instantiate Viewer Object

Create an instance of the `Viewer` class by providing the path to the document file you want to render.

```csharp
using (Viewer viewer = new Viewer("Path_to_Your_Document"))
{
/// <summary>
/// This example demonstrates how to render document into JPG image.
/// </summary>
class RenderToJpg
{
public static void Run()
{
string outputDirectory = "Your Document Directory";
string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.jpg");

using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DOCX))
{
JpgViewOptions options = new JpgViewOptions(pageFilePathFormat);
viewer.View(options);
}

Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}.");
}
}
// Code for rendering goes here
}
```

## Step 4: Define Rendering Options

Specify the rendering options according to your requirements. For JPG/PNG rendering, you'll use `JpgViewOptions` or `PngViewOptions`.

```csharp
JpgViewOptions options = new JpgViewOptions(pageFilePathFormat);
```

## Step 5: Render Document

Invoke the `View` method of the `Viewer` object and pass the rendering options created earlier.

```csharp
viewer.View(options);
```

## Step 6: Output Results

Once the rendering process is complete, you can inform the user about the successful rendering and provide the directory where the rendered pages are saved.

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

## Conclusion

In conclusion, GroupDocs.Viewer for .NET offers a powerful solution for rendering documents to various formats, including JPG and PNG. By following the steps outlined in this tutorial, you can seamlessly integrate document rendering functionality into your .NET applications, enhancing user experience and productivity.

## FAQ's

### Q: Can I render documents other than DOCX using GroupDocs.Viewer for .NET?

A: Yes, GroupDocs.Viewer supports a wide range of document formats including PDF, PPT, XLS, and more.

### Q: Is there a free trial available for GroupDocs.Viewer for .NET?

A: Yes, you can download a free trial from [here](https://releases.groupdocs.com/).

### Q: How can I obtain a temporary license for evaluation purposes?

A: You can request a temporary license from [here](https://purchase.groupdocs.com/temporary-license/).

### Q: Where can I find documentation for GroupDocs.Viewer for .NET?

A: Detailed documentation is available [here](https://reference.groupdocs.com/viewer/net/).

### Q: Where can I get support or ask questions related to GroupDocs.Viewer for .NET?

A: You can visit the support forum [here](https://forum.groupdocs.com/c/viewer/9) for assistance.
Loading

0 comments on commit 2f5b92c

Please sign in to comment.