From f777fa5398781460569e4a7ae90a74f91f816b66 Mon Sep 17 00:00:00 2001 From: Muhammad Muqarrab Date: Thu, 14 Mar 2024 11:58:44 +0500 Subject: [PATCH] Updated rendering visio doc --- .../net/rendering-visio-documents/_index.md | 3 +- .../render-visio-figures/_index.md | 143 ++++++++++-------- 2 files changed, 79 insertions(+), 67 deletions(-) diff --git a/content/english/net/rendering-visio-documents/_index.md b/content/english/net/rendering-visio-documents/_index.md index 890547e..6dd7301 100644 --- a/content/english/net/rendering-visio-documents/_index.md +++ b/content/english/net/rendering-visio-documents/_index.md @@ -9,4 +9,5 @@ url: /net/rendering-visio-documents/ --- ## Rendering Visio Documents Tutorials -### [Render Visio Figures](./render-visio-figures/) \ No newline at end of file +### [Render Visio Figures](./render-visio-figures/) +Learn how to render Visio figures using GroupDocs.Viewer for .NET with this comprehensive. Enhance document viewing capabilities in your .NET applications. \ No newline at end of file diff --git a/content/english/net/rendering-visio-documents/render-visio-figures/_index.md b/content/english/net/rendering-visio-documents/render-visio-figures/_index.md index 70aa87f..d8cb82f 100644 --- a/content/english/net/rendering-visio-documents/render-visio-figures/_index.md +++ b/content/english/net/rendering-visio-documents/render-visio-figures/_index.md @@ -2,80 +2,91 @@ title: Render Visio Figures linktitle: Render Visio Figures second_title: GroupDocs.Viewer .NET API -description: +description: Learn how to render Visio figures using GroupDocs.Viewer for .NET with this comprehensive. Enhance document viewing capabilities in your .NET applications. type: docs weight: 10 url: /net/rendering-visio-documents/render-visio-figures/ --- - -## Complete Source Code +## Introduction +In today's digital age, document rendering plays a crucial role in various applications. Whether it's displaying documents on a website or converting them into different formats, efficient rendering is essential. GroupDocs.Viewer for .NET provides a robust solution for viewing and manipulating documents within .NET applications. In this tutorial, we'll delve into rendering Visio figures using GroupDocs.Viewer for .NET, breaking down the process into simple steps. +## Prerequisites +Before diving into the tutorial, ensure you have the following prerequisites: +1. Environment Setup: Make sure you have a working environment for .NET development. +2. GroupDocs.Viewer for .NET: Download and install GroupDocs.Viewer for .NET from the [download link](https://releases.groupdocs.com/viewer/net/). +3. Basic Understanding of C#: Familiarize yourself with C# programming language fundamentals. +4. Sample Visio Document: Have a sample Visio document ready for rendering. + +## Import Namespaces +In your C# project, start by importing the necessary namespaces: ```csharp using GroupDocs.Viewer.Options; using System; using System.IO; - - -namespace GroupDocs.Viewer.Examples.CSharp.AdvancedUsage.Rendering.RenderingOptionsByDocumentType.RenderingImageFiles +``` +## 1. Rendering to HTML +```csharp +string outputDirectory = "Your Document Directory"; +string pageFilePathFormat = Path.Combine(outputDirectory, "result_page.html"); +using (Viewer viewer = new Viewer("YourVisioDocumentPath")) { - /// - /// This example demonstrates how to render Visio documents figures into HTML, JPG, PNG, PDF. - /// - public class RenderingVisioDocumentsFigures - { - public static void Run() - { - string outputDirectory = "Your Document Directory"; - string pageFilePathFormat = Path.Combine(outputDirectory, "result_page.html"); - - // TO HTML - using (Viewer viewer = new Viewer(TestFiles.SAMPLE_VISIO)) - { - HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat); - options.VisioRenderingOptions.RenderFiguresOnly = true; - options.VisioRenderingOptions.FigureWidth = 250; - - viewer.View(options); - } - - // TO JPG - pageFilePathFormat = Path.Combine(outputDirectory, "visio_result.jpg"); - - using (Viewer viewer = new Viewer(TestFiles.SAMPLE_VISIO)) - { - JpgViewOptions options = new JpgViewOptions(pageFilePathFormat); - options.VisioRenderingOptions.RenderFiguresOnly = true; - options.VisioRenderingOptions.FigureWidth = 250; - - viewer.View(options); - } - - // TO PNG - pageFilePathFormat = Path.Combine(outputDirectory, "visio_result.png"); - - using (Viewer viewer = new Viewer(TestFiles.SAMPLE_VISIO)) - { - PngViewOptions options = new PngViewOptions(pageFilePathFormat); - options.VisioRenderingOptions.RenderFiguresOnly = true; - options.VisioRenderingOptions.FigureWidth = 250; - - viewer.View(options); - } - - // TO PDF - pageFilePathFormat = Path.Combine(outputDirectory, "visio_result.pdf"); - - using (Viewer viewer = new Viewer(TestFiles.SAMPLE_VISIO)) - { - PdfViewOptions options = new PdfViewOptions(pageFilePathFormat); - options.VisioRenderingOptions.RenderFiguresOnly = true; - options.VisioRenderingOptions.FigureWidth = 250; - - viewer.View(options); - } - - Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); - } - } + HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat); + options.VisioRenderingOptions.RenderFiguresOnly = true; + options.VisioRenderingOptions.FigureWidth = 250; + viewer.View(options); +} +``` +- Output Directory: Define the directory where the rendered HTML will be saved. +- Page File Path Format: Specify the path format for the HTML page. +- Viewer Initialization: Initialize the Viewer object with the path to the Visio document. +- HTML View Options: Configure options for rendering HTML. +- Visio Rendering Options: Set options specific to Visio rendering, such as rendering only figures and figure width. +## 2. Rendering to JPG +```csharp +string pageFilePathFormat = Path.Combine(outputDirectory, "visio_result.jpg"); +using (Viewer viewer = new Viewer("YourVisioDocumentPath")) +{ + JpgViewOptions options = new JpgViewOptions(pageFilePathFormat); + options.VisioRenderingOptions.RenderFiguresOnly = true; + options.VisioRenderingOptions.FigureWidth = 250; + viewer.View(options); +} +``` +- Similar to rendering to HTML, configure options for rendering to JPG format. +## 3. Rendering to PNG +```csharp +string pageFilePathFormat = Path.Combine(outputDirectory, "visio_result.png"); +using (Viewer viewer = new Viewer("YourVisioDocumentPath")) +{ + PngViewOptions options = new PngViewOptions(pageFilePathFormat); + options.VisioRenderingOptions.RenderFiguresOnly = true; + options.VisioRenderingOptions.FigureWidth = 250; + viewer.View(options); +} +``` +- Configuration for rendering to PNG format follows a similar pattern as JPG rendering. +## 4. Rendering to PDF +```csharp +string pageFilePathFormat = Path.Combine(outputDirectory, "visio_result.pdf"); +using (Viewer viewer = new Viewer("YourVisioDocumentPath")) +{ + PdfViewOptions options = new PdfViewOptions(pageFilePathFormat); + options.VisioRenderingOptions.RenderFiguresOnly = true; + options.VisioRenderingOptions.FigureWidth = 250; + viewer.View(options); } - ``` +- For rendering to PDF, configure options specific to PDF format. + +## Conclusion +In this tutorial, we've explored how to render Visio figures using GroupDocs.Viewer for .NET. By following the step-by-step guide, you can seamlessly integrate document rendering capabilities into your .NET applications, enhancing user experience and productivity. +## FAQ's +### Can I customize the rendering options for Visio figures? +Yes, GroupDocs.Viewer for .NET provides extensive options for customizing rendering, including figure width, rendering only figures, and more. +### Is GroupDocs.Viewer for .NET suitable for large-scale document rendering? +Absolutely, GroupDocs.Viewer for .NET is optimized for handling large-scale document rendering efficiently. +### Does GroupDocs.Viewer support other document formats apart from Visio? +Yes, GroupDocs.Viewer supports a wide range of document formats, including PDF, Microsoft Office, AutoCAD, and more. +### Can I integrate GroupDocs.Viewer into web applications? +Yes, GroupDocs.Viewer can be seamlessly integrated into web applications for document viewing and manipulation. +### Is there a trial version available for testing before purchasing? +Yes, you can avail of a free trial from the [website](https://releases.groupdocs.com/) to test the capabilities of GroupDocs.Viewer for .NET.