diff --git a/.gitignore b/.gitignore index 3f981ed..87fb7d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ deploy_key common/ bin/ -obj/ \ No newline at end of file +obj/ +.vs \ No newline at end of file diff --git a/net/developer-guide/caching-results/_index.md b/net/developer-guide/caching-results/_index.md index e20844d..5a4f5ab 100644 --- a/net/developer-guide/caching-results/_index.md +++ b/net/developer-guide/caching-results/_index.md @@ -23,7 +23,14 @@ The following code snippet shows how to enable caching and displays the differen {{< tabs "example1">}} {{< tab "C#" >}} ```csharp -// Specify parameters. +using System; +using System.Diagnostics; +using System.IO; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Caching; +using GroupDocs.Viewer.Options; +// ... + string outputDirectory = @"C:\output"; string cachePath = Path.Combine(outputDirectory, "cache"); string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.html"); @@ -48,6 +55,58 @@ using (Viewer viewer = new Viewer(@"C:\sample.docx", settings)) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports System.Diagnostics +Imports System.IO +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Caching +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Dim outputDirectory As String = "C:\output" + Dim cachePath As String = Path.Combine(outputDirectory, "cache") + Dim pageFilePathFormat As String = Path.Combine(outputDirectory, "page_{0}.html") + ' Create a cache. + Dim cache As FileCache = New FileCache(cachePath) + Dim settings As ViewerSettings = New ViewerSettings(cache) + + Using viewer As Viewer = New Viewer("C:\sample.docx", settings) + ' Create an HTML file. + Dim options As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat) + ' Render and display the rendering time. + Dim stopWatch As Stopwatch = Stopwatch.StartNew() + viewer.View(options) + stopWatch.[Stop]() + Console.WriteLine("Time taken on first call to View method {0} (ms).", stopWatch.ElapsedMilliseconds) + ' Get cached results and display the time. + stopWatch.Restart() + viewer.View(options) + stopWatch.[Stop]() + Console.WriteLine("Time taken on second call to View method {0} (ms).", stopWatch.ElapsedMilliseconds) + End Using + End Sub +End Module +``` +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +CONVERSION ERROR: Conversion for GlobalStatement not implemented, please report this issue in 'string outputDirectory = @"...' at character 160 + +CONVERSION ERROR: Conversion for GlobalStatement not implemented, please report this issue in 'string cachePath = Path.Com...' at character 200 + +CONVERSION ERROR: Conversion for GlobalStatement not implemented, please report this issue in 'string pageFilePathFormat =...' at character 260 + +CONVERSION ERROR: Conversion for GlobalStatement not implemented, please report this issue in 'FileCache cache = new FileC...' at character 357 + +CONVERSION ERROR: Conversion for GlobalStatement not implemented, please report this issue in 'ViewerSettings settings = n...' at character 402 + +CONVERSION ERROR: Conversion for GlobalStatement not implemented, please report this issue in 'using (Viewer viewer = new ...' at character 458 +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: diff --git a/net/developer-guide/caching-results/how-to-use-custom-cache-implementation.md b/net/developer-guide/caching-results/how-to-use-custom-cache-implementation.md index acb761e..c6d8bbe 100644 --- a/net/developer-guide/caching-results/how-to-use-custom-cache-implementation.md +++ b/net/developer-guide/caching-results/how-to-use-custom-cache-implementation.md @@ -30,10 +30,19 @@ The following code snippet shows how to implement a custom caching using Redis C {{< tabs "example1">}} {{< tab "C#" >}} ```csharp -using GroupDocs.Viewer; +using System; +using System.IO; +using System.Linq; +using System.Diagnostics; +using System.Collections.Generic; +using System.Xml.Serialization; + using GroupDocs.Viewer.Caching; using GroupDocs.Viewer.Options; +using GroupDocs.Viewer; + using StackExchange.Redis; +// ... // Specify the cache parameters. var serverAddress = "127.0.0.1:6379"; @@ -65,7 +74,6 @@ static void PrintTimeTaken(Action action, string format) Console.WriteLine(format, stopwatch.ElapsedMilliseconds); } -// Realize cache. public class RedisCache : ICache, IDisposable { private readonly string _cacheKeyPrefix; @@ -176,6 +184,148 @@ public class RedisCache : ICache, IDisposable } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports System.IO +Imports System.Linq +Imports System.Diagnostics +Imports System.Collections.Generic +Imports System.Runtime.InteropServices +Imports System.Xml.Serialization + +Imports GroupDocs.Viewer.Caching +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer + +Imports StackExchange.Redis + +Module Program + Public Sub Main() + ' Specify the cache parameters. + Dim serverAddress As String = "127.0.0.1:6379" + Dim filePath As String = "sample.docx" + + ' Create the cache. + Dim cache As RedisCache = New RedisCache(serverAddress, filePath) + Dim settings As ViewerSettings = New ViewerSettings(cache) + + Using viewer As Viewer = New Viewer(filePath, settings) + ' Create HTML files. + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + + ' Display rendering time. + PrintTimeTaken(Sub() viewer.View(viewOptions), "The first call to View method took {0} ms.") + ' Display time to get cached results. + PrintTimeTaken(Sub() viewer.View(viewOptions), "The second call to View method took {0} ms.") + End Using + End Sub + + ' Get and display time taken. + Private Sub PrintTimeTaken(action As Action, format As String) + Dim stopwatch As Stopwatch = New Stopwatch() + stopwatch.Start() + action.Invoke() + stopwatch.Stop() + + Console.WriteLine(format, stopwatch.ElapsedMilliseconds) + End Sub + + + Public Class RedisCache + Implements ICache, IDisposable + + Private ReadOnly _cacheKeyPrefix As String + Private ReadOnly _redis As ConnectionMultiplexer + Private ReadOnly _db As IDatabase + Private ReadOnly _host As String + + Public Sub New(host As String, cacheKeyPrefix As String) + _host = host + _cacheKeyPrefix = cacheKeyPrefix + _redis = ConnectionMultiplexer.Connect(_host) + _db = _redis.GetDatabase() + End Sub + + Private Function CopyToMemoryStream(data As Stream) As MemoryStream + Dim result As New MemoryStream() + data.Position = 0 + data.CopyTo(result) + Return result + End Function + + Public Sub [Set](key As String, value As Object) Implements ICache.[Set] + If value Is Nothing Then + Return + End If + + Dim prefixedKey As String = GetPrefixedKey(key) + Dim memoryStream As MemoryStream = Nothing + + If TypeOf value Is Stream Then + memoryStream = If(TypeOf value Is MemoryStream, DirectCast(value, MemoryStream), CopyToMemoryStream(DirectCast(value, Stream))) + Else + memoryStream = New MemoryStream() + Dim serializer As New XmlSerializer(value.GetType()) + serializer.Serialize(memoryStream, value) + End If + + _db.StringSet(prefixedKey, RedisValue.CreateFrom(memoryStream)) + End Sub + + Public Function TryGetValue(Of TEntry)(key As String, ByRef value As TEntry) As Boolean Implements ICache.TryGetValue + Dim prefixedKey As String = GetPrefixedKey(key) + Dim redisValue As RedisValue = _db.StringGet(prefixedKey) + If redisValue.HasValue Then + Dim data As Object = If(GetType(TEntry) = GetType(Stream), ReadStream(redisValue), Deserialize(Of TEntry)(redisValue)) + value = DirectCast(data, TEntry) + Return True + End If + + value = Nothing + Return False + End Function + + Public Function ICache_GetKeys(filter As String) As IEnumerable(Of String) Implements ICache.GetKeys + Return _redis.GetServer(_host).Keys(pattern:=$"*{filter}*").Select(Function(x) x.ToString().Replace(_cacheKeyPrefix, String.Empty)).Where(Function(x) x.StartsWith(filter, StringComparison.InvariantCultureIgnoreCase)).ToList() + End Function + + Private Function GetPrefixedKey(key As String) As String + Return $"{_cacheKeyPrefix}{key}" + End Function + + Private Function ReadStream(redisValue As RedisValue) As Object + Return New MemoryStream(redisValue) + End Function + + Private Function Deserialize(Of T)(redisValue As RedisValue) As T + Dim data As Object + Using stream As New MemoryStream(redisValue) + Dim serializer As New XmlSerializer(GetType(T)) + + Try + data = serializer.Deserialize(stream) + Catch ex As InvalidOperationException + data = Nothing + Catch ex As NullReferenceException + data = Nothing + End Try + End Using + + Return DirectCast(data, T) + End Function + + Public Sub Dispose() + _redis.Dispose() + End Sub + + Public Sub IDisposable_Dispose() Implements IDisposable.Dispose + Throw New NotImplementedException + End Sub + End Class +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: diff --git a/net/developer-guide/caching-results/how-to-make-cache-thread-safe-in-your-.net-csharp-application.md b/net/developer-guide/caching-results/implement-thread-safe-cache-for-groupdocs-viewer.md similarity index 56% rename from net/developer-guide/caching-results/how-to-make-cache-thread-safe-in-your-.net-csharp-application.md rename to net/developer-guide/caching-results/implement-thread-safe-cache-for-groupdocs-viewer.md index 4dd6c32..348e3a6 100644 --- a/net/developer-guide/caching-results/how-to-make-cache-thread-safe-in-your-.net-csharp-application.md +++ b/net/developer-guide/caching-results/implement-thread-safe-cache-for-groupdocs-viewer.md @@ -1,12 +1,14 @@ --- -id: how-to-make-cache-thread-safe-in-your-net-csharp-application -url: viewer/net/how-to-make-cache-thread-safe-in-your-net-csharp-application -title: How to make cache thread-safe in your .NET C# application +id: implement-thread-safe-cache-for-groupdocs-viewer +url: viewer/net/implement-thread-safe-cache-for-groupdocs-viewer +title: Implement thread-safe cache for GroupDocs.Viewer weight: 2 description: "This article explains how to make cache thread safe with GroupDocs.Viewer within your .NET applications." keywords: GroupDocs.Viewer, thread safe, cache productName: GroupDocs.Viewer for .NET hideChildren: False +aliases: + - viewer/net/how-to-make-cache-thread-safe-in-your-net-csharp-application --- This page describes how to develop a thread-sage cache using the [C# lock](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/lock-statement) statement and the [ConcurrentDictionary<,>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentdictionary-2) class. @@ -28,6 +30,9 @@ The FileCache class uses a local disk to read and write output files. You need t {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer.Caching; +using System.Collections.Generic; + internal class ThreadSafeCache : ICache { private readonly ICache _cache; @@ -65,6 +70,42 @@ internal class ThreadSafeCache : ICache } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System.Runtime.InteropServices +Imports GroupDocs.Viewer.Caching + +Class ThreadSafeCache + Implements ICache + Private ReadOnly _cache As ICache + Private ReadOnly _keyLockerStore As IKeyLockerStore + + Public Sub New(cache As ICache, keyLockerStore As IKeyLockerStore) + _cache = cache + _keyLockerStore = keyLockerStore + End Sub + + Public Function TryGetValue(Of TEntry)(key As String, ByRef value As TEntry) As Boolean Implements ICache.TryGetValue + SyncLock _keyLockerStore.GetLockerFor(key) + Return _cache.TryGetValue(key, value) + End SyncLock + End Function + + Public Function ICache_GetKeys(filter As String) As IEnumerable(Of String) Implements ICache.GetKeys + SyncLock _keyLockerStore.GetLockerFor("get_keys") + Return _cache.GetKeys(filter) + End SyncLock + End Function + + Public Sub ICache_Set(key As String, value As Object) Implements ICache.[Set] + SyncLock _keyLockerStore.GetLockerFor(key) + _cache.Set(key, value) + End SyncLock + End Sub + +End Class +``` +{{< /tab >}} {{< /tabs >}} All the ThreadSafeCache class methods use locks to make calls thread safe. The ConcurrentDictionaryKeyLockerStore class uses ConcurrentDictionary to create the locker object or to retrieve it if it already exists. It also creates a unique key that identifies a cached file. @@ -72,6 +113,9 @@ All the ThreadSafeCache class methods use locks to make calls thread safe. The C {{< tabs "example2">}} {{< tab "C#" >}} ```csharp +using System.Collections.Concurrent; +// ... + interface IKeyLockerStore { object GetLockerFor(string key); @@ -101,6 +145,36 @@ class ConcurrentDictionaryKeyLockerStore : IKeyLockerStore } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System.Collections.Concurrent +' ... + +Interface IKeyLockerStore + Function GetLockerFor(key As String) As Object +End Interface + +Class ConcurrentDictionaryKeyLockerStore + Implements IKeyLockerStore + Private ReadOnly _keyLockerMap As ConcurrentDictionary(Of String, Object) + Private ReadOnly _uniqueKeyPrefix As String + + Public Sub New(keyLockerMap As ConcurrentDictionary(Of String, Object), uniqueKeyPrefix As String) + _keyLockerMap = keyLockerMap + _uniqueKeyPrefix = uniqueKeyPrefix + End Sub + + Public Function GetLockerFor(key As String) As Object Implements IKeyLockerStore.GetLockerFor + Dim uniqueKey As String = Me.GetUniqueKey(key) + Return _keyLockerMap.GetOrAdd(uniqueKey, Function(k) New Object()) + End Function + + Private Function GetUniqueKey(key As String) As String + Return $"{_uniqueKeyPrefix}_{key}" + End Function +End Class +``` +{{< /tab >}} {{< /tabs >}} ## Result @@ -108,9 +182,9 @@ class ConcurrentDictionaryKeyLockerStore : IKeyLockerStore {{< tabs "example3">}} {{< tab "C#" >}} ```csharp -using System.Collections.Concurrent; -using System.Collections.Generic; using System.IO; +using System.Collections.Generic; +using System.Collections.Concurrent; using GroupDocs.Viewer; using GroupDocs.Viewer.Caching; using GroupDocs.Viewer.Interfaces; @@ -234,4 +308,113 @@ namespace ThreadSaveCacheExample } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System.IO +Imports System.Collections.Concurrent +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Caching +Imports GroupDocs.Viewer.Interfaces +Imports GroupDocs.Viewer.Options +Imports System.Runtime.InteropServices + +Module Program + Private ReadOnly KeyLockerMap As ConcurrentDictionary(Of String, Object) = New ConcurrentDictionary(Of String, Object)() + + Public Sub Main() + Dim fileName As String = "resume.pdf" + Dim cacheFolder As String = fileName.Replace("."c, "_"c) + Dim cachePath As String = Path.Combine("cache", cacheFolder) + Dim uniqueKeyPrefix As String = cachePath + + Dim fileCache As ICache = New FileCache(cachePath) + Dim keyLockerStore As IKeyLockerStore = New ConcurrentDictionaryKeyLockerStore(KeyLockerMap, uniqueKeyPrefix) + Dim threadSafeCache As ICache = New ThreadSafeCache(fileCache, keyLockerStore) + + Dim viewerSettings As ViewerSettings = New ViewerSettings(threadSafeCache) + + Dim pages As List(Of MemoryStream) = New List(Of MemoryStream)() + Using viewer As Viewer = New Viewer(fileName, viewerSettings) + Dim pageStreamFactory As IPageStreamFactory = New MemoryPageStreamFactory(pages) + Dim viewOptions As ViewOptions = HtmlViewOptions.ForEmbeddedResources(pageStreamFactory) + viewer.View(viewOptions) + End Using + End Sub +End Module + +Class ThreadSafeCache + Implements ICache + Private ReadOnly _cache As ICache + Private ReadOnly _keyLockerStore As IKeyLockerStore + + Public Sub New(cache As ICache, keyLockerStore As IKeyLockerStore) + _cache = cache + _keyLockerStore = keyLockerStore + End Sub + + Public Function TryGetValue(Of TEntry)(key As String, ByRef value As TEntry) As Boolean Implements ICache.TryGetValue + SyncLock _keyLockerStore.GetLockerFor(key) + Return _cache.TryGetValue(key, value) + End SyncLock + End Function + + Public Function ICache_GetKeys(filter As String) As IEnumerable(Of String) Implements ICache.GetKeys + SyncLock _keyLockerStore.GetLockerFor("get_keys") + Return _cache.GetKeys(filter) + End SyncLock + End Function + + Public Sub ICache_Set(key As String, value As Object) Implements ICache.[Set] + SyncLock _keyLockerStore.GetLockerFor(key) + _cache.Set(key, value) + End SyncLock + End Sub + +End Class + +Interface IKeyLockerStore + Function GetLockerFor(key As String) As Object +End Interface + +Class ConcurrentDictionaryKeyLockerStore + Implements IKeyLockerStore + Private ReadOnly _keyLockerMap As ConcurrentDictionary(Of String, Object) + Private ReadOnly _uniqueKeyPrefix As String + + Public Sub New(keyLockerMap As ConcurrentDictionary(Of String, Object), uniqueKeyPrefix As String) + _keyLockerMap = keyLockerMap + _uniqueKeyPrefix = uniqueKeyPrefix + End Sub + + Public Function GetLockerFor(key As String) As Object Implements IKeyLockerStore.GetLockerFor + Dim uniqueKey As String = Me.GetUniqueKey(key) + Return _keyLockerMap.GetOrAdd(uniqueKey, Function(k) New Object()) + End Function + + Private Function GetUniqueKey(key As String) As String + Return $"{_uniqueKeyPrefix}_{key}" + End Function +End Class + +Class MemoryPageStreamFactory + Implements IPageStreamFactory + Private ReadOnly _pages As List(Of MemoryStream) + + Public Sub New(pages As List(Of MemoryStream)) + _pages = pages + End Sub + + Public Sub IPageStreamFactory_ReleasePageStream(pageNumber As Integer, pageStream As Stream) Implements IPageStreamFactory.ReleasePageStream + 'Do not release page stream as we'll need to keep the stream open + End Sub + + Public Function IPageStreamFactory_CreatePageStream(pageNumber As Integer) As Stream Implements IPageStreamFactory.CreatePageStream + Dim pageStream As MemoryStream = New MemoryStream() + _pages.Add(pageStream) + + Return pageStream + End Function +End Class +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/loading-documents/load-password-protected-document.md b/net/developer-guide/loading-documents/load-password-protected-document.md index faa1239..a237396 100644 --- a/net/developer-guide/loading-documents/load-password-protected-document.md +++ b/net/developer-guide/loading-documents/load-password-protected-document.md @@ -25,6 +25,10 @@ The following code snippet shows how to load and render an encrypted document: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + // Specify a password. LoadOptions loadOptions = new LoadOptions(); loadOptions.Password = "123456"; @@ -36,5 +40,25 @@ using (Viewer viewer = new Viewer("encrypted.docx", loadOptions)) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + ' Specify a password. + Dim loadOptions As LoadOptions = New LoadOptions() + loadOptions.Password = "123456" + ' Render a file. + Using viewer As Viewer = New Viewer("encrypted.docx", loadOptions) + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/loading-documents/loading-documents-from-different-sources/load-document-from-local-disk.md b/net/developer-guide/loading-documents/loading-documents-from-different-sources/load-document-from-local-disk.md index 0d52a4f..276d78c 100644 --- a/net/developer-guide/loading-documents/loading-documents-from-different-sources/load-document-from-local-disk.md +++ b/net/developer-guide/loading-documents/loading-documents-from-different-sources/load-document-from-local-disk.md @@ -14,14 +14,39 @@ The following code snippet shows how to load a document using the local path str {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + // Specify a path to a file. string filePath = "sample.docx"; + // Render the file. -using (Viewer viewer = new Viewer(filePath)) +using (Viewer viewer = new Viewer(filePath)) { HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); viewer.View(viewOptions); -} +} +``` +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + ' Specify a path to a file. + Dim filePath As String = "sample.docx" + + ' Render the file. + Using viewer As Viewer = New Viewer(filePath) + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewer.View(viewOptions) + End Using + End Sub +End Module ``` {{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/_index.md b/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/_index.md index 8d82e20..477e86c 100644 --- a/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/_index.md +++ b/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/_index.md @@ -19,8 +19,12 @@ The following code snippet shows how to load a document from a stream: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp -// Implement a method that returns a stream with document data. -Stream stream = GetStream("sample.docx"); +using System.IO; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + +Stream stream = GetStream("sample.docx"); // TODO: implement this method // Render a document from the stream. using (Viewer viewer = new Viewer(stream)) @@ -30,6 +34,26 @@ using (Viewer viewer = new Viewer(stream)) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System.IO +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Dim stream As Stream = GetStream("sample.docx") ' TODO: implement this method + + ' Render a document from the stream. + Using viewer As Viewer = New Viewer(stream) + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} Please refer to the following pages for examples: \ No newline at end of file diff --git a/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-amazon-s3-storage.md b/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-amazon-s3-storage.md index 23ed493..a913dc4 100644 --- a/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-amazon-s3-storage.md +++ b/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-amazon-s3-storage.md @@ -7,21 +7,35 @@ description: "This article explains how to load a document from Amazon S3 Storag productName: GroupDocs.Viewer for .NET hideChildren: False --- -The following code snippet shows how to load a document from Amazon S3 Storage: +The following code snippet shows how to load a document from Amazon S3 Storage. + +{{< alert style="info" >}} + +Runnig this code requires installing [AWSSDK.S3](https://nuget.org/packages/AWSSDK.S3) NuGet package. + +{{< /alert >}} {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System.IO; +using System.Threading.Tasks; +using Amazon.S3; +using Amazon.S3.Model; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + string key = "sample.docx"; -Stream stream = DownloadFile(key); +Stream stream = await DownloadFileAsync(key); using (Viewer viewer = new Viewer(stream)) { - HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); + HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); viewer.View(viewOptions); } -static Stream DownloadFile(string key) +static async Task DownloadFileAsync(string key) { AmazonS3Client client = new AmazonS3Client(); string bucketName = "my-bucket"; @@ -30,7 +44,8 @@ static Stream DownloadFile(string key) Key = key, BucketName = bucketName }; - using (GetObjectResponse response = client.GetObject(request)) + + using (GetObjectResponse response = await client.GetObjectAsync(request)) { MemoryStream stream = new MemoryStream(); response.ResponseStream.CopyTo(stream); @@ -38,6 +53,46 @@ static Stream DownloadFile(string key) return stream; } } +``` +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System.IO +Imports System.Threading.Tasks +Imports Amazon.S3 +Imports Amazon.S3.Model +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Dim key As String = "sample.docx" + Dim stream As Stream = DownloadFileAsync(key).GetAwaiter().GetResult() + + Using viewer As New Viewer(stream) + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewer.View(viewOptions) + End Using + End Sub + + Private Async Function DownloadFileAsync(ByVal key As String) As Task(Of Stream) + Dim client As New AmazonS3Client() + Dim bucketName As String = "my-bucket" + Dim request As New GetObjectRequest With { + .Key = key, + .BucketName = bucketName + } + + Using response As GetObjectResponse = Await client.GetObjectAsync(request) + Dim stream As New MemoryStream() + response.ResponseStream.CopyTo(stream) + stream.Position = 0 + Return stream + End Using + End Function +End Module + ``` {{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-azure-blob-storage.md b/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-azure-blob-storage.md index 9ad08db..0181704 100644 --- a/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-azure-blob-storage.md +++ b/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-azure-blob-storage.md @@ -7,21 +7,35 @@ description: "This article explains how to load a document from Azure Blob Stora productName: GroupDocs.Viewer for .NET hideChildren: False --- -The following code snippet shows how to load a document from Azure Blob Storage: + +The following code snippet shows how to load a document from Azure Blob Storage. + +{{< alert style="info" >}} + +Runnig this code requires installing [Azure.Storage.Blobs](https://nuget.org/packages/Azure.Storage.Blobs) NuGet package. + +{{< /alert >}} {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System.IO; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer; +using Azure.Storage.Blobs; +// ... + string blobName = "sample.docx"; Stream stream = DownloadFile(blobName); +LoadOptions loadOptions = new LoadOptions(FileType.DOCX); -using (Viewer viewer = new Viewer()) +using (Viewer viewer = new Viewer(stream, loadOptions)) { HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); viewer.View(viewOptions); } -public static Stream DownloadFile(string blobName) +static Stream DownloadFile(string blobName) { BlobContainerClient containerClient = GetContainerClient(); @@ -33,7 +47,7 @@ public static Stream DownloadFile(string blobName) return memoryStream; } -private static BlobContainerClient GetContainerClient() +static BlobContainerClient GetContainerClient() { string accountName = "***"; string accountKey = "***"; @@ -47,6 +61,56 @@ private static BlobContainerClient GetContainerClient() return blobContainerClient; } +``` +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System.IO +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer +Imports Azure.Storage.Blobs +' ... + +Module Program + Sub Main(args As String()) + Dim blobName As String = "sample.docx" + Dim stream As Stream = DownloadFile(blobName) + Dim loadOptions As New LoadOptions(FileType.DOCX) + + Using viewer As New Viewer(stream, loadOptions) + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewer.View(viewOptions) + End Using + End Sub + + Private Function DownloadFile(ByVal blobName As String) As Stream + Dim containerClient As BlobContainerClient = GetContainerClient() + + ' Get a reference to a blob + Dim blobClient As BlobClient = containerClient.GetBlobClient(blobName) + Dim memoryStream As New MemoryStream() + blobClient.DownloadTo(memoryStream) + memoryStream.Position = 0 + Return memoryStream + End Function + + Private Function GetContainerClient() As BlobContainerClient + Dim accountName As String = "***" + Dim accountKey As String = "***" + Dim endpointSuffix As String = "core.windows.net" + Dim containerName As String = "***" + + Dim connectionString As String = + $"DefaultEndpointsProtocol=https;AccountName={accountName};AccountKey={accountKey};EndpointSuffix={ _ + endpointSuffix}" + + ' Create a BlobContainerClient object which will be used to create a container client + Dim blobContainerClient As New BlobContainerClient(connectionString, containerName) + + Return blobContainerClient + End Function +End Module + ``` {{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-ftp.md b/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-ftp.md index ce65cca..8a22c1c 100644 --- a/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-ftp.md +++ b/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-ftp.md @@ -12,13 +12,20 @@ The following code snippet shows how to load a document from FTP: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System; +using System.IO; +using System.Net; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + Stream stream = GetFileFromFtp("sample.docx"); using (Viewer viewer = new Viewer(stream)) { - HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); + HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); viewer.View(viewOptions); } - + static Stream GetFileFromFtp(string filePath) { Uri uri = new Uri(filePath); @@ -44,4 +51,47 @@ static Stream GetFileStream(WebResponse response) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports System.IO +Imports System.Net +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Dim stream As Stream = GetFileFromFtp("sample.docx") + Using viewer As New Viewer(stream) + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewer.View(viewOptions) + End Using + End Sub + + Private Function GetFileFromFtp(ByVal filePath As String) As Stream + Dim uri As New Uri(filePath) + Dim request As FtpWebRequest = CreateRequest(uri) + Using response As WebResponse = request.GetResponse() + Return GetFileStream(response) + End Using + End Function + + Private Function CreateRequest(ByVal uri As Uri) As FtpWebRequest + Dim request As FtpWebRequest = DirectCast(WebRequest.Create(uri), FtpWebRequest) + request.Method = WebRequestMethods.Ftp.DownloadFile + Return request + End Function + + Private Function GetFileStream(ByVal response As WebResponse) As Stream + Dim fileStream As New MemoryStream() + Using responseStream As Stream = response.GetResponseStream() + responseStream.CopyTo(fileStream) + End Using + fileStream.Position = 0 + Return fileStream + End Function +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-url.md b/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-url.md index 1ceca09..10e2e3a 100644 --- a/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-url.md +++ b/net/developer-guide/loading-documents/loading-documents-from-different-sources/loading-documents-from-stream/load-document-from-url.md @@ -12,17 +12,22 @@ The following code snippet shows how to load a document from a URL: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System.IO; +using System.Net; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + string url = "https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET/blob/master/Examples/GroupDocs.Viewer.Examples.CSharp/Resources/SampleFiles/sample.docx?raw=true"; - + Stream stream = DownloadFile(url); -using (Viewer viewer = new Viewer(stream)) +using (Viewer viewer = new Viewer(stream, new LoadOptions(FileType.DOCX))) { - HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); + HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); viewer.View(viewOptions); } - static Stream DownloadFile(string url) { WebRequest request = WebRequest.Create(url); @@ -40,4 +45,43 @@ static Stream GetFileStream(WebResponse response) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System.IO +Imports System.Net +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + + Dim url As String = "https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET/blob/master/Examples/GroupDocs.Viewer.Examples.CSharp/Resources/SampleFiles/sample.docx?raw=true" + + Dim stream As Stream = DownloadFile(url) + + Using viewer As New Viewer(stream, new LoadOptions(FileType.DOCX)) + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewer.View(viewOptions) + End Using + End Sub + + Private Function DownloadFile(ByVal url As String) As Stream + Dim request As WebRequest = WebRequest.Create(url) + Using response As WebResponse = request.GetResponse() + Return GetFileStream(response) + End Using + End Function + + Private Function GetFileStream(ByVal response As WebResponse) As Stream + Dim fileStream As New MemoryStream() + Using responseStream As Stream = response.GetResponseStream() + responseStream.CopyTo(fileStream) + End Using + fileStream.Position = 0 + Return fileStream + End Function +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/loading-documents/loading-external-resources.md b/net/developer-guide/loading-documents/loading-external-resources.md index d773a34..3c806bf 100644 --- a/net/developer-guide/loading-documents/loading-external-resources.md +++ b/net/developer-guide/loading-documents/loading-external-resources.md @@ -25,6 +25,10 @@ The following code snippet shows how to deny loading of external resources: {{< tabs "example3">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + LoadOptions loadOptions = new LoadOptions(); loadOptions.SkipExternalResources = true; // Skip loading of external resources @@ -37,6 +41,26 @@ using (Viewer viewer = new Viewer("business-flyer.docx", loadOptions)) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Dim loadOptions As LoadOptions = New LoadOptions() + loadOptions.SkipExternalResources = True ' Skip loading of external resources + + Using viewer As Viewer = New Viewer("business-flyer.docx", loadOptions) + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following images show the output file with and without external resources (see top right corner): @@ -52,6 +76,10 @@ The following code snippet shows how to allow loading of external resources from {{< tabs "example2">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + LoadOptions loadOptions = new LoadOptions(); loadOptions.SkipExternalResources = true; // Skip loading of all external resources loadOptions.WhitelistedResources.Add("avatars.githubusercontent.com"); //Enable loading of external resources that has `avatars.githubusercontent.com` fragment in resource URL. @@ -65,6 +93,27 @@ using (Viewer viewer = new Viewer("business-flyer.docx", loadOptions)) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Dim loadOptions As LoadOptions = New LoadOptions() + loadOptions.SkipExternalResources = True ' Skip loading of all external resources + loadOptions.WhitelistedResources.Add("avatars.githubusercontent.com") 'Enable loading of external resources that has `avatars.githubusercontent.com` fragment in resource URL. + + Using viewer As Viewer = New Viewer("business-flyer.docx", loadOptions) + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Set timeout for loading of external resources @@ -76,6 +125,11 @@ The following code snippet shows how to set a timeout to load external resources {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + // Specify a timeout. LoadOptions loadOptions = new LoadOptions(); loadOptions.ResourceLoadingTimeout = TimeSpan.FromSeconds(5); @@ -87,4 +141,25 @@ using (Viewer viewer = new Viewer("sample.docx", loadOptions)) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + ' Specify a timeout. + Dim loadOptions As LoadOptions = New LoadOptions() + loadOptions.ResourceLoadingTimeout = TimeSpan.FromSeconds(5) + ' Render a file. + Using viewer As Viewer = New Viewer("sample.docx", loadOptions) + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/loading-documents/specify-encoding-when-loading-documents.md b/net/developer-guide/loading-documents/specify-encoding-when-loading-documents.md index e2f0715..2a54c13 100644 --- a/net/developer-guide/loading-documents/specify-encoding-when-loading-documents.md +++ b/net/developer-guide/loading-documents/specify-encoding-when-loading-documents.md @@ -22,6 +22,11 @@ The following code snippet shows how to specify the document encoding: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System.Text; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + // Specify an encoding. LoadOptions loadOptions = new LoadOptions(); loadOptions.Encoding = Encoding.GetEncoding("shift_jis"); @@ -33,4 +38,25 @@ using (Viewer viewer = new Viewer("sample.txt", loadOptions)) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System.Text +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + ' Specify an encoding. + Dim loadOptions As LoadOptions = New LoadOptions() + loadOptions.Encoding = Encoding.GetEncoding("shift_jis") + ' Render a file. + Using viewer As Viewer = New Viewer("sample.txt", loadOptions) + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/loading-documents/specify-file-type-when-loading-a-document.md b/net/developer-guide/loading-documents/specify-file-type-when-loading-a-document.md index 485f893..db1f120 100644 --- a/net/developer-guide/loading-documents/specify-file-type-when-loading-a-document.md +++ b/net/developer-guide/loading-documents/specify-file-type-when-loading-a-document.md @@ -18,18 +18,45 @@ The following code snippet shows how to specify the file type when loading a doc {{< tabs "example1">}} {{< tab "C#" >}} ```csharp -// Implement a method that returns a stream with document data. -Stream stream = GetFileStream("sample.docx"); +using System.IO; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + +Stream stream = GetFileStream("sample.docx"); //TODO: implement your method // Specify the file type. LoadOptions loadOptions = new LoadOptions(FileType.DOCX); //Render a file. -using (Viewer viewer = new Viewer(stream, loadOptions) +using (Viewer viewer = new Viewer(stream, loadOptions)) { HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System.IO +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Dim stream As Stream = GetFileStream("sample.docx") 'TODO: implement your method + + ' Specify the file type. + Dim loadOptions As LoadOptions = New LoadOptions(FileType.DOCX) + + 'Render a file. + Using viewer As Viewer = New Viewer(stream, loadOptions) + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/logging.md b/net/developer-guide/logging.md index 2e58c57..b321e12 100644 --- a/net/developer-guide/logging.md +++ b/net/developer-guide/logging.md @@ -27,6 +27,11 @@ The following code snippet shows how to log to a file using the [FileLogger](htt {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Logging; +using GroupDocs.Viewer.Options; +// ... + // Create logger and specify the output file. FileLogger fileLogger = new FileLogger("output.log"); @@ -41,6 +46,30 @@ using (Viewer viewer = new Viewer("sample.docx",viewerSettings)) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Logging +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + ' Create logger and specify the output file. + Dim fileLogger As FileLogger = New FileLogger("output.log") + + ' Create ViewerSettings and specify FileLogger. + Dim viewerSettings As ViewerSettings = New ViewerSettings(fileLogger) + + ' Render a document. + Using viewer As Viewer = New Viewer("sample.docx", viewerSettings) + Dim viewOptions As ViewOptions = HtmlViewOptions.ForEmbeddedResources("result.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows the output.log file: @@ -54,6 +83,11 @@ The following code snippet shows how to log to the console using the [ConsoleLog {{< tabs "example2">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Logging; +using GroupDocs.Viewer.Options; +// ... + // Create console logger. ConsoleLogger consoleLogger = new ConsoleLogger(); @@ -68,6 +102,30 @@ using (Viewer viewer = new Viewer("sample.docx", viewerSettings)) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Logging +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + ' Create console logger. + Dim consoleLogger As ConsoleLogger = New ConsoleLogger() + + ' Create ViewerSettings and specify FileLogger. + Dim viewerSettings As ViewerSettings = New ViewerSettings(consoleLogger) + + ' Render a document. + Using viewer As Viewer = New Viewer("sample.docx", viewerSettings) + Dim viewOptions As ViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: @@ -87,6 +145,13 @@ The following code snippet shows how to implement a simple file logger: {{< tabs "example3">}} {{< tab "C#" >}} ```csharp +using System; +using System.IO; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Logging; +using GroupDocs.Viewer.Options; +// ... + // Create logger and specify the output file. CustomLogger customLogger = new CustomLogger("output.log"); @@ -176,6 +241,105 @@ public class CustomLogger : ILogger } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports System.IO +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Logging +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + ' Create logger and specify the output file. + Dim customLogger As CustomLogger = New CustomLogger("output.log") + + ' Create ViewerSettings and specify CustomLogger. + Dim viewerSettings As ViewerSettings = New ViewerSettings(customLogger) + + ' Render a document. + Using viewer As Viewer = New Viewer("sample.docx", viewerSettings) + Dim viewOptions As ViewOptions = HtmlViewOptions.ForEmbeddedResources("result.html") + viewer.View(viewOptions) + End Using + End Sub + + ' + ' Writes log messages to a file. + ' + Public Class CustomLogger + Implements ILogger + + Private ReadOnly _fileName As String + + Private Sub New() + End Sub + + ''' + ''' Create logger to a file. + ''' + ''' Full file name with path + Public Sub New(fileName As String) + _fileName = fileName + End Sub + + ''' + ''' Writes warning message to the file; + ''' Warning log messages provide information about the unexpected and recoverable events in application flow. + ''' + ''' The warning message. + ''' Thrown when is null. + Public Sub ILogger_Warning(message As String) Implements ILogger.Warning + If message Is Nothing Then + Throw New ArgumentNullException(NameOf(message)) + End If + + Using wr As New StreamWriter(_fileName, True) + wr.WriteLine($"[WARN] {message}") + End Using + End Sub + + ''' + ''' Writes trace message to the file. + ''' Trace log messages provide generally useful information about application flow. + ''' + ''' The trace message. + ''' Thrown when is null. + Public Sub ILogger_Trace(message As String) Implements ILogger.Trace + If message Is Nothing Then + Throw New ArgumentNullException(NameOf(message)) + End If + + Using wr As New StreamWriter(_fileName, True) + wr.WriteLine($"[TRACE] {message}") + End Using + End Sub + + ''' + ''' Writes an error message to the file. + ''' Error log messages provide information about unrecoverable events in application flow. + ''' + ''' The error message. + ''' The exception. + ''' Thrown when is null. + ''' Thrown when is null. + Public Sub [Error](message As String, exception As Exception) Implements ILogger.[Error] + If message Is Nothing Then + Throw New ArgumentNullException(NameOf(message)) + End If + If exception Is Nothing Then + Throw New ArgumentNullException(NameOf(exception)) + End If + + Using wr As New StreamWriter(_fileName, True) + wr.WriteLine($"[ERROR] {message}, exception: {exception}") + End Using + End Sub + End Class +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows the output.log file: diff --git a/net/developer-guide/processing-attachments/how-to-convert-and-view-attachments.md b/net/developer-guide/processing-attachments/how-to-convert-and-view-attachments.md index 2043885..6e74b91 100644 --- a/net/developer-guide/processing-attachments/how-to-convert-and-view-attachments.md +++ b/net/developer-guide/processing-attachments/how-to-convert-and-view-attachments.md @@ -26,15 +26,24 @@ The following code snippet shows how to render attachments from the MSG file: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System.IO; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Results; +// ... + // Specify attachment. -Attachment attachment = new Attachment("attachment-word.doc", @"C:\Output\attachment-word.doc"); +Attachment attachment = new Attachment("attachment-word.doc", @"C:\Output\attachment-word.doc"); + // Create a stream for attachment. MemoryStream attachmentStream = new MemoryStream(); + //Save attachment using (Viewer viewer = new Viewer("sample.msg")) { - viewer.SaveAttachment(attachment, attachmentStream); + viewer.SaveAttachment(attachment, attachmentStream); } + // Render attachment using (Viewer viewer = new Viewer(attachmentStream)) { @@ -43,4 +52,34 @@ using (Viewer viewer = new Viewer(attachmentStream)) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System.IO +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + ' Specify attachment. + Dim attachment As Attachment = New Attachment("attachment-word.doc", "C:\Output\attachment-word.doc") + + ' Create a stream for attachment. + Dim attachmentStream As MemoryStream = New MemoryStream() + + 'Save attachment + Using viewer As Viewer = New Viewer("sample.msg") + viewer.SaveAttachment(attachment, attachmentStream) + End Using + + ' Render attachment + Using viewer As Viewer = New Viewer(attachmentStream) + Dim options As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewer.View(options) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/processing-attachments/how-to-extract-and-save-attachments.md b/net/developer-guide/processing-attachments/how-to-extract-and-save-attachments.md index ae734a4..a1a9df8 100644 --- a/net/developer-guide/processing-attachments/how-to-extract-and-save-attachments.md +++ b/net/developer-guide/processing-attachments/how-to-extract-and-save-attachments.md @@ -21,17 +21,46 @@ The following code snippet shows how to get and save all attachments from the MS {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System.IO; +using System.Collections.Generic; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Results; +// ... + using (Viewer viewer = new Viewer("with_attachments.msg")) { // Get list of attachments. IList attachments = viewer.GetAttachments(); // Save each attachments. - foreach(Attachment attachment in attachments) + foreach (Attachment attachment in attachments) { - string filePath = Path.Combine(@"C:\output", attachment.FileName); - viewer.SaveAttachment(attachment, File.OpenWrite(filePath)); + string filePath = Path.Combine("output", attachment.FileName); + viewer.SaveAttachment(attachment, File.OpenWrite(filePath)); } -} +} +``` +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System.IO +Imports System.Collections.Generic +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("with_attachments.msg") + ' Get list of attachments. + Dim attachments As IList(Of Attachment) = viewer.GetAttachments() + ' Save each attachments. + For Each attachment As Attachment In attachments + Dim filePath As String = Path.Combine("output", attachment.FileName) + viewer.SaveAttachment(attachment, File.OpenWrite(filePath)) + Next + End Using + End Sub +End Module ``` {{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/processing-attachments/how-to-list-attachments.md b/net/developer-guide/processing-attachments/how-to-list-attachments.md index 0affa99..630c334 100644 --- a/net/developer-guide/processing-attachments/how-to-list-attachments.md +++ b/net/developer-guide/processing-attachments/how-to-list-attachments.md @@ -22,17 +22,48 @@ The following code snippet shows how to get a list of attachments from the MSG f {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System; +using System.Collections.Generic; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Results; +// ... + using (Viewer viewer = new Viewer("sample.msg")) { // Get list of attachments. IList attachments = viewer.GetAttachments(); + // Display list of attachments. Console.WriteLine("\nAttachments:"); - foreach(Attachment attachment in attachments) + foreach (Attachment attachment in attachments) Console.WriteLine(attachment); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports System.Collections.Generic +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.msg") + ' Get list of attachments. + Dim attachments As IList(Of Attachment) = viewer.GetAttachments() + + ' Display list of attachments. + Console.WriteLine(Global.Microsoft.VisualBasic.Constants.vbLf & "Attachments:") + For Each attachment As Attachment In attachments + Console.WriteLine(attachment) + Next + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: diff --git a/net/developer-guide/rendering-documents/add-text-watermark.md b/net/developer-guide/rendering-documents/add-text-watermark.md index a38fb74..8952ffe 100644 --- a/net/developer-guide/rendering-documents/add-text-watermark.md +++ b/net/developer-guide/rendering-documents/add-text-watermark.md @@ -20,14 +20,37 @@ The following code snippet shows how to apply the watermark to the output pages. {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { // Create an HTML file. HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); // Add watermark - viewOptions.Watermark = new Watermark("This is a watermark"); + viewOptions.Watermark = new Watermark("This is a watermark"); viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create an HTML file. + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources () + ' Add watermark + viewOptions.Watermark = New Watermark("This is a watermark") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} \ No newline at end of file diff --git a/net/developer-guide/rendering-documents/cancel-rendering.md b/net/developer-guide/rendering-documents/cancel-rendering.md index 8e15382..1e4a124 100644 --- a/net/developer-guide/rendering-documents/cancel-rendering.md +++ b/net/developer-guide/rendering-documents/cancel-rendering.md @@ -30,15 +30,21 @@ The following code snippet shows how to cancel a task: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System.Diagnostics; +using System.Threading.Tasks; +using System.Threading; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + // Create cancellation token source. CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); -// Create (get) cancellation token object. CancellationToken cancellationToken = cancellationTokenSource.Token; // Create task and pass token Task runTask = Task.Run(() => { - using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DOCX, new ViewerSettings(new GroupDocs.Viewer.Logging.ConsoleLogger()))) + using (Viewer viewer = new Viewer("sample.docx")) { HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(); options.RenderComments = true; @@ -55,7 +61,43 @@ cancellationTokenSource.CancelAfter(1000); // Wait for the task to cancel. Thread.Sleep(2000); -// runTask.IsCanceled == true +Debug.Assert(runTask.IsCanceled); +``` +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System.Threading +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + ' Create cancellation token source. + Dim cancellationTokenSource As CancellationTokenSource = New CancellationTokenSource() + Dim cancellationToken As CancellationToken = cancellationTokenSource.Token + + ' Create task and pass token + Dim runTask As Task = Task.Run(Sub() + Using viewer As Viewer = New Viewer("sample.docx") + Dim options As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + options.RenderComments = True + viewer.View(options, cancellationToken) + End Using + End Sub, cancellationToken) + + ' Cancel task after 1000 ms. + cancellationTokenSource.CancelAfter(1000) + + ' Also you can call Cancel method at any time + 'cancellationTokenSource.Cancel(); + + ' Wait for the task to cancel. + Thread.Sleep(2000) + + Debug.Assert(runTask.IsCanceled) + End Sub +End Module ``` {{< /tab >}} {{< /tabs >}} @@ -73,5 +115,5 @@ The following methods of the [Viewer](https://reference.groupdocs.com/viewer/net * [View](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.viewer/view/methods/2) with ViewOptions * [View](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.viewer/view/methods/3) with ViewOptions and page numbers array -You can also view the [example](https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET/blob/master/Examples/GroupDocs.Viewer.Examples.CSharp/AdvancedUsage/Rendering/CommonRenderingOptions/CancelRenderWithCancellationToken.cs) in our public GitHub repository . +You can also view the [example](https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET/blob/master/Examples/GroupDocs.Viewer.Examples.CSharp/AdvancedUsage/Rendering/CommonRenderingOptions/CancelRenderWithCancellationToken.cs) in our public GitHub repository. diff --git a/net/developer-guide/rendering-documents/flip-or-rotate-pages.md b/net/developer-guide/rendering-documents/flip-or-rotate-pages.md index 86e5cf3..423a253 100644 --- a/net/developer-guide/rendering-documents/flip-or-rotate-pages.md +++ b/net/developer-guide/rendering-documents/flip-or-rotate-pages.md @@ -26,6 +26,10 @@ The following code snippet shows how to rotate output pages when rendering a doc {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { // Create a PDF file. @@ -36,6 +40,25 @@ using (Viewer viewer = new Viewer("sample.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create a PDF file. + Dim viewOptions As PdfViewOptions = New PdfViewOptions() + ' Rotate the first page. + viewOptions.RotatePage(1, Rotation.On90Degree) + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} You can also view the [example](https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET/blob/master/Examples/GroupDocs.Viewer.Examples.CSharp/AdvancedUsage/Rendering/CommonRenderingOptions/FlipRotatePages.cs) in our public GitHub repository . \ No newline at end of file diff --git a/net/developer-guide/rendering-documents/rendering-to-html/_index.md b/net/developer-guide/rendering-documents/rendering-to-html/_index.md index fcdecde..ab47ec5 100644 --- a/net/developer-guide/rendering-documents/rendering-to-html/_index.md +++ b/net/developer-guide/rendering-documents/rendering-to-html/_index.md @@ -29,14 +29,35 @@ The following code snippet shows how to render a .docx document to HTML with ext {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { - // Create an HTML file. + // Create view options. var viewOptions = HtmlViewOptions.ForExternalResources(); viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create view options. + Dim viewOptions = HtmlViewOptions.ForExternalResources() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Rendering to HTML with embedded resources @@ -46,14 +67,35 @@ The following code snippet shows how to render a .docx document to HTML with emb {{< tabs "example2">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { - // Create an HTML file. + // Create view options. var viewOptions = HtmlViewOptions.ForEmbeddedResources(); viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create view options. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} For details, please refer to the following pages: diff --git a/net/developer-guide/rendering-documents/rendering-to-html/exclude-fonts.md b/net/developer-guide/rendering-documents/rendering-to-html/exclude-fonts.md index 874e1ab..2e1df85 100644 --- a/net/developer-guide/rendering-documents/rendering-to-html/exclude-fonts.md +++ b/net/developer-guide/rendering-documents/rendering-to-html/exclude-fonts.md @@ -21,6 +21,10 @@ The following code snippet shows how to prevent adding the **Times New Roman** f {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { // Create an HTML file. @@ -31,6 +35,25 @@ using (Viewer viewer = new Viewer("sample.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create an HTML file. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources() + ' Exclude the Times New Roman font. + viewOptions.FontsToExclude.Add("Times New Roman") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## List of format families that support adding fonts to HTML diff --git a/net/developer-guide/rendering-documents/rendering-to-html/minify-html.md b/net/developer-guide/rendering-documents/rendering-to-html/minify-html.md index 7a2eab2..8aef639 100644 --- a/net/developer-guide/rendering-documents/rendering-to-html/minify-html.md +++ b/net/developer-guide/rendering-documents/rendering-to-html/minify-html.md @@ -52,15 +52,40 @@ The following code snippet shows how to enable minification: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { - // Create an HTML file. + // Create view options. var viewOptions = HtmlViewOptions.ForEmbeddedResources(); + // Render the minified file. viewOptions.Minify = true; viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create view options. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources() + + ' Render the minified file. + viewOptions.Minify = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/rendering-documents/rendering-to-html/optimize-html-for-printing.md b/net/developer-guide/rendering-documents/rendering-to-html/optimize-html-for-printing.md index 75bdc29..488deed 100644 --- a/net/developer-guide/rendering-documents/rendering-to-html/optimize-html-for-printing.md +++ b/net/developer-guide/rendering-documents/rendering-to-html/optimize-html-for-printing.md @@ -24,14 +24,39 @@ The following code snippet shows how to render a .docx document to HTML optimize {{< tabs "example1">}} {{< tab "C#" >}} ```csharp - using (Viewer viewer = new Viewer("sample.docx")) +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + +using (Viewer viewer = new Viewer("sample.docx")) { - // Create an HTML file. + // Create view options. var viewOptions = HtmlViewOptions.ForEmbeddedResources(); + // Render a file optimized for printing. viewOptions.ForPrinting = true; viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create view options. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources() + + ' Render a file optimized for printing. + viewOptions.ForPrinting = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/rendering-documents/rendering-to-html/render-with-responsive-layout.md b/net/developer-guide/rendering-documents/rendering-to-html/render-with-responsive-layout.md index 8b6c84c..e278db1 100644 --- a/net/developer-guide/rendering-documents/rendering-to-html/render-with-responsive-layout.md +++ b/net/developer-guide/rendering-documents/rendering-to-html/render-with-responsive-layout.md @@ -15,14 +15,39 @@ The following code snippet shows how to render a .docx document to HTML with res {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { - // Create an HTML file. + // Create view options. var viewOptions = HtmlViewOptions.ForEmbeddedResources(); + // Render the file with responsive layout. viewOptions.RenderResponsive = true; viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create view options. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources() + + ' Render the file with responsive layout. + viewOptions.RenderResponsive = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} \ No newline at end of file diff --git a/net/developer-guide/rendering-documents/rendering-to-html/set-image-size-limits-when-rendering-to-html.md b/net/developer-guide/rendering-documents/rendering-to-html/set-image-size-limits-when-rendering-to-html.md index 26bb957..bed1a52 100644 --- a/net/developer-guide/rendering-documents/rendering-to-html/set-image-size-limits-when-rendering-to-html.md +++ b/net/developer-guide/rendering-documents/rendering-to-html/set-image-size-limits-when-rendering-to-html.md @@ -34,6 +34,31 @@ public int ImageWidth { get; set; } public int ImageHeight { get; set; } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Class SurroundingClass + ''' + ''' Max width of an output image in pixels. + ''' + Public Property ImageMaxWidth As Integer + + ''' + ''' Max height of an output image in pixels. + ''' + Public Property ImageMaxHeight As Integer + + ''' + ''' The width of the output image in pixels. + ''' + Public Property ImageWidth As Integer + + ''' + ''' The height of an output image in pixels. + ''' + Public Property ImageHeight As Integer +End Class +``` +{{< /tab >}} {{< /tabs >}} You can set the width and/or height of the output images. Use one of the following methods: @@ -57,9 +82,13 @@ The following code snippet shows how to set the output image size limits: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp -using (Viewer viewer = new Viewer("sample.jpg")) +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + +using (Viewer viewer = new Viewer("sample.jpeg")) { - // Create an HTML file. + // Create view options. var viewOptions = HtmlViewOptions.ForEmbeddedResources(); // Specify the maximum width and height. viewOptions.ImageMaxWidth = 800; @@ -68,4 +97,24 @@ using (Viewer viewer = new Viewer("sample.jpg")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.jpeg") + ' Create view options. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources() + ' Specify the maximum width and height. + viewOptions.ImageMaxWidth = 800 + viewOptions.ImageMaxHeight = 600 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/_index.md b/net/developer-guide/rendering-documents/rendering-to-pdf/_index.md index 33ac663..c3363a8 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/_index.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/_index.md @@ -21,6 +21,10 @@ The following code snippet shows how to render a .docx document to PDF: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { // Create a PDF file. @@ -29,6 +33,23 @@ using (Viewer viewer = new Viewer("sample.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create a PDF file. + Dim viewOptions As PdfViewOptions = New PdfViewOptions() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} For details, please refer to the following pages: diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/adjust-jpeg-images-quality.md b/net/developer-guide/rendering-documents/rendering-to-pdf/adjust-jpeg-images-quality.md index 6ef3693..c70a29e 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/adjust-jpeg-images-quality.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/adjust-jpeg-images-quality.md @@ -23,14 +23,41 @@ The following code snippet shows how to adjust JPG image quality in the output P {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { - // Create a PDF file. + // Create view options. PdfViewOptions viewOptions = new PdfViewOptions(); + // Specify the JPG image quality. - viewOptions.JpgQuality = 50; + viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions(); + viewOptions.PdfOptimizationOptions.ImageQuality = 50; viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create view options. + Dim viewOptions As PdfViewOptions = New PdfViewOptions() + + ' Specify the JPG image quality. + viewOptions.PdfOptimizationOptions = New PdfOptimizationOptions() + viewOptions.PdfOptimizationOptions.ImageQuality = 50 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-for-web.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-for-web.md index ee2a6f1..8db8534 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-for-web.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-for-web.md @@ -18,21 +18,38 @@ The following code snippet shows how to optimize a PDF file for browser: ```csharp using GroupDocs.Viewer; using GroupDocs.Viewer.Options; -using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization; // ... using (var viewer = new Viewer("sample.docx")) { PdfViewOptions viewOptions = new PdfViewOptions(); - viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions() + viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions { Lineriaze = true }; - + viewer.View(viewOptions); } ``` -{{}} -{{}} +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.docx") + Dim viewOptions As PdfViewOptions = New PdfViewOptions() + viewOptions.PdfOptimizationOptions = New PdfOptimizationOptions With { + .Lineriaze = True + } + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} +{{< /tabs >}} diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-resources.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-resources.md index 613e821..cb08a7c 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-resources.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-resources.md @@ -19,7 +19,6 @@ The following code snippet shows how to optimize the PDF file by default: ```csharp using GroupDocs.Viewer; using GroupDocs.Viewer.Options; -using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization; // ... using (var viewer = new Viewer("sample.docx")) @@ -30,7 +29,23 @@ using (var viewer = new Viewer("sample.docx")) viewer.View(viewOptions); } ``` -{{}} -{{}} +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.docx") + Dim viewOptions As PdfViewOptions = New PdfViewOptions() + viewOptions.PdfOptimizationOptions = New PdfOptimizationOptions() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} +{{< /tabs >}} diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-spreadsheets.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-spreadsheets.md index e8bbaf3..6129cff 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-spreadsheets.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-spreadsheets.md @@ -22,7 +22,6 @@ The following code snippet shows how to optimize spreadsheets in a PDF file: ```csharp using GroupDocs.Viewer; using GroupDocs.Viewer.Options; -using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization; // ... using (var viewer = new Viewer("invoice.xlsx")) @@ -36,7 +35,25 @@ using (var viewer = new Viewer("invoice.xlsx")) viewer.View(viewOptions); } ``` -{{}} -{{}} - - +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("invoice.xlsx") + Dim viewOptions As PdfViewOptions = New PdfViewOptions() + viewOptions.PdfOptimizationOptions = New PdfOptimizationOptions With { + .OptimizeSpreadsheets = True + } + + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} +{{< /tabs >}} diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-annotations.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-annotations.md index 26ac4da..3dea2fa 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-annotations.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-annotations.md @@ -21,22 +21,38 @@ The following code snippet shows how to remove annotations from the file: ```csharp using GroupDocs.Viewer; using GroupDocs.Viewer.Options; -using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization; // ... using (var viewer = new Viewer("sample.docx")) { PdfViewOptions viewOptions = new PdfViewOptions(); - viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions() - { - RemoveAnnotations = true - }; - + viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions(); + viewOptions.PdfOptimizationOptions.RemoveAnnotations = true; + viewer.View(viewOptions); } ``` -{{}} -{{}} +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.docx") + Dim viewOptions As PdfViewOptions = New PdfViewOptions() + viewOptions.PdfOptimizationOptions = New PdfOptimizationOptions() + viewOptions.PdfOptimizationOptions.RemoveAnnotations = True + + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} +{{< /tabs >}} The following image demonstrates the result: diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-fields.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-fields.md index 2d35b33..ce65eb1 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-fields.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-fields.md @@ -21,13 +21,12 @@ The following code snippet shows how to flatten form fields in the file: ```csharp using GroupDocs.Viewer; using GroupDocs.Viewer.Options; -using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization; // ... using (var viewer = new Viewer("sample.docx")) { PdfViewOptions viewOptions = new PdfViewOptions(); - viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions() + viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions { RemoveFormFields = true }; @@ -35,8 +34,28 @@ using (var viewer = new Viewer("sample.docx")) viewer.View(viewOptions); } ``` -{{}} -{{}} +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.docx") + Dim viewOptions As PdfViewOptions = New PdfViewOptions() + viewOptions.PdfOptimizationOptions = New PdfOptimizationOptions With { + .RemoveFormFields = True + } + + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} +{{< /tabs >}} The following image demonstrates the result: diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-fonts/optimization-pdf-subset-fonts.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-fonts/optimization-pdf-subset-fonts.md index 5945c66..b84bae7 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-fonts/optimization-pdf-subset-fonts.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-fonts/optimization-pdf-subset-fonts.md @@ -10,10 +10,7 @@ productName: GroupDocs.Viewer for .NET hideChildren: False toc: True --- -Optimization resources. SubsetFonts optimization option -Fonts will be converted into subsets if set to true - -If the file uses embedded fonts, it contains all font data. GroupDocs.Viewer can subset embedded fonts to reduce the file size. +Not optimized files may contain embedded fonts. GroupDocs.Viewer can remove unused instructions in embedded fonts to reduce the file size. To subset fonts in a PDF file, set the [SubsetFonts](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/pdfoptimizationoptions/subsetfonts) property to `true`. @@ -24,13 +21,12 @@ The following code snippet shows how to subset fonts in a PDF file: ```csharp using GroupDocs.Viewer; using GroupDocs.Viewer.Options; -using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization; // ... using (var viewer = new Viewer("sample.docx")) { PdfViewOptions viewOptions = new PdfViewOptions(); - viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions() + viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions { SubsetFonts = true }; @@ -38,8 +34,28 @@ using (var viewer = new Viewer("sample.docx")) viewer.View(viewOptions); } ``` -{{}} -{{}} +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.docx") + Dim viewOptions As PdfViewOptions = New PdfViewOptions() + viewOptions.PdfOptimizationOptions = New PdfOptimizationOptions With { + .SubsetFonts = True + } + + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} +{{< /tabs >}} The following image demonstrates the result. There is no difference in appearance: diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-images/optimization-pdf-convert-grayscale.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-images/optimization-pdf-convert-grayscale.md index 255cf1b..ac204e6 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-images/optimization-pdf-convert-grayscale.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-images/optimization-pdf-convert-grayscale.md @@ -21,13 +21,12 @@ The following code snippet shows how to convert a PDF file to grayscale: ```csharp using GroupDocs.Viewer; using GroupDocs.Viewer.Options; -using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization; // ... using (var viewer = new Viewer("sample.docx")) { PdfViewOptions viewOptions = new PdfViewOptions(); - viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions() + viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions { ConvertToGrayScale = true }; @@ -35,8 +34,28 @@ using (var viewer = new Viewer("sample.docx")) viewer.View(viewOptions); } ``` -{{}} -{{}} +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.docx") + Dim viewOptions As PdfViewOptions = New PdfViewOptions() + viewOptions.PdfOptimizationOptions = New PdfOptimizationOptions With { + .ConvertToGrayScale = True + } + + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} +{{< /tabs >}} The following image demonstrates the result: diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-images/optimization-pdf-reduce-image-quality.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-images/optimization-pdf-reduce-image-quality.md index 7dc1465..675f8b1 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-images/optimization-pdf-reduce-image-quality.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-images/optimization-pdf-reduce-image-quality.md @@ -24,13 +24,12 @@ The following code snippet shows how to compress images in the file: ```csharp using GroupDocs.Viewer; using GroupDocs.Viewer.Options; -using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization; // ... using (var viewer = new Viewer("sample.docx")) { PdfViewOptions viewOptions = new PdfViewOptions(); - viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions() + viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions { CompressImages = true, ImageQuality = 50 @@ -39,8 +38,29 @@ using (var viewer = new Viewer("sample.docx")) viewer.View(viewOptions); } ``` -{{}} -{{}} +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.docx") + Dim viewOptions As PdfViewOptions = New PdfViewOptions() + viewOptions.PdfOptimizationOptions = New PdfOptimizationOptions With { + .CompressImages = True, + .ImageQuality = 50 + } + + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} +{{< /tabs >}} The following image demonstrates the result: diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-images/optimization-pdf-set-max-resolution.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-images/optimization-pdf-set-max-resolution.md index d803965..e33f841 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-images/optimization-pdf-set-max-resolution.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-images/optimization-pdf-set-max-resolution.md @@ -21,13 +21,12 @@ The following code snippet shows how to reduce image resolution in the file: ```csharp using GroupDocs.Viewer; using GroupDocs.Viewer.Options; -using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization; // ... using (var viewer = new Viewer("sample.docx")) { PdfViewOptions viewOptions = new PdfViewOptions(); - viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions() + viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions { CompressImages = true, ImageQuality = 50, @@ -38,8 +37,31 @@ using (var viewer = new Viewer("sample.docx")) viewer.View(viewOptions); } ``` -{{}} -{{}} +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.docx") + Dim viewOptions As PdfViewOptions = New PdfViewOptions() + viewOptions.PdfOptimizationOptions = New PdfOptimizationOptions With { + .CompressImages = True, + .ImageQuality = 50, + .ResizeImages = True, + .MaxResolution = 100 + } + + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} +{{< /tabs >}} The following image demonstrates the result: diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/protect-pdf-document.md b/net/developer-guide/rendering-documents/rendering-to-pdf/protect-pdf-document.md index 82b2c55..46569f5 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/protect-pdf-document.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/protect-pdf-document.md @@ -29,19 +29,51 @@ The following code snippet shows how to protect the output PDF document: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp -using (Viewer viewer = new Viewer("sample.docx")) +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer; +// ... + +using(Viewer viewer = new Viewer("sample.docx")) { // Specify the security settings. Security security = new Security(); security.DocumentOpenPassword = "o123"; security.PermissionsPassword = "p123"; security.Permissions = Permissions.AllowAll ^ Permissions.DenyPrinting; + // Create a PDF file. PdfViewOptions viewOptions = new PdfViewOptions(); + // Apply the security settings - viewOptions.Security = security; + viewOptions.Security = security; viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Specify the security settings. + Dim security As Security = New Security() + security.DocumentOpenPassword = "o123" + security.PermissionsPassword = "p123" + security.Permissions = Permissions.AllowAll Xor Permissions.DenyPrinting + + ' Create a PDF file. + Dim viewOptions As PdfViewOptions = New PdfViewOptions() + + ' Apply the security settings + viewOptions.Security = security + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} \ No newline at end of file diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/reorder-pages.md b/net/developer-guide/rendering-documents/rendering-to-pdf/reorder-pages.md index b8c41ec..0d807b5 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/reorder-pages.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/reorder-pages.md @@ -20,13 +20,37 @@ The following code snippet shows how to reorder pages: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { - // Create a PDF file. - PdfViewOptions viewOptions = new PdfViewOptions(); + // Create view options. + PdfViewOptions viewOptions = new PdfViewOptions(); + // Pass page numbers in the order you want to render them. viewer.View(viewOptions, 2, 1); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create view options. + Dim viewOptions As PdfViewOptions = New PdfViewOptions() + + ' Pass page numbers in the order you want to render them. + viewer.View(viewOptions, 2, 1) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/set-image-size-limits-when-rendering-to-pdf.md b/net/developer-guide/rendering-documents/rendering-to-pdf/set-image-size-limits-when-rendering-to-pdf.md index 054034a..71462c2 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/set-image-size-limits-when-rendering-to-pdf.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/set-image-size-limits-when-rendering-to-pdf.md @@ -33,6 +33,31 @@ public int ImageWidth { get; set; } public int ImageHeight { get; set; } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Class SurroundingClass + ''' + ''' Max width of an output image in pixels. + ''' + Public Property ImageMaxWidth As Integer + + ''' + ''' Max height of an output image in pixels. + ''' + Public Property ImageMaxHeight As Integer + + ''' + ''' The width of the output image in pixels. + ''' + Public Property ImageWidth As Integer + + ''' + ''' The height of an output image in pixels. + ''' + Public Property ImageHeight As Integer +End Class +``` +{{< /tab >}} {{< /tabs >}} You can set the width and/or height of the output images. Use one of the following methods: @@ -56,15 +81,41 @@ The following code snippet shows how to set the output image size limits: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer; +// ... + using (Viewer viewer = new Viewer("sample.jpg")) { - // Create a PDF file. - PdfViewOptions viewOptions = new PdfViewOptions(); - // Specify the maximum width and height. - viewOptions.ImageMaxWidth = 800; - viewOptions.ImageMaxHeight = 600; - viewer.View(viewOptions); + // Create a PDF file. + PdfViewOptions viewOptions = new PdfViewOptions(); + + // Specify the maximum width and height. + viewOptions.ImageMaxWidth = 800; + viewOptions.ImageMaxHeight = 600; + viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.jpg") + ' Create a PDF file. + Dim viewOptions As PdfViewOptions = New PdfViewOptions() + + ' Specify the maximum width and height. + viewOptions.ImageMaxWidth = 800 + viewOptions.ImageMaxHeight = 600 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} \ No newline at end of file diff --git a/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/_index.md b/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/_index.md index d80c0b5..037b52a 100644 --- a/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/_index.md +++ b/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/_index.md @@ -23,6 +23,10 @@ The following code snippet shows how to render a .docx document to PNG image: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { // Create a PNG file. @@ -31,6 +35,23 @@ using (Viewer viewer = new Viewer("sample.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create a PNG file. + Dim viewOptions As PngViewOptions = New PngViewOptions() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Rendering to JPEG @@ -40,6 +61,10 @@ The following code snippet shows how to render a .docx document to JPG image: {{< tabs "example2">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { // Create a JPG file. @@ -48,6 +73,23 @@ using (Viewer viewer = new Viewer("sample.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create a JPG file. + Dim viewOptions As JpgViewOptions = New JpgViewOptions() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} For details, please refer to the following pages: \ No newline at end of file diff --git a/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/image-viewer-adjust-image-size.md b/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/image-viewer-adjust-image-size.md index a1c5711..1fb07fe 100644 --- a/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/image-viewer-adjust-image-size.md +++ b/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/image-viewer-adjust-image-size.md @@ -18,10 +18,15 @@ The following code snippet shows how to set the image width or height. {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { // Create a JPG file. JpgViewOptions viewOptions = new JpgViewOptions(); + // Specify the width and height. viewOptions.Width = 600; viewOptions.Height = 800; @@ -30,4 +35,26 @@ using (Viewer viewer = new Viewer("sample.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create a JPG file. + Dim viewOptions As JpgViewOptions = New JpgViewOptions() + + ' Specify the width and height. + viewOptions.Width = 600 + viewOptions.Height = 800 + + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/image-viewer-adjust-quality-for-jpg.md b/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/image-viewer-adjust-quality-for-jpg.md index 8e944ee..e3faa3a 100644 --- a/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/image-viewer-adjust-quality-for-jpg.md +++ b/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/image-viewer-adjust-quality-for-jpg.md @@ -23,14 +23,39 @@ The following code snippet shows how to adjust quality of the output JPG image: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { // Create a JPG file. JpgViewOptions viewOptions = new JpgViewOptions(); + // Specify the JPG image quality. viewOptions.Quality = 50; viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create a JPG file. + Dim viewOptions As JpgViewOptions = New JpgViewOptions() + + ' Specify the JPG image quality. + viewOptions.Quality = 50 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} \ No newline at end of file diff --git a/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/image-viewer-get-text-coordinates.md b/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/image-viewer-get-text-coordinates.md index d50c63d..a520637 100644 --- a/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/image-viewer-get-text-coordinates.md +++ b/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/image-viewer-get-text-coordinates.md @@ -14,18 +14,25 @@ The following code snippet shows how to retrieve and print out text ([lines](htt {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Results; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { // Get the file information and extract it text. bool extractText = true; ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForPngView(extractText); ViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions); + // Display the file information and text. - foreach(Page page in viewInfo.Pages) + 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); @@ -42,6 +49,42 @@ using (Viewer viewer = new Viewer("sample.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Get the file information and extract it text. + Dim extractText As Boolean = True + Dim viewInfoOptions As ViewInfoOptions = ViewInfoOptions.ForPngView(extractText) + Dim viewInfo As ViewInfo = viewer.GetViewInfo(viewInfoOptions) + + ' Display the file information and text. + For Each page As Page In viewInfo.Pages + Console.WriteLine($"Page: {page.Number}") + Console.WriteLine("Text lines/words/characters:") + + For Each line As Line In page.Lines + Console.WriteLine(line) + For Each word As Word In line.Words + Console.WriteLine($" {word}") + For Each character As Character In word.Characters + Console.WriteLine($" {character}") + Next + Next + Next + Next + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: diff --git a/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/set-image-size-limits-when-rendering-to-png-jpg.md b/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/set-image-size-limits-when-rendering-to-png-jpg.md index 85e2caf..644e806 100644 --- a/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/set-image-size-limits-when-rendering-to-png-jpg.md +++ b/net/developer-guide/rendering-documents/rendering-to-png-or-jpeg/set-image-size-limits-when-rendering-to-png-jpg.md @@ -30,6 +30,24 @@ public interface IMaxSizeOptions } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +''' +''' Limits of image size options interface. +''' +Public Interface IMaxSizeOptions + ''' + ''' Max width of an output image in pixels. + ''' + Property MaxWidth As Integer + + ''' + ''' Max height of an output image in pixels. + ''' + Property MaxHeight As Integer +End Interface +``` +{{< /tab >}} {{< /tabs >}} {{< alert style="warning" >}} @@ -48,11 +66,15 @@ The following code snippet shows how to set the output image size limits: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.jpg")) { // Create a JPG or PNG file. JpgViewOptions viewOptions = new JpgViewOptions("result_{0}.jpg"); - //PngViewOptions viewOptions = new PngViewOptions("result_{0}.png"); + // or PngViewOptions viewOptions = new PngViewOptions("result_{0}.png"); // Specify the maximum width and height. viewOptions.MaxWidth = 800; @@ -62,4 +84,27 @@ using (Viewer viewer = new Viewer("sample.jpg")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.jpg") + ' Create a JPG or PNG file. + Dim viewOptions As JpgViewOptions = New JpgViewOptions("result_{0}.jpg") + ' or PngViewOptions viewOptions = new PngViewOptions("result_{0}.png"); + + ' Specify the maximum width and height. + viewOptions.MaxWidth = 800 + viewOptions.MaxHeight = 600 + + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} \ No newline at end of file diff --git a/net/developer-guide/rendering-documents/replace-missing-font.md b/net/developer-guide/rendering-documents/replace-missing-font.md index 65b624c..80db1df 100644 --- a/net/developer-guide/rendering-documents/replace-missing-font.md +++ b/net/developer-guide/rendering-documents/replace-missing-font.md @@ -17,14 +17,39 @@ The following code snippet shows how to set the default font name: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp -using (Viewer viewer = new Viewer(@"sample.pptx")) +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + +using (Viewer viewer = new Viewer("sample.pptx")) { // Create an HTML file. HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); + // Specify a default font. viewOptions.DefaultFontName = "Courier New"; viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.pptx") + ' Create an HTML file. + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources () + + ' Specify a default font. + viewOptions.DefaultFontName = "Courier New" + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} \ No newline at end of file diff --git a/net/developer-guide/rendering-documents/save-output-to-stream.md b/net/developer-guide/rendering-documents/save-output-to-stream.md index 6796d09..8345eec 100644 --- a/net/developer-guide/rendering-documents/save-output-to-stream.md +++ b/net/developer-guide/rendering-documents/save-output-to-stream.md @@ -26,6 +26,13 @@ The following code snippet shows how to render to HTML with embedded resources a {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System.IO; +using System.Collections.Generic; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Interfaces; +// ... + // Create the list to store output pages List pages = new List(); @@ -35,7 +42,7 @@ using (Viewer viewer = new Viewer("sample.docx")) ViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(pageStreamFactory); viewer.View(viewOptions); } -// + internal class MemoryPageStreamFactory : IPageStreamFactory { private readonly List _pages; @@ -59,4 +66,47 @@ internal class MemoryPageStreamFactory : IPageStreamFactory } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System.IO +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Interfaces +' ... + +Module Program + Sub Main(args As String()) + ' Create the list to store output pages + Dim pages As New List(Of MemoryStream)() + + Using viewer As New Viewer("sample.docx") + Dim pageStreamFactory As New MemoryPageStreamFactory(pages) + Dim viewOptions As ViewOptions = HtmlViewOptions.ForEmbeddedResources(pageStreamFactory) + viewer.View(viewOptions) + End Using + End Sub + + Class MemoryPageStreamFactory + Implements IPageStreamFactory + + Private ReadOnly _pages As List(Of MemoryStream) + + Public Sub New(pages As List(Of MemoryStream)) + _pages = pages + End Sub + + Public Function CreatePageStream(pageNumber As Integer) As Stream Implements IPageStreamFactory.CreatePageStream + Dim pageStream As New MemoryStream() + _pages.Add(pageStream) + Return pageStream + End Function + + Public Sub ReleasePageStream(pageNumber As Integer, pageStream As Stream) _ + Implements IPageStreamFactory.ReleasePageStream + 'Do not release page stream as we'll need to keep the stream open + End Sub + End Class +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/developer-guide/rendering-documents/set-custom-fonts.md b/net/developer-guide/rendering-documents/set-custom-fonts.md index eee1553..d4b1603 100644 --- a/net/developer-guide/rendering-documents/set-custom-fonts.md +++ b/net/developer-guide/rendering-documents/set-custom-fonts.md @@ -15,10 +15,16 @@ The following code snippet shows how to add a custom font source: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Fonts; +// ... + // Specify the font source. -FolderFontSource fontSource = new FolderFontSource(@"C:\custom_fonts", Fonts.SearchOption.TopFolderOnly); -FontSettings.SetFontSources(fontSource); - +FolderFontSource fontSource = + new FolderFontSource(@"C:\custom_fonts", SearchOption.TopFolderOnly); +FontSettings.SetFontSources(fontSource); + using (Viewer viewer = new Viewer("sample.docx")) { // Create an HTML file. @@ -27,4 +33,26 @@ using (Viewer viewer = new Viewer("sample.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Fonts +' ... + +Module Program + Sub Main(args As String()) + ' Specify the font source. + Dim fontSource As FolderFontSource = New FolderFontSource("C:\custom_fonts", SearchOption.TopFolderOnly) + FontSettings.SetFontSources(fontSource) + + Using viewer As Viewer = New Viewer("sample.docx") + ' Create an HTML file. + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} \ No newline at end of file diff --git a/net/developer-guide/rendering-documents/show-hidden-pages.md b/net/developer-guide/rendering-documents/show-hidden-pages.md index faaf93e..226eeba 100644 --- a/net/developer-guide/rendering-documents/show-hidden-pages.md +++ b/net/developer-guide/rendering-documents/show-hidden-pages.md @@ -21,14 +21,39 @@ The following code snippet shows how to enable rendering of hidden items: {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.pptx")) { - // Create an HTML file. + // Create view options. var viewOptions = HtmlViewOptions.ForEmbeddedResources(); + // Enable rendering of hidden items. viewOptions.RenderHiddenPages = true; - viewer.View(viewOptions); + viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.pptx") + ' Create view options. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources() + + ' Enable rendering of hidden items. + viewOptions.RenderHiddenPages = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} \ No newline at end of file diff --git a/net/developer-guide/rendering-documents/view-specific-pages.md b/net/developer-guide/rendering-documents/view-specific-pages.md index 1a0ae27..df136d9 100644 --- a/net/developer-guide/rendering-documents/view-specific-pages.md +++ b/net/developer-guide/rendering-documents/view-specific-pages.md @@ -25,15 +25,39 @@ The following code snippet shows how to render the first and third pages of a do {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { - // Create an HTML file. + // Create view options. HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); + // Specify the page numbers. viewer.View(viewOptions, 1, 3); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + ' Create view options. + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + + ' Specify the page numbers. + viewer.View(viewOptions, 1, 3) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Specify pages by using an array @@ -49,16 +73,43 @@ The following code snippet shows how to render the 1st, 2nd, and 4th pages of a {{< tabs "example2">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + // Create an array and specify page numbers. - int[] pageNumbers = new int[] { 1, 2, 4 }; - - using (Viewer viewer = new Viewer("sample.docx")) - { - // Create an HTML file. - var viewOptions = HtmlViewOptions.ForEmbeddedResources(); - // Use array to render specific pages. - viewer.View(viewOptions, pageNumbers); - } +int[] pageNumbers = new int[] { 1, 2, 4 }; + +using (Viewer viewer = new Viewer("sample.docx")) +{ + // Create view options. + var viewOptions = HtmlViewOptions.ForEmbeddedResources(); + + // Use array to render specific pages. + viewer.View(viewOptions, pageNumbers); +} +``` +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + ' Create an array and specify page numbers. + Dim pageNumbers = New Integer() {1, 2, 4} + + Using viewer As Viewer = New Viewer("sample.docx") + ' Create view options. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources() + + ' Use array to render specific pages. + viewer.View(viewOptions, pageNumbers) + End Using + End Sub +End Module ``` {{< /tab >}} {{< /tabs >}} \ No newline at end of file diff --git a/net/developer-guide/retrieving-document-information/get-pdf-output-file-info.md b/net/developer-guide/retrieving-document-information/get-pdf-output-file-info.md index 4e866ed..5e40a32 100644 --- a/net/developer-guide/retrieving-document-information/get-pdf-output-file-info.md +++ b/net/developer-guide/retrieving-document-information/get-pdf-output-file-info.md @@ -16,6 +16,12 @@ The following code snippet shows how to get the page count and the width and hei {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Results; +// ... + using (Viewer viewer = new Viewer("sample.pdf")) { // Get file information. @@ -34,6 +40,34 @@ using (Viewer viewer = new Viewer("sample.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.pdf") + ' Get file information. + Dim viewInfoOptions As ViewInfoOptions = ViewInfoOptions.ForPdfView() + Dim viewInfo As ViewInfo = viewer.GetViewInfo(viewInfoOptions) + + ' Display page count. + Console.WriteLine("Pages count: " & viewInfo.Pages.Count.ToString()) + + ' Display width and height of each page. + For Each page As Page In viewInfo.Pages + Console.WriteLine($"Page: {page.Number}; Width: {page.Width}, pixels") + Console.WriteLine($"Page: {page.Number}; Height: {page.Height}, pixels") + Next + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: diff --git a/net/developer-guide/retrieving-document-information/how-to-check-if-file-is-encrypted.md b/net/developer-guide/retrieving-document-information/how-to-check-if-file-is-encrypted.md index a21b0fa..f53403a 100644 --- a/net/developer-guide/retrieving-document-information/how-to-check-if-file-is-encrypted.md +++ b/net/developer-guide/retrieving-document-information/how-to-check-if-file-is-encrypted.md @@ -16,17 +16,45 @@ If you want to check if a file is encrypted, use the _GetFileInfo()_ method that {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Results; +// ... + using (Viewer viewer = new Viewer("encrypted.pdf")) { - // Get file information. - Results.FileInfo fileInfo = viewer.GetFileInfo(); + // Get file information. + FileInfo fileInfo = viewer.GetFileInfo(); - // Display the file type and flag if the file is encrypted. + // Display the file type and flag if the file is encrypted. Console.WriteLine("File type is: " + fileInfo.FileType); Console.WriteLine("File encrypted: " + fileInfo.Encrypted); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("encrypted.pdf") + ' Get file information. + Dim fileInfo As FileInfo = viewer.GetFileInfo() + + ' Display the file type and flag if the file is encrypted. + Console.WriteLine("File type is: " & fileInfo.FileType.ToString()) + Console.WriteLine("File encrypted: " & fileInfo.Encrypted.ToString()) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: diff --git a/net/developer-guide/retrieving-document-information/how-to-determine-file-type.md b/net/developer-guide/retrieving-document-information/how-to-determine-file-type.md index c5d76ba..8ba474f 100644 --- a/net/developer-guide/retrieving-document-information/how-to-determine-file-type.md +++ b/net/developer-guide/retrieving-document-information/how-to-determine-file-type.md @@ -25,6 +25,10 @@ The following code snippet shows how to determine a file type using the file ext {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System; +using GroupDocs.Viewer; +// ... + // Specify a file extension. string extension = ".docx"; // Set a file type using the extension. @@ -33,6 +37,24 @@ FileType fileType = FileType.FromExtension(extension); Console.WriteLine($"Extension {extension}; File type: {fileType}."); ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports GroupDocs.Viewer +' ... + +Module Program + Sub Main(args As String()) + ' Specify a file extension. + Dim extension As String = ".docx" + ' Set a file type using the extension. + Dim fileType As FileType = FileType.FromExtension(extension) + ' Display the extension and the file type. + Console.WriteLine($"Extension {extension}; File type: {fileType}.") + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: @@ -48,11 +70,30 @@ The following code snippet shows how to determine a file type using the media he {{< tabs "example2">}} {{< tab "C#" >}} ```csharp +using System; +using GroupDocs.Viewer; +// ... + string mediaType = "application/pdf"; FileType fileType = FileType.FromMediaType(mediaType); Console.WriteLine($"Media-type {mediaType}; File type: {fileType}."); ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports GroupDocs.Viewer +' ... + +Module Program + Sub Main(args As String()) + Dim mediaType As String = "application/pdf" + Dim fileType As FileType = FileType.FromMediaType(mediaType) + Console.WriteLine($"Media-type {mediaType}; File type: {fileType}.") + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: @@ -68,6 +109,11 @@ The following code snippet shows how to determine a file type using the file sig {{< tabs "example3">}} {{< tab "C#" >}} ```csharp +using System; +using System.IO; +using GroupDocs.Viewer; +// ... + using (Stream stream = File.OpenRead("sample.docx")) { FileType fileType = FileType.FromStream(stream); @@ -75,6 +121,23 @@ using (Stream stream = File.OpenRead("sample.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports System.IO +Imports GroupDocs.Viewer +' ... + +Module Program + Sub Main(args As String()) + Using stream As Stream = File.OpenRead("sample.docx") + Dim fileType As FileType = FileType.FromStream(stream) + Console.WriteLine($"File type: {fileType}.") + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: diff --git a/net/developer-guide/retrieving-document-information/how-to-get-file-type-and-pages-count.md b/net/developer-guide/retrieving-document-information/how-to-get-file-type-and-pages-count.md index e3d0191..57afefb 100644 --- a/net/developer-guide/retrieving-document-information/how-to-get-file-type-and-pages-count.md +++ b/net/developer-guide/retrieving-document-information/how-to-get-file-type-and-pages-count.md @@ -27,17 +27,47 @@ The following code snippet shows how to get the file type and the pages count fr {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Results; +// ... + using (Viewer viewer = new Viewer("sample.pdf")) { // Get file information. ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView(); ViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions); + // Display file type and pages count. Console.WriteLine("Document type is: " + viewInfo.FileType); Console.WriteLine("Pages count: " + viewInfo.Pages.Count); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.pdf") + ' Get file information. + Dim viewInfoOptions As ViewInfoOptions = ViewInfoOptions.ForHtmlView() + Dim viewInfo As ViewInfo = viewer.GetViewInfo(viewInfoOptions) + + ' Display file type and pages count. + Console.WriteLine("Document type is: " & viewInfo.FileType.ToString()) + Console.WriteLine("Pages count: " & viewInfo.Pages.Count.ToString()) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: @@ -51,6 +81,13 @@ The following code snippet shows how to get the file type and the pages count fr {{< tabs "example2">}} {{< tab "C#" >}} ```csharp +using System; +using System.IO; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Results; +// ... + using (Viewer viewer = new Viewer(File.OpenRead("sample.pdf"))) { ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView(); @@ -61,6 +98,28 @@ using (Viewer viewer = new Viewer(File.OpenRead("sample.pdf"))) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports System.IO +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer(File.OpenRead("sample.pdf")) + Dim viewInfoOptions As ViewInfoOptions = ViewInfoOptions.ForHtmlView() + Dim viewInfo As ViewInfo = viewer.GetViewInfo(viewInfoOptions) + + Console.WriteLine("Document type is: " & viewInfo.FileType.ToString()) + Console.WriteLine("Pages count: " & viewInfo.Pages.Count.ToString()) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: diff --git a/net/developer-guide/retrieving-document-information/how-to-get-page-width-and-height.md b/net/developer-guide/retrieving-document-information/how-to-get-page-width-and-height.md index 58ba23f..f0ec2e6 100644 --- a/net/developer-guide/retrieving-document-information/how-to-get-page-width-and-height.md +++ b/net/developer-guide/retrieving-document-information/how-to-get-page-width-and-height.md @@ -16,6 +16,12 @@ The following code snippet shows how to get the width and height of each documen {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System; +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Results; +// ... + using (Viewer viewer = new Viewer("sample.pdf")) { // Get file information. @@ -31,6 +37,31 @@ using (Viewer viewer = new Viewer("sample.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.pdf") + ' Get file information. + Dim viewInfoOptions As ViewInfoOptions = ViewInfoOptions.ForHtmlView() + Dim viewInfo As ViewInfo = viewer.GetViewInfo(viewInfoOptions) + + ' Display width and height of each page. + For Each page As Page In viewInfo.Pages + Console.WriteLine($"Page: {page.Number}; Width: {page.Width}, pixels") + Console.WriteLine($"Page: {page.Number}; Height: {page.Height}, pixels") + Next + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: diff --git a/net/developer-guide/retrieving-document-information/how-to-list-and-print-all-supported-file-types.md b/net/developer-guide/retrieving-document-information/how-to-list-and-print-all-supported-file-types.md index 9e9669c..44ff214 100644 --- a/net/developer-guide/retrieving-document-information/how-to-list-and-print-all-supported-file-types.md +++ b/net/developer-guide/retrieving-document-information/how-to-list-and-print-all-supported-file-types.md @@ -20,8 +20,14 @@ The following code snippet shows how to list supported file formats in the conso {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System; +using System.Collections.Generic; +using GroupDocs.Viewer; +// ... + // Get list of file types. IEnumerable supportedFileTypes = FileType.GetSupportedFileTypes(); + // Display list of file types foreach (FileType fileType in supportedFileTypes) { @@ -29,6 +35,26 @@ foreach (FileType fileType in supportedFileTypes) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports System.Collections.Generic +Imports GroupDocs.Viewer +' ... + +Module Program + Sub Main(args As String()) + ' Get list of file types. + Dim supportedFileTypes As IEnumerable(Of FileType) = FileType.GetSupportedFileTypes() + + ' Display list of file types + For Each fileType As FileType In supportedFileTypes + Console.WriteLine(fileType) + Next + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: diff --git a/net/developer-guide/troubleshooting/how-to-migrate-to-groupdocs.viewer-19.8-or-higher.md b/net/developer-guide/troubleshooting/how-to-migrate-to-groupdocs.viewer-19.8-or-higher.md index 8357878..de3a273 100644 --- a/net/developer-guide/troubleshooting/how-to-migrate-to-groupdocs.viewer-19.8-or-higher.md +++ b/net/developer-guide/troubleshooting/how-to-migrate-to-groupdocs.viewer-19.8-or-higher.md @@ -56,6 +56,35 @@ foreach (PageHtml page in pages) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +'Get Configurations +Dim config As ViewerConfig = Utilities.GetConfigurations() + +' Create html handler +Dim htmlHandler As ViewerHtmlHandler = New ViewerHtmlHandler(config) + +' Guid implies that unique document name +Dim guid As String = "sample.docx" + +'Instantiate the HtmlOptions object +Dim options As HtmlOptions = New HtmlOptions() + +'to get html representations of pages with embedded resources +options.IsResourcesEmbedded = True + +' Set password if document is password protected. +If Not [String].IsNullOrEmpty(DocumentPassword) Then options.Password = DocumentPassword + +'Get document pages in html form +Dim pages As List(Of PageHtml) = htmlHandler.GetPages(guid, options) + +For Each page As PageHtml In pages + 'Save each page at disk + Utilities.SaveAsHtml(page.PageNumber.ToString() & "_" + DocumentName, page.HtmlContent) +Next +``` +{{< /tab >}} {{< /tabs >}} The following code snippet shows the new coding style: @@ -63,6 +92,10 @@ The following code snippet shows the new coding style: {{< tabs "example2">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("sample.docx")) { HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(); @@ -70,4 +103,19 @@ using (Viewer viewer = new Viewer("sample.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + Dim options As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewer.View(options) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} \ No newline at end of file diff --git a/net/developer-guide/troubleshooting/known-issues/limitations-when-rendering-cad-drawings.md b/net/developer-guide/troubleshooting/known-issues/limitations-when-rendering-cad-drawings.md index 7135a85..8e7c7a5 100644 --- a/net/developer-guide/troubleshooting/known-issues/limitations-when-rendering-cad-drawings.md +++ b/net/developer-guide/troubleshooting/known-issues/limitations-when-rendering-cad-drawings.md @@ -15,8 +15,8 @@ hideChildren: False When rendering CAD drawings using GroupDocs.Viewer, it is required to add the [assembly binding redirect](https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/redirect-assembly-versions) to the app.config or web.config project files. The following example shows the required assembly binding redirect to render CAD drawings with GroupDocs.Viewer for .NET 20.6.1 and earlier. {{< tabs "example1">}} -{{< tab "C#" >}} -```csharp +{{< tab "Project file" >}} +```xml diff --git a/net/getting-started/how-to-run-examples.md b/net/getting-started/how-to-run-examples.md index 640b768..bde411a 100644 --- a/net/getting-started/how-to-run-examples.md +++ b/net/getting-started/how-to-run-examples.md @@ -26,15 +26,37 @@ You can build a project from scratch using Visual Studio or [.NET CLI](https://d 6. Edit `Program.cs` and add the following lines to the `Main` method {{< tabs "example1">}} {{< tab "C#" >}} - ```csharp - string documentPath = @"C:\sample.docx"; - using (Viewer viewer = new Viewer(documentPath)) - { - string filePathFormat = @"C:\output\page-{0}.html"; - HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(filePathFormat); - viewer.View(options); - } - ``` +```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + +using (Viewer viewer = new Viewer("sample.docx")) +{ + string outputFilePathFormat = @"output\page-{0}.html"; + HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(outputFilePathFormat); + + viewer.View(options); +} +``` +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + Dim outputFilePathFormat As String = "output\page-{0}.html" + Dim options As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources(outputFilePathFormat) + + viewer.View(options) + End Using + End Sub +End Module +``` {{< /tab >}} {{< /tabs >}} 7. Replace `documentPath` value with the actual path to the document you're going to render. @@ -49,15 +71,35 @@ You can build a project from scratch using Visual Studio or [.NET CLI](https://d 4. Add the following code to the `Main` method: {{< tabs "example2">}} {{< tab "C#" >}} - ```csharp - string documentPath = @"C:\sample.docx"; - using (Viewer viewer = new Viewer(documentPath)) - { - string filePathFormat = @"C:\output\page-{0}.html"; - HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(filePathFormat); - viewer.View(options); - } - ``` +```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + +using (Viewer viewer = new Viewer("sample.docx")) +{ + string outputFilePathFormat = @"output\page-{0}.html"; + HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(outputFilePathFormat); + viewer.View(options); +} +``` +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.docx") + Dim outputFilePathFormat As String = "output\page-{0}.html" + Dim options As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources(outputFilePathFormat) + viewer.View(options) + End Using + End Sub +End Module +``` {{< /tab >}} {{< /tabs >}} 5. Replace `documentPath` value with the actual path to the document you're going to render. @@ -80,9 +122,9 @@ To run any demo from [GroupDocs.Viewer for .NET Demo projects](https://github.co * Clone the repository: {{< tabs "example3">}} {{< tab "Git" >}} - ```bash - git clone git@github.com:groupdocs-viewer/GroupDocs.Viewer-for-.NET.git - ``` +```bash +git clone git@github.com:groupdocs-viewer/GroupDocs.Viewer-for-.NET.git +``` {{< /tab >}} {{< /tabs >}} * Or [download](https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET/archive/master.zip) source code. diff --git a/net/getting-started/how-to-run-in-docker.md b/net/getting-started/how-to-run-in-docker.md index 1ba6a62..dc88429 100644 --- a/net/getting-started/how-to-run-in-docker.md +++ b/net/getting-started/how-to-run-in-docker.md @@ -51,6 +51,7 @@ In this documentation article we're going to use [Official .NET Docker image](ht ```cs using GroupDocs.Viewer; using GroupDocs.Viewer.Options; +// ... namespace DemoApp { @@ -78,7 +79,7 @@ namespace DemoApp `formatting.docx` is sample DOCX file that we're going to use in this example. Click [here](/viewer/net/sample-files/how-to-run-groupdocs-viewer-in-docker/formatting.docx) to download it. {{< /tab-text >}} {{< /tab >}} -{{}} +{{< /tabs >}} Your folder tree should look similar to the following directory structure: diff --git a/net/getting-started/licensing-and-subscription.md b/net/getting-started/licensing-and-subscription.md index 072b1ca..f2e4d96 100644 --- a/net/getting-started/licensing-and-subscription.md +++ b/net/getting-started/licensing-and-subscription.md @@ -74,11 +74,28 @@ The following code snippet shows how to set a license from file: {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +// ... + string licensePath = "GroupDocs.Viewer.lic"; License license = new License(); license.SetLicense(licensePath); ``` +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +' ... + +Module Program + Sub Main(args As String()) + Dim licensePath As String = "GroupDocs.Viewer.lic" + Dim license As License = New License() + license.SetLicense(licensePath) + End Sub +End Module +``` {{< /tab >}} {{< /tabs >}} @@ -90,6 +107,10 @@ The following code snippet shows how to set a license from a stream: {{< tab "C#" >}} ```csharp +using System.IO; +using GroupDocs.Viewer; +// ... + string licensePath = "GroupDocs.Viewer.lic"; using (FileStream fileStream = File.OpenRead(licensePath)) { @@ -98,6 +119,24 @@ using (FileStream fileStream = File.OpenRead(licensePath)) } ``` +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System.IO +Imports GroupDocs.Viewer +' ... + +Module Program + Sub Main(args As String()) + Dim licensePath As String = "GroupDocs.Viewer.lic" + + Using fileStream As FileStream = File.OpenRead(licensePath) + Dim license As License = New License() + license.SetLicense(fileStream) + End Using + End Sub +End Module +``` {{< /tab >}} {{< /tabs >}} @@ -110,6 +149,10 @@ The following code snippet shows how to use the metered license: {{< tabs "example3">}} {{< tab "C#" >}} ```csharp +using System; +using GroupDocs.Viewer; +// ... + string publicKey = ""; // Your public license key string privateKey = ""; // Your private license key @@ -125,6 +168,31 @@ decimal creditsConsumed = GroupDocs.Viewer.Metered.GetConsumptionCredit(); Console.WriteLine("Credits consumed: " + creditsConsumed); ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports GroupDocs.Viewer +' ... + +Module Program + Sub Main(args As String()) + Dim publicKey As String = "" ' Your public license key + Dim privateKey As String = "" ' Your private license key + + Dim metered As Metered = New Metered() + metered.SetMeteredKey(publicKey, privateKey) + + ' Get amount (MB) consumed + Dim amountConsumed As Decimal = GroupDocs.Viewer.Metered.GetConsumptionQuantity() + Console.WriteLine("Amount (MB) consumed: " & amountConsumed.ToString()) + + ' Get count of credits consumed + Dim creditsConsumed As Decimal = GroupDocs.Viewer.Metered.GetConsumptionCredit() + Console.WriteLine("Credits consumed: " & creditsConsumed.ToString()) + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} #### Apply License from an Embedded Resource @@ -140,10 +208,26 @@ The following code snippet shows how to use the embedded license: {{< tabs "example4">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +// ... + License license = new License(); license.SetLicense("GroupDocs.Viewer.lic"); ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +' ... + +Module Program + Sub Main(args As String()) + Dim license As License = New License() + license.SetLicense("GroupDocs.Viewer.lic") + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ### Changing the License File Name diff --git a/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-convert-grayscale.png b/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-convert-grayscale.png index a4ceeff..5fc839c 100644 Binary files a/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-convert-grayscale.png and b/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-convert-grayscale.png differ diff --git a/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-reduce-image-quality.png b/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-reduce-image-quality.png index aadf10c..6323806 100644 Binary files a/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-reduce-image-quality.png and b/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-reduce-image-quality.png differ diff --git a/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-set-max-resolution.png b/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-set-max-resolution.png index 902bb24..009cc03 100644 Binary files a/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-set-max-resolution.png and b/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-set-max-resolution.png differ diff --git a/net/rendering-basics/render-archive-files.md b/net/rendering-basics/render-archive-files.md index 9164939..5c6b13a 100644 --- a/net/rendering-basics/render-archive-files.md +++ b/net/rendering-basics/render-archive-files.md @@ -64,6 +64,24 @@ using (var viewer = new Viewer("Documents.zip")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Documents.zip") + ' Create an HTML file for the top folder and each subfolder in the archive. + ' {0} is replaced with the current page number in the output file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -94,6 +112,26 @@ using (var viewer = new Viewer("Documents.zip")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Documents.zip") + ' Create an HTML file for the top folder and each subfolder in the archive. + ' {0} is replaced with the current page number in the output file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + ' Specify the number of items to display on each HTML page. + viewOptions.ArchiveOptions.ItemsPerPage = 10 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ### Create a single HTML page @@ -117,6 +155,25 @@ using (var viewer = new Viewer("Documents.zip")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Documents.zip") + ' Create an HTML file. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html") + ' Render the archive file to a single page. + viewOptions.RenderToSinglePage = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The animation below demonstrates the result. You can navigate between the archive folders. Click on a particular folder to see its contents. To go backward, click the required folder name in the navigation bar at the top of the web page. @@ -142,6 +199,23 @@ using (var viewer = new Viewer("Documents.zip")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Documents.zip") + ' Create a PDF file. + Dim viewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -171,6 +245,27 @@ using (var viewer = new Viewer("Documents.zip")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Documents.zip") + ' Create a PNG image for the top folder and each subfolder in the archive. + ' {0} is replaced with the current page number in the image name. + Dim viewOptions = New PngViewOptions("output_{0}.png") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 1000 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -200,6 +295,27 @@ using (var viewer = new Viewer("Documents.zip")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Documents.zip") + ' Create a JPEG image for the top folder and each subfolder in the archive. + ' {0} is replaced with the current page number in the image name. + Dim viewOptions = New JpgViewOptions("output_{0}.jpg") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 1000 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Obtain information about folders in an archive file @@ -213,6 +329,7 @@ Follow the steps below to obtain information about folders contained in an archi {{< tabs "example7">}} {{< tab "C#" >}} ```csharp +using System; using GroupDocs.Viewer; using GroupDocs.Viewer.Options; using GroupDocs.Viewer.Results; @@ -235,6 +352,34 @@ using (var viewer = new Viewer("Documents.zip")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Documents.zip") + Dim viewInfoOptions = ViewInfoOptions.ForHtmlView() + Dim viewInfo = TryCast(viewer.GetViewInfo(viewInfoOptions), ArchiveViewInfo) + + If viewInfo IsNot Nothing Then + Console.WriteLine($"File type: {viewInfo.FileType}") + Console.WriteLine($"The number of pages: {viewInfo.Pages.Count}") + Console.WriteLine("Folders: ") + ' Display the list of folders in the archive file. + For Each folder As String In viewInfo.Folders + Console.WriteLine($" - {folder}") + Next + End If + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: @@ -272,6 +417,25 @@ using (var viewer = new Viewer("Documents.zip")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Documents.zip") + ' Create an HTML file. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html") + ' Specify a folder to render items from. + viewOptions.ArchiveOptions.Folder = "Documents/CAD files" + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Specify the archive file name @@ -302,6 +466,26 @@ using (var viewer = new Viewer("Documents.zip")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Documents.zip") + ' Create an HTML file for the top folder and each subfolder in the archive. + ' {0} is replaced with the current page number in the output file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + ' Specify a custom filename + viewOptions.ArchiveOptions.FileName = New FileName("Sample Files") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the result. diff --git a/net/rendering-basics/render-cad-documents/render-cad-documents.md b/net/rendering-basics/render-cad-documents/render-cad-documents.md index 8248a1a..3fb5a9d 100644 --- a/net/rendering-basics/render-cad-documents/render-cad-documents.md +++ b/net/rendering-basics/render-cad-documents/render-cad-documents.md @@ -64,15 +64,33 @@ using GroupDocs.Viewer; using GroupDocs.Viewer.Options; // ... -using (var viewer = new Viewer("HousePlan.dwg")) +using (Viewer viewer = new Viewer("HousePlan.dwg")) { // Create an HTML file for the drawing. // Specify the HTML file name. - var viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html"); + HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html"); viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("HousePlan.dwg") + ' Create an HTML file for the drawing. + ' Specify the HTML file name. + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources("output.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -94,16 +112,35 @@ using GroupDocs.Viewer; using GroupDocs.Viewer.Options; // ... -using (var viewer = new Viewer("HousePlan.dwg")) +using (Viewer viewer = new Viewer("HousePlan.dwg")) { // Create an HTML file for the drawing. // Specify the HTML file name and location of external resources. // {0} is replaced with the resource name. - var viewOptions = HtmlViewOptions.ForExternalResources("output.html", "output/resource_{0}", "output/resource_{0}"); + HtmlViewOptions viewOptions = HtmlViewOptions.ForExternalResources("output.html", "output/resource_{0}", "output/resource_{0}"); viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("HousePlan.dwg") + ' Create an HTML file for the drawing. + ' Specify the HTML file name and location of external resources. + ' {0} is replaced with the resource name. + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForExternalResources("output.html", "output/resource_{0}", "output/resource_{0}") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the result. External resources are placed in a separate folder. @@ -121,15 +158,33 @@ using GroupDocs.Viewer; using GroupDocs.Viewer.Options; // ... -using (var viewer = new Viewer("HousePlan.dwg")) +using (Viewer viewer = new Viewer("HousePlan.dwg")) { // Create a PDF file for the drawing. // Specify the PDF file name. - var viewOptions = new PdfViewOptions("output.pdf"); + PdfViewOptions viewOptions = new PdfViewOptions("output.pdf"); viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("HousePlan.dwg") + ' Create a PDF file for the drawing. + ' Specify the PDF file name. + Dim viewOptions As PdfViewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -147,10 +202,10 @@ using GroupDocs.Viewer; using GroupDocs.Viewer.Options; // ... -using (var viewer = new Viewer("HousePlan.dwg")) +using (Viewer viewer = new Viewer("HousePlan.dwg")) { // Create a PNG image for the drawing. - var viewOptions = new PngViewOptions("output.png"); + PngViewOptions viewOptions = new PngViewOptions("output.png"); // Set width and height. viewOptions.Width = 1500; viewOptions.Height = 1000; @@ -158,6 +213,26 @@ using (var viewer = new Viewer("HousePlan.dwg")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("HousePlan.dwg") + ' Create a PNG image for the drawing. + Dim viewOptions As PngViewOptions = New PngViewOptions("output.png") + ' Set width and height. + viewOptions.Width = 1500 + viewOptions.Height = 1000 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -175,10 +250,10 @@ using GroupDocs.Viewer; using GroupDocs.Viewer.Options; // ... -using (var viewer = new Viewer("HousePlan.dwg")) +using (Viewer viewer = new Viewer("HousePlan.dwg")) { // Create a JPG image for the drawing. - var viewOptions = new JpgViewOptions("output.jpg"); + JpgViewOptions viewOptions = new JpgViewOptions("output.jpg"); // Set width and height. viewOptions.Width = 1500; viewOptions.Height = 1000; @@ -186,6 +261,26 @@ using (var viewer = new Viewer("HousePlan.dwg")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("HousePlan.dwg") + ' Create a JPG image for the drawing. + Dim viewOptions As JpgViewOptions = New JpgViewOptions("output.jpg") + ' Set width and height. + viewOptions.Width = 1500 + viewOptions.Height = 1000 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Get information about existing layouts and layers @@ -199,16 +294,18 @@ Follow the steps below to obtain information about layouts and layers contained {{< tabs "example6">}} {{< tab "C#" >}} ```csharp +using System; using GroupDocs.Viewer; using GroupDocs.Viewer.Options; using GroupDocs.Viewer.Results; +// ... -using (var viewer = new Viewer("HousePlan.dwg")) +using (Viewer viewer = new Viewer("HousePlan.dwg")) { - var viewInfoOptions = ViewInfoOptions.ForHtmlView(); + ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView(); // Enable this option to see the list of all layouts contained in the CAD file. viewInfoOptions.CadOptions.RenderLayouts = true; - var viewInfo = viewer.GetViewInfo(viewInfoOptions) as CadViewInfo; + CadViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions) as CadViewInfo; if (viewInfo != null) { @@ -229,6 +326,44 @@ using (var viewer = new Viewer("HousePlan.dwg")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("HousePlan.dwg") + Dim viewInfoOptions As ViewInfoOptions = ViewInfoOptions.ForHtmlView() + ' Enable this option to see the list of all layouts contained in the CAD file. + viewInfoOptions.CadOptions.RenderLayouts = True + Dim viewInfo As CadViewInfo = TryCast(viewer.GetViewInfo(viewInfoOptions), CadViewInfo) + + If viewInfo IsNot Nothing Then + ' Display information about the CAD file. + Console.WriteLine($"File type: {viewInfo.FileType}") + Console.WriteLine($"The number of pages: {viewInfo.Pages.Count}") + + ' Display the list of existing layouts. + Console.WriteLine("The drawing contains the following layout(s):") + For Each layout As Layout In viewInfo.Layouts + Console.WriteLine(layout.Name) + Next + + ' Display the list of existing layers. + Console.WriteLine("The drawing contains the following layer(s):") + For Each layer As Layer In viewInfo.Layers + Console.WriteLine(layer) + Next + End If + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: @@ -255,16 +390,35 @@ using GroupDocs.Viewer; using GroupDocs.Viewer.Options; // ... -using (var viewer = new Viewer("sample.dwg")) +using (Viewer viewer = new Viewer("sample.dwg")) { // Convert the document to PDF. - var viewOptions = new PdfViewOptions("output.pdf"); + PdfViewOptions viewOptions = new PdfViewOptions("output.pdf"); // Render the Model and all non-empty paper space layouts. viewOptions.CadOptions.RenderLayouts = true; viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.dwg") + ' Convert the document to PDF. + Dim viewOptions As PdfViewOptions = New PdfViewOptions("output.pdf") + ' Render the Model and all non-empty paper space layouts. + viewOptions.CadOptions.RenderLayouts = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} To render a specific layout, assign the layout name to the [CadOptions.LayoutName](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/cadoptions/properties/layoutname) property of a target view. @@ -276,10 +430,10 @@ using GroupDocs.Viewer; using GroupDocs.Viewer.Options; // ... -using (var viewer = new Viewer("sample.dwg")) +using (Viewer viewer = new Viewer("sample.dwg")) { // Convert the document to PDF. - var viewOptions = new PdfViewOptions("output.pdf"); + PdfViewOptions viewOptions = new PdfViewOptions("output.pdf"); // Specify the name of the layout to render. // If the specified layout is not found, // an exception occurs. @@ -288,6 +442,27 @@ using (var viewer = new Viewer("sample.dwg")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("sample.dwg") + ' Convert the document to PDF. + Dim viewOptions As PdfViewOptions = New PdfViewOptions("output.pdf") + ' Specify the name of the layout to render. + ' If the specified layout is not found, + ' an exception occurs. + viewOptions.CadOptions.LayoutName = "Layout1" + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} {{< alert style="info" >}} @@ -319,12 +494,14 @@ The following example renders layers with walls and furniture to PDF: ```csharp using GroupDocs.Viewer; using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Results; +using System.Collections.Generic; // ... -using (var viewer = new Viewer("HousePlan.dwg")) +using (Viewer viewer = new Viewer("HousePlan.dwg")) { // Convert the document to PDF. - var viewOptions = new PdfViewOptions("output.pdf"); + PdfViewOptions viewOptions = new PdfViewOptions("output.pdf"); // Specify a list of layers to display. viewOptions.CadOptions.Layers = new List { @@ -336,6 +513,31 @@ using (var viewer = new Viewer("HousePlan.dwg")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +Imports System.Collections.Generic +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("HousePlan.dwg") + ' Convert the document to PDF. + Dim viewOptions As PdfViewOptions = New PdfViewOptions("output.pdf") + ' Specify a list of layers to display. + viewOptions.CadOptions.Layers = New List(Of Layer) From { + New Layer("Base"), + New Layer("Walls"), + New Layer("Furniture") + } + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below illustrates the result. diff --git a/net/rendering-basics/render-cad-documents/specify-rendering-options.md b/net/rendering-basics/render-cad-documents/specify-rendering-options.md index 3b651b9..de09581 100644 --- a/net/rendering-basics/render-cad-documents/specify-rendering-options.md +++ b/net/rendering-basics/render-cad-documents/specify-rendering-options.md @@ -32,19 +32,42 @@ The following code snippet converts a CAD drawing to PDF and sets the background {{< tab "C#" >}} ```csharp using GroupDocs.Viewer; +using GroupDocs.Viewer.Drawing; using GroupDocs.Viewer.Options; // ... using (var viewer = new Viewer("HousePlan.dwg")) { - // Convert the document to PDF. - var viewOptions = new PdfViewOptions("output.pdf"); - // Specify the background color. - viewOptions.CadOptions.BackgroundColor = Color.LightYellow; - viewer.View(viewOptions); + // Convert the document to PDF. + var viewOptions = new PdfViewOptions("output.pdf"); + + // Specify the background color. + viewOptions.CadOptions.BackgroundColor = Argb32Color.Transparent; + viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Drawing +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("HousePlan.dwg") + ' Convert the document to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + + ' Specify the background color. + viewOptions.CadOptions.BackgroundColor = Argb32Color.Transparent + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image illustrates the result: @@ -79,6 +102,25 @@ using (var viewer = new Viewer("HousePlan.dwg")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("HousePlan.dwg") + ' Convert the diagram to PNG. + Dim viewOptions = New PngViewOptions("output.png") + ' Specify a scale factor. + viewOptions.CadOptions = CadOptions.ForRenderingByScaleFactor(0.5F) + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} When you render all layouts/sheets contained in a CAD file (the [CadOptions.RenderLayouts](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/cadoptions/properties/renderlayouts) property is `true`), each layout/sheet is rendered as a separate page/image and has its own size. In this case, when you specify only the [width](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/cadoptions/methods/forrenderingbywidth) or [height](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/cadoptions/methods/forrenderingbyheight) value, the other side is scaled proportionally to maintain the aspect ratio of each layout/sheet. When you set both [width and height](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/cadoptions/methods/forrenderingbywidthandheight), all generated images have the same size and may look distorted. To avoid this, use the [CadOptions.LayoutName](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/cadoptions/properties/layoutname) property to render each layout/sheet separately and set its size. @@ -104,6 +146,25 @@ using (var viewer = new Viewer("sample.dwg")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.dwg") + ' Convert the diagram to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Specify a path to the PC3 file. + viewOptions.CadOptions.Pc3File = "small_page.pc3" + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Split a drawing into tiles @@ -161,6 +222,48 @@ using (var viewer = new Viewer("HousePlan.dwg")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("HousePlan.dwg") + Dim viewInfoOptions = ViewInfoOptions.ForHtmlView() + Dim viewInfo = viewer.GetViewInfo(viewInfoOptions) + + ' Get the width and height of the CAD drawing. + Dim width As Integer = viewInfo.Pages(0).Width + Dim height As Integer = viewInfo.Pages(0).Height + + ' Specify the number of rows and columns to split the drawing into. + Dim columns As Integer = 2 + Dim rows As Integer = 2 + + ' Calculate the width and height of each tile. + Dim tileWidth As Integer = width / columns + Dim tileHeight As Integer = height / rows + Dim pointX As Integer = 0 + Dim pointY As Integer = 0 + + ' Split the drawing into tiles and convert them to HTML. + ' {0} is replaced with the tile number in the output file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + For i As Integer = 0 To columns - 1 + For j As Integer = 0 To rows - 1 + Dim tile As Tile = New Tile(pointX + tileWidth * i, pointY + tileHeight * j, tileWidth, tileHeight) + viewOptions.CadOptions.Tiles.Add(tile) + Next + Next + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} In the example above the GroupDocs.Viewer will generate four HTML files named "page_1.html", "page_2.html", "page_3.html", and "page_4.html", where each of these HTML file contains a single tile in a form of SVG vector image. The [`HtmlViewOptions.ForExternalResources()`](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/htmlviewoptions/forexternalresources/#forexternalresources) static method (with all its overloads) can also be used — in such case the SVG files will not be embedded inside the output HTML files, but will be saved separately, while HTML only references them through the `A` HTML element. @@ -175,7 +278,14 @@ Starting from the version 24.2 the GroupDocs.Viewer introduces a new public prop Enabling this mode is pretty simple — just create an instance of the [`CadOptions`](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/cadoptions) class by using [any of the static methods described above](#ctors), and then set the value for the `EnablePerformanceConversionMode` property. Example is below: + +{{< tabs "example5">}} +{{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("input.dwg")) { HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources("Output-Page#{0}.html"); @@ -185,6 +295,29 @@ using (Viewer viewer = new Viewer("input.dwg")) viewer.View(viewOptions); } ``` +{{< /tab >}} +{{< tab "VB.NET" >}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("input.dwg") + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + + viewOptions.CadOptions = CadOptions.ForRenderingByWidth(1000) + viewOptions.CadOptions.EnablePerformanceConversionMode = True + + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} + +{{< /tabs >}} If taking an ordinary DWG file as a sample, the comparison between "quality" and "performance" modes are the next: diff --git a/net/rendering-basics/render-ebooks.md b/net/rendering-basics/render-ebooks.md index b429320..98b2e48 100644 --- a/net/rendering-basics/render-ebooks.md +++ b/net/rendering-basics/render-ebooks.md @@ -52,6 +52,24 @@ using (var viewer = new Viewer("abook.epub")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("abook.epub") + ' Create an HTML file for each document page. + ' {0} is replaced with the current page number in the file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -83,6 +101,25 @@ using (var viewer = new Viewer("abook.epub")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("abook.epub") + ' Create an HTML file for each document page. + ' Specify the HTML file names and location of external resources. + ' {0} and {1} are replaced with the current page number and resource name, respectively. + Dim viewOptions = HtmlViewOptions.ForExternalResources("page_{0}.html", "page_{0}/resource_{0}_ {1}", "page_{0}/resource_{0}_{1}") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the result. External resources are placed in a separate folder. @@ -109,6 +146,24 @@ using (var viewer = new Viewer("abook.epub")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("abook.epub") + ' Create a PDF file for the document. + ' Specify the PDF file name. + Dim viewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -131,6 +186,7 @@ using (var viewer = new Viewer("abook.epub")) // Create a PNG image for each document page. // {0} is replaced with the current page number in the image name. var viewOptions = new PngViewOptions("output_{0}.png"); + // Set width and height. viewOptions.Width = 800; viewOptions.Height = 900; @@ -138,6 +194,28 @@ using (var viewer = new Viewer("abook.epub")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("abook.epub") + ' Create a PNG image for each document page. + ' {0} is replaced with the current page number in the image name. + Dim viewOptions = New PngViewOptions("output_{0}.png") + + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 900 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -154,11 +232,12 @@ using GroupDocs.Viewer; using GroupDocs.Viewer.Options; // ... -using (var viewer = new Viewer("abook.epub)) +using (var viewer = new Viewer("abook.epub")) { // Create a JPEG image for each document page. // {0} is replaced with the current page number in the image name. var viewOptions = new JpgViewOptions("output_{0}.jpg"); + // Set width and height. viewOptions.Width = 800; viewOptions.Height = 900; @@ -166,5 +245,27 @@ using (var viewer = new Viewer("abook.epub)) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("abook.epub") + ' Create a JPEG image for each document page. + ' {0} is replaced with the current page number in the image name. + Dim viewOptions = New JpgViewOptions("output_{0}.jpg") + + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 900 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/rendering-basics/render-email-messages.md b/net/rendering-basics/render-email-messages.md index a79f15c..901ce51 100644 --- a/net/rendering-basics/render-email-messages.md +++ b/net/rendering-basics/render-email-messages.md @@ -56,6 +56,23 @@ using (var viewer = new Viewer("sample.eml")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.eml") + ' Create an HTML file. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -86,6 +103,24 @@ using (var viewer = new Viewer("sample.eml")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.eml") + ' Specify the HTML file name and location of external resources. + ' {0} is replaced with the resource name in the output file name. + Dim viewOptions = HtmlViewOptions.ForExternalResources("output.html", "output/resource_{0}", "output/resource_{0}") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The result is shown below. External resources are placed in a separate folder. @@ -111,6 +146,23 @@ using (var viewer = new Viewer("sample.eml")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.eml") + ' Create a PDF file. + Dim viewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -139,6 +191,26 @@ using (var viewer = new Viewer("sample.eml")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.eml") + ' Create a PNG image. + Dim viewOptions = New PngViewOptions("output.png") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 1000 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -167,6 +239,26 @@ using (var viewer = new Viewer("sample.eml")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.eml") + ' Create a JPG image. + Dim viewOptions = New JpgViewOptions("output.jpg") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 1000 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Specify rendering options @@ -201,6 +293,25 @@ using (var viewer = new Viewer("sample.eml")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.eml") + ' Create a PDF file. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Specify the page size. + viewOptions.EmailOptions.PageSize = PageSize.Letter + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ### Rename fields in the message header @@ -231,6 +342,28 @@ using (var viewer = new Viewer("sample.eml")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.eml") + ' Create an HTML file. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html") + ' Specify custom field labels. + viewOptions.EmailOptions.FieldTextMap(Field.From) = "Sender" + viewOptions.EmailOptions.FieldTextMap(Field.[To]) = "Recipient" + viewOptions.EmailOptions.FieldTextMap(Field.Sent) = "Date" + viewOptions.EmailOptions.FieldTextMap(Field.Subject) = "Email subject" + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image illustrates the result: @@ -249,6 +382,7 @@ When rendering email messages, GroupDocs.Viewer formats date and time informatio {{< tabs "example8">}} {{< tab "C#" >}} ```csharp +using System; using GroupDocs.Viewer; using GroupDocs.Viewer.Options; // ... @@ -265,6 +399,28 @@ using (var viewer = new Viewer("sample.eml")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.eml") + ' Create an HTML file. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html") + ' Apply a custom format to the date in the email message header. + viewOptions.EmailOptions.DateTimeFormat = "MMMM dd, yyyy H:mm:ss zzz" + ' Specify the time zone offset. + viewOptions.EmailOptions.TimeZoneOffset = New TimeSpan(-7, 0, 0) + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image illustrates the result: diff --git a/net/rendering-basics/render-images.md b/net/rendering-basics/render-images.md index 04300c4..bb28171 100644 --- a/net/rendering-basics/render-images.md +++ b/net/rendering-basics/render-images.md @@ -97,6 +97,23 @@ using (var viewer = new Viewer("vector-image.svg")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("vector-image.svg") + ' Create an HTML file. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -127,6 +144,24 @@ using (var viewer = new Viewer("vector-image.svg")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("vector-image.svg") + ' Specify the HTML file name and location of external resources. + ' {0} is replaced with the resource name in the output file name. + Dim viewOptions = HtmlViewOptions.ForExternalResources("output.html", "output/resource_{0}", "output/resource_{0}") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The result is shown below. The image is placed in a separate folder. @@ -152,6 +187,23 @@ using (var viewer = new Viewer("vector-image.svg")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("vector-image.svg") + ' Create a PDF file. + Dim viewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -180,6 +232,26 @@ using (var viewer = new Viewer("vector-image.svg")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("vector-image.svg") + ' Create a PNG image. + Dim viewOptions = New PngViewOptions("output.png") + ' Set width and height. + viewOptions.Width = 1600 + viewOptions.Height = 900 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -208,6 +280,26 @@ using (var viewer = new Viewer("vector-image.svg")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("vector-image.svg") + ' Create a JPEG image. + Dim viewOptions = New JpgViewOptions("output.jpg") + ' Set width and height. + viewOptions.Width = 1600 + viewOptions.Height = 900 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Render a PSD file with custom fonts @@ -231,8 +323,7 @@ using GroupDocs.Viewer.Options; // ... // Specify a folder that stores custom fonts used in a PSD file. -var fontSource = new FolderFontSource(@"C:\custom_fonts_folder", - GroupDocs.Viewer.Fonts.SearchOption.AllFolders); +var fontSource = new FolderFontSource(@"C:\custom_fonts_folder", SearchOption.AllFolders); FontSettings.SetFontSources(fontSource); using (var viewer = new Viewer("sample.psd")) @@ -240,9 +331,33 @@ using (var viewer = new Viewer("sample.psd")) // Convert a PSD file to PNG. var viewOptions = new PngViewOptions("output.png"); // Specify the default font that should be used to replace missing fonts. - options.DefaultFontName = "Arial"; - viewer.View(options); + viewOptions.DefaultFontName = "Arial"; + viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Fonts +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + ' Specify a folder that stores custom fonts used in a PSD file. + Dim fontSource = New FolderFontSource("C:\custom_fonts_folder", SearchOption.AllFolders) + FontSettings.SetFontSources(fontSource) + + Using viewer = New Viewer("sample.psd") + ' Convert a PSD file to PNG. + Dim viewOptions = New PngViewOptions("output.png") + ' Specify the default font that should be used to replace missing fonts. + viewOptions.DefaultFontName = "Arial" + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/rendering-basics/render-lotus-notes-files.md b/net/rendering-basics/render-lotus-notes-files.md index fe79b53..694a03f 100644 --- a/net/rendering-basics/render-lotus-notes-files.md +++ b/net/rendering-basics/render-lotus-notes-files.md @@ -39,6 +39,23 @@ using (var viewer = new Viewer("sample.nsf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.nsf") + ' Create an HTML file. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -64,6 +81,23 @@ using (var viewer = new Viewer("sample.nsf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.nsf") + ' Create a PDF file. + Dim viewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -93,6 +127,27 @@ using (var viewer = new Viewer("sample.nsf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.nsf") + ' Convert the NSF file to PNG. + ' {0} is replaced with the page numbers in the output image names. + Dim viewOptions = New PngViewOptions("output_{0}.png") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 1000 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -122,6 +177,27 @@ using (var viewer = new Viewer("sample.nsf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.nsf") + ' Convert the NSF file to JPEG. + ' {0} is replaced with the page numbers in the output image names. + Dim viewOptions = New JpgViewOptions("output_{0}.jpg") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 1000 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Specify rendering options @@ -156,6 +232,25 @@ using (var viewer = new Viewer("sample.nsf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.nsf") + ' Create an HTML file. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources() + ' Specify the maximum items to render. + viewOptions.MailStorageOptions.MaxItems = 20 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ### Filter messages @@ -189,4 +284,24 @@ using (var viewer = new Viewer("sample.nsf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.nsf") + ' Create an HTML file. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources() + ' Set filters. + viewOptions.MailStorageOptions.TextFilter = "Viewer" + viewOptions.MailStorageOptions.AddressFilter = "groupdocs@mail.com" + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/rendering-basics/render-ms-project-files.md b/net/rendering-basics/render-ms-project-files.md index 47b7dc6..8b8fd10 100644 --- a/net/rendering-basics/render-ms-project-files.md +++ b/net/rendering-basics/render-ms-project-files.md @@ -57,6 +57,24 @@ using (var viewer = new Viewer("SoftwareDevelopmentPlan.mpp")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("SoftwareDevelopmentPlan.mpp") + ' Render the project's active view as HTML. + ' {0} is replaced with the current page number in the output file names. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -88,6 +106,25 @@ using (var viewer = new Viewer("SoftwareDevelopmentPlan.mpp")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("SoftwareDevelopmentPlan.mpp") + ' Render the project's active view as HTML. + ' Specify the HTML file names and location of external resources. + ' {0} and {1} are replaced with the page number and resource name, respectively. + Dim viewOptions = HtmlViewOptions.ForExternalResources("page_{0}.html", "page_{0}/resource_{0}_{1}", "page_{0}/resource_{0}_{1}") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the result. External resources are placed in a separate folder. @@ -113,6 +150,23 @@ using (var viewer = new Viewer("SoftwareDevelopmentPlan.mpp")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("SoftwareDevelopmentPlan.mpp") + ' Create a PDF file for the project's active view. + Dim viewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -142,6 +196,27 @@ using (var viewer = new Viewer("SoftwareDevelopmentPlan.mpp")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("SoftwareDevelopmentPlan.mpp") + ' Render the project's active view as PNG. + ' {0} is replaced with the current page number in the output file names. + Dim viewOptions = New PngViewOptions("output_{0}.png") + ' Set width and height. + viewOptions.Width = 1600 + viewOptions.Height = 650 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -171,6 +246,27 @@ using (var viewer = new Viewer("SoftwareDevelopmentPlan.mpp")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("SoftwareDevelopmentPlan.mpp") + ' Render the project's active view as JPEG. + ' {0} is replaced with the current page number in the output file names. + Dim viewOptions = New JpgViewOptions("output_{0}.jpg") + ' Set width and height. + viewOptions.Width = 1600 + viewOptions.Height = 650 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Get information about a Project file @@ -205,6 +301,31 @@ using (var viewer = new Viewer("SoftwareDevelopmentPlan.mpp")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("SoftwareDevelopmentPlan.mpp") + Dim viewInfoOptions = ViewInfoOptions.ForHtmlView() + Dim viewInfo = TryCast(viewer.GetViewInfo(viewInfoOptions), ProjectManagementViewInfo) + + If viewInfo IsNot Nothing Then + ' Display information about the Project file. + Console.WriteLine($"File type: {viewInfo.FileType}") + Console.WriteLine($"The number of pages: {viewInfo.Pages.Count}") + Console.WriteLine($"Project start date: {viewInfo.StartDate}") + Console.WriteLine($"Project end date: {viewInfo.EndDate}") + End If + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: @@ -239,6 +360,25 @@ using (var viewer = new Viewer("SoftwareDevelopmentPlan.mpp")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("SoftwareDevelopmentPlan.mpp") + ' Convert the document to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Specify the page size. + viewOptions.ProjectManagementOptions.PageSize = PageSize.A3 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} @@ -271,6 +411,26 @@ using (var viewer = new Viewer("SoftwareDevelopmentPlan.mpp")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("SoftwareDevelopmentPlan.mpp") + ' Convert the document to HTML. + ' {0} is replaced with the current page number in the file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("output_{0}.html") + ' Specify the time unit. + viewOptions.ProjectManagementOptions.TimeUnit = TimeUnit.ThirdsOfMonths + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below illustrates the result. @@ -286,6 +446,7 @@ The example below demonstrates how to convert a Project file to PDF and set the {{< tabs "example9">}} {{< tab "C#" >}} ```csharp +using System; using GroupDocs.Viewer; using GroupDocs.Viewer.Options; // ... @@ -298,6 +459,28 @@ using (var viewer = new Viewer("SoftwareDevelopmentPlan.mpp")) viewOptions.ProjectManagementOptions.StartDate = new DateTime(2022, 08, 01); viewOptions.ProjectManagementOptions.EndDate = new DateTime(2022, 09, 01); viewer.View(viewOptions); +} +``` +{{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("SoftwareDevelopmentPlan.mpp") + ' Convert the document to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Specify the date range. + viewOptions.ProjectManagementOptions.StartDate = New DateTime(2022, 08, 01) + viewOptions.ProjectManagementOptions.EndDate = New DateTime(2022, 09, 01) + viewer.View(viewOptions) + End Using + End Sub +End Module ``` {{< /tab >}} {{< /tabs >}} @@ -333,6 +516,25 @@ using (var viewer = new Viewer("SoftwareDevelopmentPlan.mpp")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("SoftwareDevelopmentPlan.mpp") + ' Convert the document to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Enable notes rendering. + viewOptions.RenderNotes = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the result. Notes are rendered on a separate page. diff --git a/net/rendering-basics/render-outlook-data-files.md b/net/rendering-basics/render-outlook-data-files.md index d35114e..49d4097 100644 --- a/net/rendering-basics/render-outlook-data-files.md +++ b/net/rendering-basics/render-outlook-data-files.md @@ -51,6 +51,23 @@ using (var viewer = new Viewer("sample.pst")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pst") + ' Create an HTML file. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -76,6 +93,23 @@ using (var viewer = new Viewer("sample.pst")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pst") + ' Create a PDF file. + Dim viewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -105,6 +139,27 @@ using (var viewer = new Viewer("sample.pst")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pst") + ' Convert the PST file to PNG. + ' {0} is replaced with the page numbers in the output image names. + Dim viewOptions = New PngViewOptions("output_{0}.png") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 900 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -134,6 +189,27 @@ using (var viewer = new Viewer("sample.pst")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pst") + ' Convert the PST file to JPEG. + ' {0} is replaced with the page numbers in the output image names. + Dim viewOptions = New JpgViewOptions("output_{0}.jpg") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 900 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Get information about folders in an Outlook data file @@ -172,6 +248,36 @@ using (var viewer = new Viewer("sample.pst")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pst") + ' Create an HTML file. + Dim viewInfoOptions = ViewInfoOptions.ForHtmlView() + Dim viewInfo = TryCast(viewer.GetViewInfo(viewInfoOptions), OutlookViewInfo) + + If viewInfo IsNot Nothing Then + ' Display information about the PST file. + Console.WriteLine($"File type: {viewInfo.FileType}") + Console.WriteLine($"The number of pages: {viewInfo.Pages.Count}") + + ' Display the list of folders that the PST file contains. + Console.WriteLine("The file contains the following folders:") + For Each folder As String In viewInfo.Folders + Console.WriteLine(folder) + Next + End If + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Specify rendering options @@ -207,6 +313,27 @@ using (var viewer = new Viewer("sample.pst")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pst") + ' Create an HTML file. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources() + ' Render messages from the "Inbox" folder and its subfolders. + viewOptions.OutlookOptions.Folder = "Inbox" + ' Render messages from a specific subfolder in the "Inbox" folder. + ' viewOptions.OutlookOptions.Folder = "Inbox\\Work\\Urgent"; + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ### Limit the number of folder items to render @@ -232,6 +359,25 @@ using (var viewer = new Viewer("sample.pst")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pst") + ' Create an HTML file. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources() + ' Specify the maximum number of folder items. + viewOptions.OutlookOptions.MaxItemsInFolder = 30 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ### Filter messages @@ -265,4 +411,24 @@ using (var viewer = new Viewer("sample.pst")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pst") + ' Create an HTML file. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources() + ' Set filters. + viewOptions.OutlookOptions.TextFilter = "Viewer" + viewOptions.OutlookOptions.AddressFilter = "groupdocs.com" + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/rendering-basics/render-pdf-documents.md b/net/rendering-basics/render-pdf-documents.md index 6835cf5..1ce785a 100644 --- a/net/rendering-basics/render-pdf-documents.md +++ b/net/rendering-basics/render-pdf-documents.md @@ -53,6 +53,24 @@ using (var viewer = new Viewer("resume.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.pdf") + ' Create an HTML file for each PDF page. + ' {0} is replaced with the current page number in the file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -84,6 +102,25 @@ using (var viewer = new Viewer("resume.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.pdf") + ' Create an HTML file for each PDF page. + ' Specify the HTML file names and location of external resources. + ' {0} and {1} are replaced with the current page number and resource name, respectively. + Dim viewOptions = HtmlViewOptions.ForExternalResources("page_{0}.html", "page_{0}/resource_{0}_{1}", "page_{0}/resource_{0}_{1}") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the result. External resources are placed in a separate folder. @@ -120,6 +157,26 @@ using (var viewer = new Viewer("Letter.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Letter.pdf") + ' Create an HTML file for each PDF page. + ' {0} is replaced with the current page number in the file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + ' Disable fixed layout. + viewOptions.PdfOptions.FixedLayout = False + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} {{< alert style="info" >}} @@ -160,6 +217,26 @@ using (var viewer = new Viewer("resume.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.pdf") + ' Create an HTML file for each document page. + ' {0} is replaced with the current page number in the file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + ' Set image quality to medium. + viewOptions.PdfOptions.ImageQuality = ImageQuality.Medium + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ### Render text as an image @@ -186,6 +263,26 @@ using (var viewer = new Viewer("resume.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.pdf") + ' Create an HTML file for each document page. + ' {0} is replaced with the current page number in the file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("text-as-image_{0}.html") + ' Enable rendering text as image. + viewOptions.PdfOptions.RenderTextAsImage = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below illustrates the result. PDF content is exported to HTML as an image, so users cannot select or copy document text. @@ -216,6 +313,26 @@ using (var viewer = new Viewer("sample.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pdf") + ' Create an HTML file for each document page. + ' {0} is replaced with the current page number in the file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + ' Enable the multi-layer rendering. + viewOptions.PdfOptions.EnableLayeredRendering = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Render PDF files as images @@ -243,6 +360,27 @@ using (var viewer = new Viewer("resume.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.pdf") + ' Create a PNG image for each PDF page. + ' {0} is replaced with the current page number in the image name. + Dim viewOptions = New PngViewOptions("output_{0}.png") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 900 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -272,6 +410,27 @@ using (var viewer = new Viewer("resume.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.pdf") + ' Create a JPEG image for each PDF page. + ' {0} is replaced with the current page number in the image name. + Dim viewOptions = New JpgViewOptions("output_{0}.jpg") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 900 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ### Preserve the size of document pages @@ -296,6 +455,26 @@ using (var viewer = new Viewer("resume.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.pdf") + ' Create a PNG image for each PDF page. + ' {0} is replaced with the current page number in the image name. + Dim viewOptions = New PngViewOptions("output_{0}.png") + ' Preserve the size of document pages. + viewOptions.PdfOptions.RenderOriginalPageSize = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ### Enable font hinting @@ -320,6 +499,26 @@ using (var viewer = new Viewer("resume.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.pdf") + ' Create a PNG image for each PDF page. + ' {0} is replaced with the current page number in the image name. + Dim viewOptions = New PngViewOptions("output_{0}.png") + 'Enable font hinting + viewOptions.PdfOptions.EnableFontHinting = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} Refer to the following article for more information on font hinting: [Font hinting](https://en.wikipedia.org/wiki/Font_hinting). @@ -346,6 +545,26 @@ using (var viewer = new Viewer("sample.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pdf") + ' Create an HTML file for each document page. + ' {0} is replaced with the current page number in the file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + ' Disable character grouping + viewOptions.PdfOptions.DisableCharsGrouping = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Render text comments @@ -372,6 +591,26 @@ using (var viewer = new Viewer("resume_commented.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume_commented.pdf") + ' Create a PNG image for each PDF page. + ' {0} is replaced with the current page number in the image name. + Dim viewOptions = New PngViewOptions("output_{0}.png") + ' Enable comments rendering. + viewOptions.RenderComments = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image illustrates the result: @@ -415,6 +654,36 @@ using (var viewer = new Viewer("resume.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.pdf") + Dim viewInfoOptions = ViewInfoOptions.ForHtmlView() + Dim viewInfo = TryCast(viewer.GetViewInfo(viewInfoOptions), PdfViewInfo) + + ' Display information about the PDF document. + Console.WriteLine($"File type: {viewInfo.FileType}") + Console.WriteLine($"The number of pages: {viewInfo.Pages.Count}") + Console.WriteLine($"Is printing allowed: {viewInfo.PrintingAllowed}") + + ' Display information about all document pages. + Console.WriteLine("Page information:") + For Each page As Page In viewInfo.Pages + ' The Page.ToString method is overriden to display the following page information: + ' "Page {Number} ({visibility}) {Width}x{Height}px with {Lines.Count} line(s)." + Console.WriteLine(page) + Next + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: @@ -449,6 +718,32 @@ using (var viewer = new Viewer("resume.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.pdf") + Dim viewInfoOptions = ViewInfoOptions.ForHtmlView() + viewInfoOptions.ExtractText = True + Dim viewInfo = TryCast(viewer.GetViewInfo(viewInfoOptions), PdfViewInfo) + + ' Retrieve text from the PDF file. + Console.WriteLine("Extracted document text:") + For Each page As Page In viewInfo.Pages + For Each line As Line In page.Lines + Console.WriteLine(line.Value) + Next + Next + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ![Extract and display PDF text](/viewer/net/images/rendering-basics/render-pdf-documents/extract-pdf-text.png) @@ -460,14 +755,35 @@ If an XPS or OXPS file contains a font that cannot be embedded due to licensing {{< tabs "example15">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("resume.oxps")) { HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); - options.PdfOptions.DisableFontLicenseVerifications = true; + viewOptions.PdfOptions.DisableFontLicenseVerifications = true; viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("resume.oxps") + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewOptions.PdfOptions.DisableFontLicenseVerifications = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Enclose images in SVG when rendering PDF and Page Layout files @@ -481,6 +797,10 @@ This option is available when rendering PDF and Page Layout file formats to HTML {{< tabs "example16">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("resume.pdf")) { HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); @@ -490,6 +810,24 @@ using (Viewer viewer = new Viewer("resume.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("resume.pdf") + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewOptions.PdfOptions.WrapImagesInSvg = True + + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows the rendering [resume.pdf](/viewer/net/images/rendering-basics/render-pdf-documents/resume.pdf) with the disabled (left) and enabled (right) `WrapImagesInSvg` option: @@ -513,6 +851,10 @@ This option is supported when rendering PDF files to HTML with embedded or exter {{< tabs "example17">}} {{< tab "C#" >}} ```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +// ... + using (Viewer viewer = new Viewer("protected-resume.pdf")) { HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); @@ -522,6 +864,24 @@ using (Viewer viewer = new Viewer("protected-resume.pdf")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer As Viewer = New Viewer("protected-resume.pdf") + Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources() + viewOptions.PdfOptions.DisableCopyProtection = True + + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows the rendering of [protected-resume.pdf](/viewer/net/images/rendering-basics/render-pdf-documents/protected-resume.pdf) with copy protection on the left and with with `DisableCopyProtection` option set to `true` on the right: diff --git a/net/rendering-basics/render-presentations.md b/net/rendering-basics/render-presentations.md index ea774ef..04bbeee 100644 --- a/net/rendering-basics/render-presentations.md +++ b/net/rendering-basics/render-presentations.md @@ -65,6 +65,24 @@ using (var viewer = new Viewer("sample.pptx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pptx") + ' Create an HTML file for each slide. + ' {0} is replaced with the current page number in the file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -97,6 +115,25 @@ using (var viewer = new Viewer("sample.pptx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pptx") + ' Create an HTML file for each slide. + ' Specify the HTML file names and location of external resources. + ' {0} and {1} are replaced with the current page number and resource name, respectively. + Dim viewOptions = HtmlViewOptions.ForExternalResources("page_{0}.html", "page_{0}/resource_{0}_{1}", "page_{0}/resource_{0}_{1}") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the result. External resources are placed in a separate folder. @@ -123,6 +160,24 @@ using (var viewer = new Viewer("sample.pptx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pptx") + ' Create a PDF file for the presentation. + ' Specify the PDF file name. + Dim viewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -152,6 +207,27 @@ using (var viewer = new Viewer("sample.pptx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pptx") + ' Create a PNG image for each slide. + ' {0} is replaced with the current page number in the image name. + Dim viewOptions = New PngViewOptions("output_{0}.png") + ' Set width and height. + viewOptions.Width = 950 + viewOptions.Height = 550 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -182,6 +258,27 @@ using (var viewer = new Viewer("sample.pptx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pptx") + ' Create a JPEG image for each slide. + ' {0} is replaced with the current page number in the image name. + Dim viewOptions = New JpgViewOptions("output_{0}.jpg") + ' Set width and height. + viewOptions.Width = 950 + viewOptions.Height = 550 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Specify image resolution @@ -218,6 +315,25 @@ using (var viewer = new Viewer("sample.pptx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pptx") + ' Convert the presentation to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Specify resolution. + viewOptions.PresentationOptions.Resolution = Resolution.Dpi150 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Render hidden slides @@ -243,6 +359,25 @@ using (var viewer = new Viewer("sample.pptx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pptx") + ' Convert the presentation to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Enable hidden slides rendering. + viewOptions.RenderHiddenPages = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Render comments @@ -266,6 +401,25 @@ using (var viewer = new Viewer("sample.pptx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pptx") + ' Convert the presentation to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Enable comments rendering. + viewOptions.RenderComments = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -299,6 +453,25 @@ using (var viewer = new Viewer("sample.pptx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.pptx") + ' Convert the presentation to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Enable speaker notes rendering. + viewOptions.RenderNotes = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the result. diff --git a/net/rendering-basics/render-spreadsheets/render-excel-and-apple-numbers-spreadsheets.md b/net/rendering-basics/render-spreadsheets/render-excel-and-apple-numbers-spreadsheets.md index 61bd6b0..826cb2e 100644 --- a/net/rendering-basics/render-spreadsheets/render-excel-and-apple-numbers-spreadsheets.md +++ b/net/rendering-basics/render-spreadsheets/render-excel-and-apple-numbers-spreadsheets.md @@ -79,6 +79,24 @@ using (var viewer = new Viewer("invoice.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("invoice.xlsx") + ' Convert the spreadsheet to HTML. + ' {0} is replaced with the current page number in the file names. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -103,6 +121,24 @@ using (var viewer = new Viewer("Products.numbers")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Products.numbers") + ' Convert the spreadsheet to HTML. + ' {0} is replaced with the current page number in the file names. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -136,6 +172,25 @@ using (var viewer = new Viewer("invoice.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("invoice.xlsx") + ' Convert the spreadsheet to HTML. + ' Specify the HTML file names and location of external resources. + ' {0} and {1} are replaced with the current page number and resource name, respectively. + Dim viewOptions = HtmlViewOptions.ForExternalResources("page_{0}.html", "page_{0}/resource_{0}_{1}", "page_{0}/resource_{0}_{1}") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} #### Convert an Apple Numbers spreadsheet to HTML @@ -157,6 +212,25 @@ using (var viewer = new Viewer("Products.numbers")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Products.numbers") + ' Convert the spreadsheet to HTML. + ' Specify the HTML file names and location of external resources. + ' {0} and {1} are replaced with the current page number and resource name, respectively. + Dim viewOptions = HtmlViewOptions.ForExternalResources("page_{0}.html", "page_{0}/resource_{0}_{1}", "page_{0}/resource_{0}_{1}") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the result. External resources are placed in a separate folder. @@ -185,6 +259,25 @@ using (var viewer = new Viewer("Personal_net_worth_calculator.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Personal_net_worth_calculator.xlsx") + ' Convert all Excel worksheets to one HTML file. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page.html") + ' Enable converting all worksheets to one file. + viewOptions.RenderToSinglePage = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -213,6 +306,23 @@ using (var viewer = new Viewer("invoice.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("invoice.xlsx") + ' Convert the spreadsheet to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -236,6 +346,23 @@ using (var viewer = new Viewer("Products.numbers")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Products.numbers") + ' Convert the spreadsheet to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -267,6 +394,27 @@ using (var viewer = new Viewer("invoice.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("invoice.xlsx") + ' Convert the spreadsheet to PNG. + ' {0} is replaced with the current page number in the file names. + Dim viewOptions = New PngViewOptions("output_{0}.png") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 900 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -293,6 +441,27 @@ using (var viewer = new Viewer("Products.numbers")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Products.numbers") + ' Convert the spreadsheet to PNG. + ' {0} is replaced with the current page number in the file names. + Dim viewOptions = New PngViewOptions("output_{0}.png") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 900 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -324,6 +493,27 @@ using (var viewer = new Viewer("invoice.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("invoice.xlsx") + ' Convert the spreadsheet to JPEG. + ' {0} is replaced with the current page number in the file names. + Dim viewOptions = New JpgViewOptions("output_{0}.jpg") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 900 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ### Convert an Apple Numbers spreadsheet to JPEG @@ -347,6 +537,27 @@ using (var viewer = new Viewer("Products.numbers")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Products.numbers") + ' Convert the spreadsheet to JPEG. + ' {0} is replaced with the current page number in the file names. + Dim viewOptions = New JpgViewOptions("output_{0}.jpg") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 900 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Detect a CSV/TSV separator @@ -376,6 +587,26 @@ using (var viewer = new Viewer("sample.csv")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.csv") + ' Convert the spreadsheet to HTML. + ' {0} is replaced with the current page number in the file names. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + ' Detect a CSV/TSV separator. + viewOptions.SpreadsheetOptions.DetectSeparator = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Get worksheet names @@ -411,6 +642,32 @@ using (var viewer = new Viewer("sample.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +Imports GroupDocs.Viewer.Results +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.xlsx") + Dim viewInfoOptions = ViewInfoOptions.ForHtmlView() + ' Call this method to create a single page for each worksheet. + viewInfoOptions.SpreadsheetOptions = SpreadsheetOptions.ForOnePagePerSheet() + + Dim viewInfo = viewer.GetViewInfo(viewInfoOptions) + + ' Print the worksheet names in the console window. + Console.WriteLine("The document contains the following worksheets:") + For Each page As Page In viewInfo.Pages + Console.WriteLine($" - Worksheet {page.Number}: '{page.Name}'") + Next + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image shows a sample console output: diff --git a/net/rendering-basics/render-spreadsheets/specify-rendering-options.md b/net/rendering-basics/render-spreadsheets/specify-rendering-options.md index a1c37ed..37df9c8 100644 --- a/net/rendering-basics/render-spreadsheets/specify-rendering-options.md +++ b/net/rendering-basics/render-spreadsheets/specify-rendering-options.md @@ -51,6 +51,25 @@ using (var viewer = new Viewer("invoice.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("invoice.xlsx") + ' Convert the spreadsheet to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Render row and column headings. + viewOptions.SpreadsheetOptions.RenderHeadings = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -80,6 +99,25 @@ using (var viewer = new Viewer("invoice.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("invoice.xlsx") + ' Convert the spreadsheet to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Render grid lines. + viewOptions.SpreadsheetOptions.RenderGridLines = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -129,6 +167,25 @@ using (var viewer = new Viewer("invoice.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("invoice.xlsx") + ' Convert the spreadsheet to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Specify the AutoFitColumn mode. + viewOptions.SpreadsheetOptions.TextOverflowMode = TextOverflowMode.AutoFitColumn + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Render hidden rows and columns @@ -157,6 +214,26 @@ using (var viewer = new Viewer("invoice.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("invoice.xlsx") + ' Convert the spreadsheet to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Enable rendering hidden rows and columns. + viewOptions.SpreadsheetOptions.RenderHiddenRows = True + viewOptions.SpreadsheetOptions.RenderHiddenColumns = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the result. Hidden rows and columns appear in the generated PDF file. @@ -186,6 +263,25 @@ using (var viewer = new Viewer("invoice.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("invoice.xlsx") + ' Convert the spreadsheet to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Enable rendering hidden pages. + viewOptions.RenderHiddenPages = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Skip empty rows and columns @@ -210,6 +306,26 @@ using (var viewer = new Viewer("invoice.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("invoice.xlsx") + ' Convert the spreadsheet to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Enable skipping blank rows and columns. + viewOptions.SpreadsheetOptions.SkipEmptyRows = True + viewOptions.SpreadsheetOptions.SkipEmptyColumns = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -238,6 +354,26 @@ using (var viewer = new Viewer("invoice.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("invoice.xlsx") + ' Convert the spreadsheet to PNG. + ' {0} is replaced with the current page number in the file names. + Dim viewOptions = New PngViewOptions("output_{0}.png") + ' Enable rendering comments. + viewOptions.RenderComments = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -271,6 +407,29 @@ using (var viewer = new Viewer("invoice.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("invoice.xlsx") + Dim viewOptions = New PdfViewOptions("output.pdf") + + ' Set margins for worksheets in the output pdf pages + viewOptions.SpreadsheetOptions.LeftMargin = 0 + viewOptions.SpreadsheetOptions.RightMargin = 0.5 + viewOptions.SpreadsheetOptions.TopMargin = 1 + viewOptions.SpreadsheetOptions.BottomMargin = -10 ' set to default value + + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: diff --git a/net/rendering-basics/render-spreadsheets/split-worksheet-into-pages.md b/net/rendering-basics/render-spreadsheets/split-worksheet-into-pages.md index ca6fde2..f7b05bd 100644 --- a/net/rendering-basics/render-spreadsheets/split-worksheet-into-pages.md +++ b/net/rendering-basics/render-spreadsheets/split-worksheet-into-pages.md @@ -41,6 +41,25 @@ using (var viewer = new Viewer("products.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("products.xlsx") + ' Convert the spreadsheet to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Split using page breaks. + viewOptions.SpreadsheetOptions = SpreadsheetOptions.ForRenderingByPageBreaks() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below illustrates the result. @@ -70,6 +89,27 @@ using (var viewer = new Viewer("two-pages.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("two-pages.xlsx") + ' Specify number of rows for every page. + Dim rowsPerPage As Integer = 15 + ' Convert the spreadsheet to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Split by number of rows. + viewOptions.SpreadsheetOptions = SpreadsheetOptions.ForSplitSheetIntoPages(rowsPerPage) + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the output PDF file. @@ -100,6 +140,28 @@ using (var viewer = new Viewer("four-pages.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("four-pages.xlsx") + ' Specify number of rows and columns for every page. + Dim rowsPerPage As Integer = 15 + Dim columnsPerPage As Integer = 7 + ' Convert the spreadsheet to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Split by number of rows and columns. + viewOptions.SpreadsheetOptions = SpreadsheetOptions.ForSplitSheetIntoPages(rowsPerPage, columnsPerPage) + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the output PDF file. @@ -133,6 +195,25 @@ using (var viewer = new Viewer("invoice.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("invoice.xlsx") + ' Convert the spreadsheet to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Render the print area only. + viewOptions.SpreadsheetOptions = SpreadsheetOptions.ForRenderingPrintArea() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below illustrates the result. @@ -162,6 +243,25 @@ using (var viewer = new Viewer("Products.xlsx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("Products.xlsx") + ' Convert the spreadsheet to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Render each worksheet to one page. + viewOptions.SpreadsheetOptions = SpreadsheetOptions.ForOnePagePerSheet() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below illustrates the result. The output PDF file contains one page that displays all worksheet data. @@ -192,12 +292,30 @@ using GroupDocs.Viewer.Options; //render spreadsheet to PDF using (var viewer = new Viewer("products.xlsx")) { - var viewOptions = new PdfViewOptions("output.pdf"); - viewOptions.SpreadsheetOptions = SpreadsheetOptions.ForRenderingPrintAreaAndPageBreaks(); - viewer.View(viewOptions); + var viewOptions = new PdfViewOptions("output.pdf"); + viewOptions.SpreadsheetOptions = SpreadsheetOptions.ForRenderingPrintAreaAndPageBreaks(); + viewer.View(viewOptions); } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + 'render spreadsheet to PDF + Using viewer = New Viewer("products.xlsx") + Dim viewOptions = New PdfViewOptions("output.pdf") + viewOptions.SpreadsheetOptions = SpreadsheetOptions.ForRenderingPrintAreaAndPageBreaks() + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below illustrates the result: diff --git a/net/rendering-basics/render-text-files.md b/net/rendering-basics/render-text-files.md index bd8f0a1..8c1b7f9 100644 --- a/net/rendering-basics/render-text-files.md +++ b/net/rendering-basics/render-text-files.md @@ -74,12 +74,12 @@ When you load a text document from a file or [FileStream](https://learn.microsof {{< tabs "example1">}} {{< tab "C#" >}} ```csharp +using System.IO; using GroupDocs.Viewer; using GroupDocs.Viewer.Options; // ... -// Implement a method that returns a stream with document data. -Stream stream = GetFileStream("markdown-file.md"); +Stream stream = GetFileStream("markdown-file.md"); //TODO: implement this method // Specify the file encoding. LoadOptions loadOptions = new LoadOptions(FileType.MD); @@ -92,6 +92,29 @@ using (var viewer = new Viewer(stream, loadOptions)) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports System.IO +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Dim stream As Stream = GetFileStream("markdown-file.md") 'TODO: implement this method + + ' Specify the file encoding. + Dim loadOptions As LoadOptions = New LoadOptions(FileType.MD) + + ' Convert the document to PDF. + Using viewer = New Viewer(stream, loadOptions) + Dim viewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Render text files as HTML @@ -118,6 +141,24 @@ using (var viewer = new Viewer("TermsOfService.txt")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("TermsOfService.txt") + ' Convert the text file to HTML. + ' {0} is replaced with the current page number in the output file names. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -149,6 +190,25 @@ using (var viewer = new Viewer("TermsOfService.txt")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("TermsOfService.txt") + ' Convert the text file to HTML. + ' Specify the output file names and location of external resources. + ' {0} and {1} are replaced with the current page number and resource name, respectively. + Dim viewOptions = HtmlViewOptions.ForExternalResources("page_{0}.html", "page_{0}/resource_{0}_{1}", "page_{0}/resource_{0}_{1}") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the result. External resources are placed in a separate folder. @@ -177,6 +237,26 @@ using (var viewer = new Viewer("TermsOfService.txt")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("TermsOfService.txt") + ' Convert the text file to HTML. + ' Specify the output file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html") + ' Render the file to a single page. + viewOptions.RenderToSinglePage = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Render text files as PDF @@ -198,6 +278,23 @@ using (var viewer = new Viewer("TermsOfService.txt")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("TermsOfService.txt") + ' Convert the text file to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -227,6 +324,27 @@ using (var viewer = new Viewer("TermsOfService.txt")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("TermsOfService.txt") + ' Convert the text file to PNG. + ' {0} is replaced with the current page number in the output image names. + Dim viewOptions = New PngViewOptions("output_{0}.png") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 900 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -256,6 +374,27 @@ using (var viewer = new Viewer("TermsOfService.txt")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("TermsOfService.txt") + ' Convert the text file to JPEG. + ' {0} is replaced with the current page number in the output image names. + Dim viewOptions = New JpgViewOptions("output_{0}.jpg") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 1000 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Specify rendering options @@ -293,6 +432,26 @@ using (var viewer = new Viewer("TermsOfService.txt")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("TermsOfService.txt") + ' Convert the text file to HTML. + ' {0} is replaced with the current page number in the output file names. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + ' Set the maximum number of rows per page. + viewOptions.TextOptions.MaxRowsPerPage = 30 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below illustrates the result: diff --git a/net/rendering-basics/render-visio-documents.md b/net/rendering-basics/render-visio-documents.md index 07f9cb7..b0e934a 100644 --- a/net/rendering-basics/render-visio-documents.md +++ b/net/rendering-basics/render-visio-documents.md @@ -65,6 +65,24 @@ using (var viewer = new Viewer("flowchart.vsdx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("flowchart.vsdx") + ' Create an HTML file for each drawing page. + ' {0} is replaced with the current page number in the file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -97,6 +115,25 @@ using (var viewer = new Viewer("flowchart.vsdx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("flowchart.vsdx") + ' Create an HTML file for each drawing page. + ' Specify the HTML file names and location of external resources. + ' {0} and {1} are replaced with the current page number and resource name, respectively. + Dim viewOptions = HtmlViewOptions.ForExternalResources("page_{0}.html", "page_{0}/resource_{0}_{1}", "page_{0}/resource_{0}_{1}") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the result. External resources are placed in a separate folder. @@ -123,6 +160,24 @@ using (var viewer = new Viewer("flowchart.vsdx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("flowchart.vsdx") + ' Create a PDF file for the document. + ' Specify the PDF file name. + Dim viewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -152,6 +207,27 @@ using (var viewer = new Viewer("flowchart.vsdx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("flowchart.vsdx") + ' Create a PNG image for each drawing page. + ' {0} is replaced with the current page number in the image name. + Dim viewOptions = New PngViewOptions("output_{0}.png") + ' Set width and height. + viewOptions.Width = 950 + viewOptions.Height = 800 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -180,6 +256,27 @@ using (var viewer = new Viewer("flowchart.vsdx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("flowchart.vsdx") + ' Create a JPEG image for each drawing page. + ' {0} is replaced with the current page number in the image name. + Dim viewOptions = New JpgViewOptions("output_{0}.jpg") + ' Set width and height. + viewOptions.Width = 950 + viewOptions.Height = 800 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Render only diagram shapes @@ -216,6 +313,27 @@ using (var viewer = new Viewer("map.vsdx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("map.vsdx") + ' Convert the Visio file to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Render the master shapes only. + viewOptions.VisioRenderingOptions.RenderFiguresOnly = True + ' Specify shape width in pixels. + viewOptions.VisioRenderingOptions.FigureWidth = 200 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the result. diff --git a/net/rendering-basics/render-web-documents.md b/net/rendering-basics/render-web-documents.md index 603df33..a58f8b0 100644 --- a/net/rendering-basics/render-web-documents.md +++ b/net/rendering-basics/render-web-documents.md @@ -51,6 +51,24 @@ using (var viewer = new Viewer("groupdocs-documentation.mhtml")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("groupdocs-documentation.mhtml") + ' Create a PDF file for the document. + ' Specify the PDF file name. + Dim viewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -77,6 +95,24 @@ using (var viewer = new Viewer("groupdocs-documentation.mhtml")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("groupdocs-documentation.mhtml") + ' Convert the web file to PNG. + ' {0} is replaced with the page numbers in the output image names. + Dim viewOptions = New PngViewOptions("output_{0}.png") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -103,6 +139,24 @@ using (var viewer = new Viewer("groupdocs-documentation.mhtml")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("groupdocs-documentation.mhtml") + ' Convert the web file to JPEG. + ' {0} is replaced with the page numbers in the output image names. + Dim viewOptions = New JpgViewOptions("output_{0}.jpg") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Convert CHM files to HTML @@ -131,6 +185,26 @@ using (var viewer = new Viewer("sample.chm")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.chm") + ' Convert the CHM file to HTML. + ' {0} is replaced with the page numbers in the output file names. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("chm_result_{0}.html") + ' Enable the following option to display all CHM content on a single HTML page. + ' options.RenderToSinglePage = true; + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -162,6 +236,25 @@ using (var viewer = new Viewer("sample.chm")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("sample.chm") + ' Convert the CHM file to HTML. + ' Specify the output file names and location of external resources. + ' {0} and {1} are replaced with the current page number and resource name, respectively. + Dim viewOptions = HtmlViewOptions.ForExternalResources("page_{0}.html", "page_{0}/resource_{0}_{1}", "page_{0}/resource_{0}_{1}") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} @@ -205,6 +298,28 @@ using (var viewer = new Viewer("groupdocs-documentation.mhtml")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("groupdocs-documentation.mhtml") + ' Convert the document to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Specify the size of page margins in points. + viewOptions.WebDocumentOptions.LeftMargin = 40 + viewOptions.WebDocumentOptions.RightMargin = 40 + viewOptions.WebDocumentOptions.TopMargin = 40 + viewOptions.WebDocumentOptions.BottomMargin = 40 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ### Set the output page size @@ -230,4 +345,23 @@ using (var viewer = new Viewer("groupdocs-documentation.mhtml")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("groupdocs-documentation.mhtml") + ' Convert the document to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Specify the page size. + viewOptions.WebDocumentOptions.PageSize = PageSize.A3 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} diff --git a/net/rendering-basics/render-word-documents.md b/net/rendering-basics/render-word-documents.md index 0e67b42..a52a2ae 100644 --- a/net/rendering-basics/render-word-documents.md +++ b/net/rendering-basics/render-word-documents.md @@ -60,6 +60,24 @@ using (var viewer = new Viewer("resume.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.docx") + ' Create an HTML file for each document page. + ' {0} is replaced with the current page number in the file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -91,6 +109,25 @@ using (var viewer = new Viewer("resume.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.docx") + ' Create an HTML file for each document page. + ' Specify the HTML file names and location of external resources. + ' {0} and {1} are replaced with the current page number and resource name, respectively. + Dim viewOptions = HtmlViewOptions.ForExternalResources("page_{0}.html", "page_{0}/resource_{0}_{1}", "page_{0}/resource_{0}_{1}") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The image below demonstrates the result. External resources are placed in a separate folder. @@ -117,6 +154,24 @@ using (var viewer = new Viewer("resume.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.docx") + ' Create a PDF file for the document. + ' Specify the PDF file name. + Dim viewOptions = New PdfViewOptions("output.pdf") + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -146,6 +201,27 @@ using (var viewer = new Viewer("resume.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.docx") + ' Create a PNG image for each document page. + ' {0} is replaced with the current page number in the image name. + Dim viewOptions = New PngViewOptions("output_{0}.png") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 900 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image demonstrates the result: @@ -174,6 +250,27 @@ using (var viewer = new Viewer("resume.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.docx") + ' Create a JPEG image for each document page. + ' {0} is replaced with the current page number in the image name. + Dim viewOptions = New JpgViewOptions("output_{0}.jpg") + ' Set width and height. + viewOptions.Width = 800 + viewOptions.Height = 900 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Define page margins @@ -215,6 +312,29 @@ using (var viewer = new Viewer("resume.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.docx") + ' Create an HTML file for each document page. + ' {0} is replaced with the current page number in the file name. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html") + ' Specify the size of page margins in points. + viewOptions.WordProcessingOptions.TopMargin = 72 + viewOptions.WordProcessingOptions.BottomMargin = 72 + viewOptions.WordProcessingOptions.LeftMargin = 54 + viewOptions.WordProcessingOptions.RightMargin = 54 + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} ## Render tracked changes @@ -245,6 +365,25 @@ using (var viewer = new Viewer("TrackChanges.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("TrackChanges.docx") + ' Convert the document to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Enable tracked changes rendering. + viewOptions.WordProcessingOptions.RenderTrackedChanges = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image illustrates the result: @@ -274,6 +413,25 @@ using (var viewer = new Viewer("resume.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.docx") + ' Convert the document to PDF. + Dim viewOptions = New PdfViewOptions("output.pdf") + ' Enable comments rendering. + viewOptions.RenderComments = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image illustrates the result: @@ -303,6 +461,25 @@ using (var viewer = new Viewer("resume.docx")) } ``` {{< /tab >}} +{{< tab "VB.NET">}} +```vb +Imports GroupDocs.Viewer +Imports GroupDocs.Viewer.Options +' ... + +Module Program + Sub Main(args As String()) + Using viewer = New Viewer("resume.docx") + ' Convert the document to HTML. + Dim viewOptions = HtmlViewOptions.ForEmbeddedResources() + ' Unlink table of contents. + viewOptions.WordProcessingOptions.UnlinkTableOfContents = True + viewer.View(viewOptions) + End Using + End Sub +End Module +``` +{{< /tab >}} {{< /tabs >}} The following image illustrates the result: