From b6acbb8802e0bd0ea6b2237ac213d483f33faaff Mon Sep 17 00:00:00 2001 From: Muhammad Muqarrab Date: Wed, 13 Mar 2024 15:42:55 +0500 Subject: [PATCH] Updated loading documents --- .../english/net/loading-documents/_index.md | 1 - .../loading-document-url/_index.md | 64 ------------------- 2 files changed, 65 deletions(-) delete mode 100644 content/english/net/loading-documents/loading-document-url/_index.md diff --git a/content/english/net/loading-documents/_index.md b/content/english/net/loading-documents/_index.md index 177054f..165b02c 100644 --- a/content/english/net/loading-documents/_index.md +++ b/content/english/net/loading-documents/_index.md @@ -11,7 +11,6 @@ url: /net/loading-documents/ ## Loading Documents Tutorials ### [Load Documents from Local Disk](./loading-document-local-disk/) Learn how to seamlessly render documents from your local disk using Groupdocs.Viewer for .NET. Enhance your .NET applications with efficient document. -### [Load Documents from URL](./loading-document-url/) ### [Load Documents from Stream](./loading-document-stream/) Learn how to seamlessly load documents from streams using GroupDocs.Viewer for .NET. Enhance your .NET applications with powerful document viewing capabilities. ### [Load Documents from FTP (Advanced)](./loading-document-ftp/) diff --git a/content/english/net/loading-documents/loading-document-url/_index.md b/content/english/net/loading-documents/loading-document-url/_index.md deleted file mode 100644 index ca3c1d8..0000000 --- a/content/english/net/loading-documents/loading-document-url/_index.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -title: Load Documents from URL -linktitle: Load Documents from URL -second_title: GroupDocs.Viewer .NET API -description: -type: docs -weight: 11 -url: /net/loading-documents/loading-document-url/ ---- - -## Complete Source Code -```csharp -using System; -using System.IO; -using System.Net; -using GroupDocs.Viewer.Options; - -namespace GroupDocs.Viewer.Examples.CSharp.AdvancedUsage.Loading.LoadingDocumentsFromDifferentSources -{ - /// - /// This example demonstrates how to download and render document. - /// - class LoadDocumentFromUrl - { - public static void Run() - { - string url = "https://cms.admin.containerize.com/templates/groupdocs/images/logos/groupdocs-logo.png"; - string outputDirectory = "Your Document Directory"; - string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.html"); - Stream stream = DownloadFile(url); - - using (Viewer viewer = new Viewer(stream)) - { - HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat); - viewer.View(options); - } - - Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); - } - - private static Stream DownloadFile(string url) - { - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); - request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0"; - request.Timeout = 10000; - - using (WebResponse response = request.GetResponse()) - return GetFileStream(response); - } - - private static Stream GetFileStream(WebResponse response) - { - MemoryStream fileStream = new MemoryStream(); - - using (Stream responseStream = response.GetResponseStream()) - responseStream.CopyTo(fileStream); - - fileStream.Position = 0; - return fileStream; - } - } -} - -```