AsyncConverter.ConvertHtmlString
Overloads
ConvertHtmlString(String) | Converts the HTML string to a PDF and get the output PDF as byte array. |
ConvertHtmlString(String, HtmlConversionOptions) | Converts the HTML string to a PDF and get the output PDF as byte array. |
ConvertHtmlString(String, HtmlConversionOptions, Byte[]) | Converts the HTML string to a PDF and get the output PDF as byte array. |
ConvertHtmlString(String, String) | Converts the HTML string to a PDF of the given name. |
ConvertHtmlString(String, String, HtmlConversionOptions) | Converts the HTML string to a PDF of the given name. |
ConvertHtmlString(String)
Converts the HTML string to a PDF and get the output PDF as byte array.
public AsyncConversion ConvertHtmlString(string htmlString)
Function ConvertHtmlString(htmlString As String) As AsyncConversion
Parameters
- htmlString
- String
HTML string for conversion.
Returns
Returns a instance of AsyncConversion class that represents the status of conversion.
Licensing Info
This method is a DynamicPDF Converter feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Converter selected.
- A DynamicPDF Converter for .NET v3.X Developer license.
Examples
This example shows how to convert HTML string to PDF and get the output as byte array asynchronously.Imports System.IO
Imports ceTe.DynamicPDF.Conversion
Module Module1
Sub Main()
' create an instance of AsyncConverter
Dim converter As AsyncConverter = New AsyncConverter
Dim htmlString As String = "<html><head><title>ceTe software</title></head><body>DynamicPDF Converter</body></html>"
' Events to know if conversion completed successfully or not
AddHandler converter.Converted, AddressOf converter_Converted
AddHandler converter.ConversionError, AddressOf converter_ConversionError
' Call ConvertHtmlString method to start conversion asynchronously and Get the status of conversion
Dim asyncConversion As AsyncConversion = converter.ConvertHtmlString(htmlString)
While (True)
If (asyncConversion.Completed) Then
Dim MyData() As Byte =asyncConversion.GetOutputData()
Exit While
End If
End While
End Sub
Sub converter_Converted(ByVal sender As Object, ByVal e As ConvertedEventArgs)
Console.WriteLine("HTML string was converted successfully.")
End Sub
Sub converter_ConversionError(ByVal sender As Object, ByVal e As ConversionErrorEventArgs)
Console.WriteLine("Conversion failed for the following reason:")
Console.WriteLine("\"" + e.Exception.Message + " \ "")
End Sub
End Module
using System;
using System.IO;
using ceTe.DynamicPDF.Conversion;
class MyClass
{
static void Main()
{
// create an instance of AsyncConverter
AsyncConverter converter = new AsyncConverter();
string htmlString = "<html><head><title>ceTe software</title></head><body>DynamicPDF Converter</body></html>";
// Events to know if conversion completed successfully or not
converter.Converted += new ConvertedEventHandler(converter_Converted);
converter.ConversionError += new ConversionErrorEventHandler(converter_ConversionError);
// Call ConvertHtmlString method to start conversion asynchronously and Get the status of conversion
AsyncConversion asyncConversion = converter.ConvertHtmlString(htmlString);
while(true)
{
if (asyncConversion.Completed)
{
byte[] MyData = asyncConversion.GetOutputData();
break;
}
}
}
private static void converter_Converted(object sender, ConvertedEventArgs e)
{
Console.WriteLine("HTML string was converted successfully.");
}
private static void converter_ConversionError(object sender, ConversionErrorEventArgs e)
{
Console.WriteLine("HTML string conversion failed for the following reason:");
Console.WriteLine("\"" + e.Exception.Message + "\"");
}
}
ConvertHtmlString(String, HtmlConversionOptions)
Converts the HTML string to a PDF and get the output PDF as byte array.
public AsyncConversion ConvertHtmlString(string htmlString, HtmlConversionOptions options)
Function ConvertHtmlString(htmlString As String, options As HtmlConversionOptions) As AsyncConversion
Parameters
- htmlString
- String
HTML string for conversion.
- options
- HtmlConversionOptions
Instance of HtmlConversionOptions class that represents the HTML string conversion options.
Returns
Returns a instance of AsyncConversion class that represents the status of conversion.
Licensing Info
This method is a DynamicPDF Converter feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Converter selected.
- A DynamicPDF Converter for .NET v3.X Developer license.
Examples
This example shows how to convert HTML string to PDF and get the output as byte array asynchronously.Imports System.IO
Imports ceTe.DynamicPDF.Conversion
Module Module1
Sub Main()
' create an instance of AsyncConverter
Dim converter As AsyncConverter = New AsyncConverter
Dim htmlString As String = "<html><head><title>ceTe software</title></head><body>DynamicPDF Converter</body></html>"
' create an instance of HtmlConversionOptions class.
Dim htmlConversionOptions As HtmlConversionOptions = new HtmlConversionOptions(PageSize.Letter,PageOrientation.Portrait, 50)
' Events to know if conversion completed successfully or not
AddHandler converter.Converted, AddressOf converter_Converted
AddHandler converter.ConversionError, AddressOf converter_ConversionError
' Call ConvertHtmlString method to start conversion asynchronously and Get the status of conversion
Dim asyncConversion As AsyncConversion = converter.ConvertHtmlString(htmlString,htmlConversionOptions)
While (True)
If (asyncConversion.Completed) Then
Dim MyData() As Byte =asyncConversion.GetOutputData()
Exit While
End If
End While
End Sub
Sub converter_Converted(ByVal sender As Object, ByVal e As ConvertedEventArgs)
Console.WriteLine("HTML string was converted successfully.")
End Sub
Sub converter_ConversionError(ByVal sender As Object, ByVal e As ConversionErrorEventArgs)
Console.WriteLine("Conversion failed for the following reason:")
Console.WriteLine("\"" + e.Exception.Message + " \ "")
End Sub
End Module
using System;
using System.IO;
using ceTe.DynamicPDF.Conversion;
class MyClass
{
static void Main()
{
// create an instance of AsyncConverter
AsyncConverter converter = new AsyncConverter();
string htmlString = "<html><head><title>ceTe software</title></head><body>DynamicPDF Converter</body></html>";
// create an instance of HtmlConversionOptions class.
HtmlConversionOptions htmlConversionOptions = new HtmlConversionOptions(PageSize.Letter,PageOrientation.Portrait, 50);
// Events to know if conversion completed successfully or not
converter.Converted += new ConvertedEventHandler(converter_Converted);
converter.ConversionError += new ConversionErrorEventHandler(converter_ConversionError);
// Call ConvertHtmlString method to start conversion asynchronously and Get the status of conversion
AsyncConversion asyncConversion = converter.ConvertHtmlString(htmlString,htmlConversionOptions);
while(true)
{
if (asyncConversion.Completed)
{
byte[] MyData = asyncConversion.GetOutputData();
break;
}
}
}
private static void converter_Converted(object sender, ConvertedEventArgs e)
{
Console.WriteLine("HTML string was converted successfully.");
}
private static void converter_ConversionError(object sender, ConversionErrorEventArgs e)
{
Console.WriteLine("HTML string conversion failed for the following reason:");
Console.WriteLine("\"" + e.Exception.Message + "\"");
}
}
ConvertHtmlString(String, HtmlConversionOptions, Byte[])
Converts the HTML string to a PDF and get the output PDF as byte array.
public AsyncConversion ConvertHtmlString(string htmlString, HtmlConversionOptions options, Byte[] appendToPdf)
Function ConvertHtmlString(htmlString As String, options As HtmlConversionOptions, appendToPdf As Byte()) As AsyncConversion
Parameters
- htmlString
- String
HTML string for conversion.
- options
- HtmlConversionOptions
Instance of HtmlConversionOptions class that represents the HTML string conversion options.
- appendToPdf
- Byte[]
Byte array of existing PDF to which output to be appended.
Returns
Returns a instance of AsyncConversion class that represents the status of conversion.
Licensing Info
This method is a DynamicPDF Converter feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Converter selected.
- A DynamicPDF Converter for .NET v3.X Developer license.
Examples
This example shows how to convert HTML string to PDF and get the output as byte array asynchronously.Imports System.IO
Imports ceTe.DynamicPDF.Conversion
Module Module1
Sub Main()
' create an instance of AsyncConverter
Dim converter As AsyncConverter = New AsyncConverter
Dim htmlString As String = "<html><head><title>ceTe software</title></head><body>DynamicPDF Converter</body></html>"
' create an instance of HtmlConversionOptions class.
Dim htmlConversionOptions As HtmlConversionOptions = new HtmlConversionOptions(PageSize.Letter,PageOrientation.Portrait,50, 50,True)
Dim appendToPdf() As Byte = File.ReadAllBytes("C:\MyDocument.pdf")
' Events to know if conversion completed successfully or not
AddHandler converter.Converted, AddressOf converter_Converted
AddHandler converter.ConversionError, AddressOf converter_ConversionError
' Call ConvertHtmlString method to start conversion asynchronously and Get the status of conversion
Dim asyncConversion As AsyncConversion = converter.ConvertHtmlString(htmlString, htmlConversionOptions, appendToPdf)
While (True)
If (asyncConversion.Completed) Then
Dim MyData() As Byte =asyncConversion.GetOutputData()
Exit While
End If
End While
End Sub
Sub converter_Converted(ByVal sender As Object, ByVal e As ConvertedEventArgs)
Console.WriteLine("HTML string was converted successfully.")
End Sub
Sub converter_ConversionError(ByVal sender As Object, ByVal e As ConversionErrorEventArgs)
Console.WriteLine("HTML string Conversion failed for the following reason:")
Console.WriteLine("\"" + e.Exception.Message + " \ "")
End Sub
End Module
using System;
using System.IO;
using ceTe.DynamicPDF.Conversion;
class MyClass
{
static void Main()
{
// create an instance of AsyncConverter
AsyncConverter converter = new AsyncConverter();
string htmlString = "<html><head><title>ceTe software</title></head><body>DynamicPDF Converter</body></html>";
// create an instance of HtmlConversionOptions class.
HtmlConversionOptions htmlConversionOptions = new HtmlConversionOptions(PageSize.Letter,PageOrientation.Portrait, 50,50,true);
byte[] appendToPdf = File.ReadAllBytes(@"C:\MyDocument.pdf");
// Events to know if conversion completed successfully or not
converter.Converted += new ConvertedEventHandler(converter_Converted);
converter.ConversionError += new ConversionErrorEventHandler(converter_ConversionError);
// Call ConvertHtmlString method to start conversion asynchronously and Get the status of conversion
AsyncConversion asyncConversion = converter.ConvertHtmlString(htmlString, htmlConversionOptions,appendToPdf);
while(true)
{
if (asyncConversion.Completed)
{
byte[] MyData = asyncConversion.GetOutputData();
break;
}
}
}
private static void converter_Converted(object sender, ConvertedEventArgs e)
{
Console.WriteLine(" HTML string was converted successfully.");
}
private static void converter_ConversionError(object sender, ConversionErrorEventArgs e)
{
Console.WriteLine(" HTML string conversion failed for the following reason:");
Console.WriteLine("\"" + e.Exception.Message + "\"");
}
}
ConvertHtmlString(String, String)
Converts the HTML string to a PDF of the given name.
public AsyncConversion ConvertHtmlString(string htmlString, string outputFilePath)
Function ConvertHtmlString(htmlString As String, outputFilePath As String) As AsyncConversion
Parameters
- htmlString
- String
HTML string for conversion.
- outputFilePath
- String
File path to store the converted pdf.
Returns
Returns a instance of AsyncConversion class that represents the status of conversion.
Licensing Info
This method is a DynamicPDF Converter feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Converter selected.
- A DynamicPDF Converter for .NET v3.X Developer license.
Examples
This example shows how to convert HTML string to PDF asynchronously.Imports System.IO
Imports ceTe.DynamicPDF.Conversion
Module Module1
Sub Main()
' create an instance of AsyncConverter
Dim converter As AsyncConverter = New AsyncConverter
Dim htmlString As String = "<html><head><title>ceTe software</title></head><body>DynamicPDF Converter</body></html>"
' Events to know if conversion completed successfully or not
AddHandler converter.Converted, AddressOf converter_Converted
AddHandler converter.ConversionError, AddressOf converter_ConversionError
' Call ConvertHtmlString method to start conversion asynchronously and Get the status of conversion
Dim asyncConversion As AsyncConversion = converter.ConvertHtmlString(htmlString,"C:\MyDocument.pdf")
While (True)
If(asyncConversion.Aborted Or asyncConversion.Exception IsNot Nothing) Then
Exit While
ElseIf(asyncConversion.Completed) Then
Exit While
End If
End While
End Sub
Sub converter_Converted(ByVal sender As Object, ByVal e As ConvertedEventArgs)
Console.WriteLine("HTML string was converted successfully.")
End Sub
Sub converter_ConversionError(ByVal sender As Object, ByVal e As ConversionErrorEventArgs)
Console.WriteLine("Conversion failed for the following reason:")
Console.WriteLine("\"" + e.Exception.Message + " \ "")
End Sub
End Module
using System;
using System.IO;
using ceTe.DynamicPDF.Conversion;
class MyClass
{
static void Main()
{
// create an instance of AsyncConverter
AsyncConverter converter = new AsyncConverter();
string htmlString = "<html><head><title>ceTe software</title></head><body>DynamicPDF Converter</body></html>";
// Events to know if conversion completed successfully or not
converter.Converted += new ConvertedEventHandler(converter_Converted);
converter.ConversionError += new ConversionErrorEventHandler(converter_ConversionError);
// Call ConvertHtmlString method to start conversion asynchronously and Get the status of conversion
AsyncConversion asyncConversion = converter.ConvertHtmlString(htmlString, "C:\MyDocument.Pdf");
while(true)
{
if(asyncConversion.Aborted ||asyncConversion.Exception== null)
{
break;
}
else if (asyncConversion.Completed)
{
break;
}
}
}
private static void converter_Converted(object sender, ConvertedEventArgs e)
{
Console.WriteLine("HTML string was converted successfully.");
}
private static void converter_ConversionError(object sender, ConversionErrorEventArgs e)
{
Console.WriteLine("conversion failed for the following reason:");
Console.WriteLine("\"" + e.Exception.Message + "\"");
}
}
ConvertHtmlString(String, String, HtmlConversionOptions)
Converts the HTML string to a PDF of the given name.
public AsyncConversion ConvertHtmlString(string htmlString, string outputFilePath, HtmlConversionOptions options)
Function ConvertHtmlString(htmlString As String, outputFilePath As String, options As HtmlConversionOptions) As AsyncConversion
Parameters
- htmlString
- String
HTML string for conversion.
- outputFilePath
- String
File path to store the converted pdf.
- options
- HtmlConversionOptions
Instance of HtmlConversionOptions class that represents the HTML string conversion options.
Returns
Returns a instance of AsyncConversion class that represents the status of conversion.
Licensing Info
This method is a DynamicPDF Converter feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Converter selected.
- A DynamicPDF Converter for .NET v3.X Developer license.
Examples
This example shows how to convert HTML string to PDF asynchronously.Imports System.IO
Imports ceTe.DynamicPDF.Conversion
Module Module1
Sub Main()
' create an instance of AsyncConverter
Dim converter As AsyncConverter = New AsyncConverter
Dim htmlString As String = "<html><head><title>ceTe software</title></head><body>DynamicPDF Converter</body></html>"
' create an instance of HtmlConversionOptions class.
Dim htmlConversionOptions As HtmlConversionOptions = new HtmlConversionOptions(PageSize.Letter,PageOrientation.Portrait, 50)
' Events to know if conversion completed successfully or not
AddHandler converter.Converted, AddressOf converter_Converted
AddHandler converter.ConversionError, AddressOf converter_ConversionError
' Call ConvertHtmlString method to start conversion asynchronously and Get the status of conversion
Dim asyncConversion As AsyncConversion = converter.ConvertHtmlString(htmlString,"C:\MyDocument.pdf", htmlConversionOptions)
While (True)
If(asyncConversion.Aborted Or asyncConversion.Exception IsNot Nothing) Then
Exit While
ElseIf(asyncConversion.Completed) Then
Exit While
End If
End While
End Sub
Sub converter_Converted(ByVal sender As Object, ByVal e As ConvertedEventArgs)
Console.WriteLine("HTML string was converted successfully.")
End Sub
Sub converter_ConversionError(ByVal sender As Object, ByVal e As ConversionErrorEventArgs)
Console.WriteLine("Conversion failed for the following reason:")
Console.WriteLine("\"" + e.Exception.Message + " \ "")
End Sub
End Module
using System;
using System.IO;
using ceTe.DynamicPDF.Conversion;
class MyClass
{
static void Main()
{
// create an instance of AsyncConverter
AsyncConverter converter = new AsyncConverter();
string htmlString = "<html><head><title>ceTe software</title></head><body>DynamicPDF Converter</body></html>";
// create an instance of HtmlConversionOptions class.
HtmlConversionOptions htmlConversionOptions = new HtmlConversionOptions(PageSize.Letter,PageOrientation.Portrait, 50);
// Events to know if conversion completed successfully or not
converter.Converted += new ConvertedEventHandler(converter_Converted);
converter.ConversionError += new ConversionErrorEventHandler(converter_ConversionError);
// Call ConvertHtmlString method to start conversion asynchronously and Get the status of conversion
AsyncConversion asyncConversion = converter.ConvertHtmlString(htmlString, "C:\MyDocument.Pdf", htmlConversionOptions);
while(true)
{
if(asyncConversion.Aborted ||asyncConversion.Exception== null)
{
break;
}
else if (asyncConversion.Completed)
{
break;
}
}
}
private static void converter_Converted(object sender, ConvertedEventArgs e)
{
Console.WriteLine("HTML string was converted successfully.");
}
private static void converter_ConversionError(object sender, ConversionErrorEventArgs e)
{
Console.WriteLine("HTML string conversion failed for the following reason:");
Console.WriteLine("\"" + e.Exception.Message + "\"");
}
}