Converter.ConvertAsync
Overloads
ConvertAsync(String, String, [Optional] Uri, [Optional] ConversionOptions) | Does the Asynchronous conversion |
ConvertAsync(String, [Optional] Uri, [Optional] ConversionOptions) | Does the Asynchronous conversion |
ConvertAsync(Uri, [Optional] ConversionOptions) | Does the Asynchronous conversion |
ConvertAsync(Uri, String, [Optional] ConversionOptions) | Does the Asynchronous conversion |
ConvertAsync(String, String, [Optional] Uri, [Optional] ConversionOptions)
Does the Asynchronous conversion
public static Task<bool> ConvertAsync(string inputHtml, string outputPath, [Uri basePath = null], [ConversionOptions conversionOptions = null])
Shared Function ConvertAsync(inputHtml As String, outputPath As String, Optional basePath As Uri = null, Optional conversionOptions As ConversionOptions = null) As Task(Of Boolean)
Parameters
- inputHtml
- String
Content of the HTML source.
- outputPath
- String
Path where the output file needs to be saved
- basePath
- Uri
Base path to fetch HTML resorces like images, scripts etc. Relative links also resolved using this path.
- conversionOptions
- ConversionOptions
Initializes the ConversionOptions property of the class.
Returns
Licensing Info
This method is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:
- Any active DynamicPDF Subscription (Essentials, Professional, Professional Plus or Ultimate).
- A DynamicPDF HTML Converter for .NET v2.X Essentials license.
- It can also be used for free with a public link back to www.dynamicpdf.com and with the DynamicPDF Essentials message displaying on the bottom of each page.
Remarks
Html resources with an absolute or relative file path will be resolved only when a basePath is specified. These resources will be considered insecure and blocked if no basePath is specified.
ConvertAsync(String, [Optional] Uri, [Optional] ConversionOptions)
Does the Asynchronous conversion
public static Task<Byte[]> ConvertAsync(string inputHtml, [Uri basePath = null], [ConversionOptions conversionOptions = null])
Shared Function ConvertAsync(inputHtml As String, Optional basePath As Uri = null, Optional conversionOptions As ConversionOptions = null) As Task(Of Byte())
Parameters
- inputHtml
- String
Content of the HTML source.
- basePath
- Uri
Base path to fetch HTML resorces like images, scripts etc. Relative links also resolved using this path.
- conversionOptions
- ConversionOptions
Initializes the ConversionOptions property of the class.
Returns
output pdf in byte array format
Licensing Info
This method is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:
- Any active DynamicPDF Subscription (Essentials, Professional, Professional Plus or Ultimate).
- A DynamicPDF HTML Converter for .NET v2.X Essentials license.
- It can also be used for free with a public link back to www.dynamicpdf.com and with the DynamicPDF Essentials message displaying on the bottom of each page.
Remarks
Html resources with an absolute or relative file path will be resolved only when a basePath is specified. These resources will be considered insecure and blocked if no basePath is specified.
ConvertAsync(Uri, [Optional] ConversionOptions)
Does the Asynchronous conversion
public static Task<Byte[]> ConvertAsync(Uri uri, [ConversionOptions conversionOptions = null])
Shared Function ConvertAsync(uri As Uri, Optional conversionOptions As ConversionOptions = null) As Task(Of Byte())
Parameters
- uri
- Uri
Uniform Resource Identifier for the HTML page.
- conversionOptions
- ConversionOptions
Initializes the ConversionOptions property of the class.
Returns
output pdf in byte array format
Licensing Info
This method is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:
- Any active DynamicPDF Subscription (Essentials, Professional, Professional Plus or Ultimate).
- A DynamicPDF HTML Converter for .NET v2.X Essentials license.
- It can also be used for free with a public link back to www.dynamicpdf.com and with the DynamicPDF Essentials message displaying on the bottom of each page.
Examples
This example shows how to convert html converter using convertAsync method and uri and conversion options as parameters.Imports System
Imports ceTe.DynamicPDF.HtmlConverter
Imports System.Threading.Tasks
Imports System.IO
Module Program
Sub Main(args As String())
Dim var As Task = run()
var.Wait()
End Sub
Public Async Function run() As Task
' Create a instance of ConversionOptions
Dim conversionOptions As ConversionOptions = New ConversionOptions(PageSize.A3, PageOrientation.Portrait, 75)
' Call convert method to do conversion.
Dim pdfData As Byte() = Await Converter.ConvertAsync(New Uri("https://www.google.com/"))
If pdfData IsNot Nothing Then
File.WriteAllBytes("D:\\output.pdf", pdfData)
End If
End Function
End Module
using System;
using ceTe.DynamicPDF.Conversion;
class MyClass
{
static void Main()
{
var task = run();
task.Wait();
}
public static async Task run()
{
ConversionOptions options = new ConversionOptions(PageSize.A3, PageOrientation.Portrait, 75);
byte []pdfData= await Converter.ConvertAsync(new Uri("https://www.google.com/"));
if (pdfData != null)
{
File.WriteAllBytes(@"D:\output.pdf", pdfData);
}
}
}
ConvertAsync(Uri, String, [Optional] ConversionOptions)
Does the Asynchronous conversion
public static Task<bool> ConvertAsync(Uri uri, string outputPath, [ConversionOptions conversionOptions = null])
Shared Function ConvertAsync(uri As Uri, outputPath As String, Optional conversionOptions As ConversionOptions = null) As Task(Of Boolean)
Parameters
- uri
- Uri
Uniform Resource Identifier for the HTML page.
- outputPath
- String
Path where the output file needs to be saved
- conversionOptions
- ConversionOptions
Initializes the ConversionOptions property of the class.
Returns
Licensing Info
This method is a DynamicPDF HTML Converter feature. One of the following is required for non-evaluation usage:
- Any active DynamicPDF Subscription (Essentials, Professional, Professional Plus or Ultimate).
- A DynamicPDF HTML Converter for .NET v2.X Essentials license.
- It can also be used for free with a public link back to www.dynamicpdf.com and with the DynamicPDF Essentials message displaying on the bottom of each page.