Class HtmlToPdfConverter
Class which allows converting HTML to PDF.
Inheritance
Inherited Members
Namespace: Syncfusion.HtmlConverter
Assembly: Syncfusion.HtmlConverter.Base.dll
Syntax
public class HtmlToPdfConverter
Remarks
To know more details about HTML to PDF conversion refer this link.
Examples
//Initialize the HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Initialize the WebKit converter settings
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKit path
settings.WebKitPath = @"/QtBinaries/";
//Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://www.google.com");
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Initialize the HTML to PDF converter
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Initialize the WebKit converter settings
Dim settings As New WebKitConverterSettings()
'Set WebKit path
settings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings
'Convert URL to PDF
Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com")
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
Constructors
HtmlToPdfConverter()
Initializes a new instance of the HtmlToPdfConverter class.
Declaration
public HtmlToPdfConverter()
Remarks
To know more details about Blink rendering engine, refer this link.
Examples
//Initialize the HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://www.google.com");
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Initialize the HTML to PDF converter
Dim htmlConverter As New HtmlToPdfConverter()
'Convert URL to PDF
Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com")
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
HtmlToPdfConverter(HtmlRenderingEngine)
Initializes a new instance of the HtmlToPdfConverter class with specified RenderingEngine.
Declaration
public HtmlToPdfConverter(HtmlRenderingEngine renderingEngine)
Parameters
| Type | Name | Description |
|---|---|---|
| HtmlRenderingEngine | renderingEngine | Rendering Engine used for conversion |
Remarks
To know more details about HTML to PDF converter, refer this link.
Examples
//Initialize the HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Initialize the WebKit converter settings
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKit path
settings.WebKitPath = @"/QtBinaries/";
//Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://www.google.com");
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Initialize the HTML to PDF converter
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Initialize the WebKit converter settings
Dim settings As New WebKitConverterSettings()
'Set WebKit path
settings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings
'Convert URL to PDF
Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com")
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
Properties
ConverterSettings
Gets or sets rendering engine settings.
Declaration
public IHtmlConverterSettings ConverterSettings { get; set; }
Property Value
| Type | Description |
|---|---|
| IHtmlConverterSettings | Specifies rendering engine settings. |
Remarks
To know more details about converter settings, refer this link.
Examples
//Initialize the HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Initialize the WebKit converter settings
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKit path
settings.WebKitPath = @"/QtBinaries/";
//Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://www.google.com");
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Initialize the HTML to PDF converter
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Initialize the WebKit converter settings
Dim settings As New WebKitConverterSettings()
'Set WebKit path
settings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings
'Convert URL to PDF
Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com")
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
RenderingEngine
Gets or sets the rendering engine used for conversion.
Declaration
public HtmlRenderingEngine RenderingEngine { get; set; }
Property Value
| Type | Description |
|---|---|
| HtmlRenderingEngine | Specifies rendering engine (Default IE rendering engine). |
Examples
//Initialize the HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
//Set rendering engine for conversion
htmlConverter.RenderingEngine = HtmlRenderingEngine.WebKit;
//Initialize the WebKit converter settings
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKitPath
settings.WebKitPath = "/QtBinaries/";
//Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://www.google.com");
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Initialize the HTML to PDF converter
Dim htmlConverter As New HtmlToPdfConverter()
'Set rendering engine for conversion
htmlConverter.RenderingEngine = HtmlRenderingEngine.WebKit
'Initialize the WebKit converter settings
Dim settings As New WebKitConverterSettings()
'Set WebKitPath
settings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings
'Convert URL to PDF
Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com")
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
ReuseBrowserProcess
Gets or sets a value indicating whether browser process reuse is enabled. Browser process reuse can improve conversion performance by keeping the underlying browser process running between conversions.
Declaration
public bool ReuseBrowserProcess { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
Remarks
The chromium process will be running in background after every conversion. Should explicitly close the HtmlToPdfConverter, if this property is enabled.
Methods
Close()
Closes the browser process after conversions are completed.
Declaration
public void Close()
Remarks
Should explicitly close the HtmlToPdfConverter, if ReuseBrowserProcess property in enabled.
Convert(String)
Converts URL to PDF document
Declaration
public PdfDocument Convert(string url)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | Path to the HTML resource. |
Returns
| Type | Description |
|---|---|
| PdfDocument | The PDF document |
Examples
//Initialize the HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Initialize the WebKit converter settings
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKit path
settings.WebKitPath = @"/QtBinaries/";
//Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://www.google.com");
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Initialize the HTML to PDF converter
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Initialize the WebKit converter settings
Dim settings As New WebKitConverterSettings()
'Set WebKit path
settings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings
'Convert URL to PDF
Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com")
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
Convert(String, out PdfLayoutResult)
Converts URL to PDF document
Declaration
public PdfDocument Convert(string url, out PdfLayoutResult layoutResult)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | Path to the Html resource. |
| PdfLayoutResult | layoutResult | Layout result |
Returns
| Type | Description |
|---|---|
| PdfDocument | PDF document |
Remarks
To know more details about pdf layout result refer this link.
Examples
//Initialize the HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Initialize the WebKit converter settings
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKitPath
settings.WebKitPath = "/QtBinaries/";
//Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings;
//Initialize PDF layout result
PdfLayoutResult pdfLayoutResult = null;
//Convert URL to PDF and get PDF layout result
PdfDocument document = htmlConverter.Convert("https://www.google.com", out pdfLayoutResult);
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Initialize the HTML to PDF converter
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Initialize the WebKit converter settings
Dim settings As New WebKitConverterSettings()
'Set WebKitPath
settings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings
'Initialize PDF layout result
Dim pdfLayoutResult As PdfLayoutResult = Nothing
'Convert URL to PDF and get PDF layout result
Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com", pdfLayoutResult)
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
Convert(String, Single, Single, AspectRatio)
Converts URL to PDF document
Declaration
public PdfDocument Convert(string url, float width, float height, AspectRatio aspectRatio)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | Path to the Html resource. |
| System.Single | width | Preferred width of the PDF page. |
| System.Single | height | Preferred height of the PDF page. |
| AspectRatio | aspectRatio | Aspect ratio of the PDF. |
Returns
| Type | Description |
|---|---|
| PdfDocument | PDF document |
Examples
//Initialize the HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Initialize the WebKit converter settings
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKitPath
settings.WebKitPath = "/QtBinaries/";
//Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://www.google.com", PdfPageSize.A4.Width, PdfPageSize.A4.Height, AspectRatio.None);
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Initialize the HTML to PDF converter
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Initialize the WebKit converter settings
Dim settings As New WebKitConverterSettings()
'Set WebKitPath
settings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings
'Convert URL to PDF
Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com", PdfPageSize.A4.Width, PdfPageSize.A4.Height, AspectRatio.None)
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
Convert(String, Single, Single, AspectRatio, out PdfLayoutResult)
Converts URL to PDF document
Declaration
public PdfDocument Convert(string url, float width, float height, AspectRatio aspectRatio, out PdfLayoutResult layoutResult)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | Path to the Html resource. |
| System.Single | width | Preferred width of the PDF page. |
| System.Single | height | Preferred height of the PDF page. |
| AspectRatio | aspectRatio | Aspect ratio |
| PdfLayoutResult | layoutResult | Layout result |
Returns
| Type | Description |
|---|---|
| PdfDocument | PDF document |
Examples
//Initialize the HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Initialize the WebKit converter settings
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKitPath
settings.WebKitPath = "/QtBinaries/";
//Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings;
//Initialize PDF layout result
PdfLayoutResult pdfLayoutResult = null;
//Convert URL to PDF and get PDF layout result
PdfDocument document = htmlConverter.Convert("https://www.google.com", PdfPageSize.A4.Width, PdfPageSize.A4.Height, AspectRatio.None, out pdfLayoutResult);
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Initialize the HTML to PDF converter
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Initialize the WebKit converter settings
Dim settings As New WebKitConverterSettings()
'Set WebKitPath
settings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to the HTML converter
htmlConverter.ConverterSettings = settings
'Initialize PDF layout result
Dim pdfLayoutResult As PdfLayoutResult = Nothing
'Convert URL to PDF and get PDF layout result
Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com", PdfPageSize.A4.Width, PdfPageSize.A4.Height, AspectRatio.None, pdfLayoutResult)
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
Convert(String, String)
Declaration
public PdfDocument Convert(string htmlString, string baseUrl)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | htmlString | |
| System.String | baseUrl |
Returns
| Type |
|---|
| PdfDocument |
Convert(String, String, out PdfLayoutResult)
Declaration
public PdfDocument Convert(string htmlString, string baseUrl, out PdfLayoutResult layoutResult)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | htmlString | |
| System.String | baseUrl | |
| PdfLayoutResult | layoutResult |
Returns
| Type |
|---|
| PdfDocument |
Convert(String, String, Single, Single, AspectRatio)
Declaration
public PdfDocument Convert(string htmlString, string baseUrl, float width, float height, AspectRatio aspectRatio)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | htmlString | |
| System.String | baseUrl | |
| System.Single | width | |
| System.Single | height | |
| AspectRatio | aspectRatio |
Returns
| Type |
|---|
| PdfDocument |
Convert(String, String, Single, Single, AspectRatio, out PdfLayoutResult)
Declaration
public PdfDocument Convert(string htmlString, string baseUrl, float width, float height, AspectRatio aspectRatio, out PdfLayoutResult layoutResult)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | htmlString | |
| System.String | baseUrl | |
| System.Single | width | |
| System.Single | height | |
| AspectRatio | aspectRatio | |
| PdfLayoutResult | layoutResult |
Returns
| Type |
|---|
| PdfDocument |
ConvertPartialHtml(String, String)
Converts URL to PDF document
Declaration
public PdfDocument ConvertPartialHtml(string url, string htmlElementID)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | Path to the HTML resource. |
| System.String | htmlElementID | Used to convert particular part of a HTML page to PDF |
Returns
| Type | Description |
|---|---|
| PdfDocument | The PDF document |
Remarks
To know more details about partial HTML to PDF conversion, refer this link.
Examples
//Initialize HTML converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
// WebKit converter settings
WebKitConverterSettings webKitSettings = new WebKitConverterSettings();
//Assign the WebKit binaries path
webKitSettings.WebKitPath = @"/QtBinaries/";
//Assign the WebKit settings
htmlConverter.ConverterSettings = webKitSettings;
//Convert Partial webpage to PDF using HTML element ID, here pic is an HTML element ID.
PdfDocument document = htmlConverter.ConvertPartialHtml("input.html", "pic");
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Initialize HTML converter
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
' WebKit converter settings
Dim webKitSettings As New WebKitConverterSettings()
'Assign the WebKit binaries path
webKitSettings.WebKitPath = "/QtBinaries/"
'Assign the WebKit settings
htmlConverter.ConverterSettings = webKitSettings
'Convert Partial webpage to PDF using HTML element ID, here pic is an HTML element ID.
Dim document As PdfDocument = htmlConverter.ConvertPartialHtml("input.html", "pic")
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
ConvertPartialHtml(String, String, out PdfLayoutResult)
Converts URL to PDF document
Declaration
public PdfDocument ConvertPartialHtml(string url, string htmlElementID, out PdfLayoutResult layoutResult)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | Path to the HTML resource. |
| System.String | htmlElementID | Used to convert particular part of a HTML page to PDF |
| PdfLayoutResult | layoutResult | Layout result |
Returns
| Type | Description |
|---|---|
| PdfDocument | The PDF document |
Remarks
To know more details about partial HTML to PDF conversion, refer this link.
Examples
//Initialize HTML converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
// WebKit converter settings
WebKitConverterSettings webKitSettings = new WebKitConverterSettings();
//Assign the WebKit binaries path
webKitSettings.WebKitPath = @"/QtBinaries/";
//Assign the WebKit settings
htmlConverter.ConverterSettings = webKitSettings;
//Initialize PDF layout result
PdfLayoutResult pdfLayoutResult = null;
//Convert partial HTML to PDF and get PDF layout result
PdfDocument document = htmlConverter.ConvertPartialHtml("input.html", "pic", out pdfLayoutResult);
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Initialize HTML converter
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
' WebKit converter settings
Dim webKitSettings As New WebKitConverterSettings()
'Assign the WebKit binaries path
webKitSettings.WebKitPath = "/QtBinaries/"
'Assign the WebKit settings
htmlConverter.ConverterSettings = webKitSettings
'Initialize PDF layout result
Dim pdfLayoutResult As PdfLayoutResult = Nothing
'Convert partial HTML to PDF and get PDF layout result
Dim document As PdfDocument = htmlConverter.ConvertPartialHtml("input.html", "pic", pdfLayoutResult)
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
ConvertPartialHtml(String, String, Single, Single, AspectRatio)
Converts URL to PDF document
Declaration
public PdfDocument ConvertPartialHtml(string url, string htmlElementID, float width, float height, AspectRatio aspectRatio)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | Path to the Html resource. |
| System.String | htmlElementID | Used to convert particular part of a HTML page to PDF |
| System.Single | width | Preferred width of the PDF page. |
| System.Single | height | Preferred height of the PDF page. |
| AspectRatio | aspectRatio | Aspect ratio of the PDF. |
Returns
| Type | Description |
|---|---|
| PdfDocument | PDF document |
Remarks
To know more details about partial HTML to PDF conversion, refer this link.
Examples
//Initialize HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Initialize WebKit converter settings
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKit path
settings.WebKitPath = @"/QtBinaries/";
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF
PdfDocument document = htmlConverter.ConvertPartialHtml("input.html", "pic", PdfPageSize.A4.Width, PdfPageSize.A4.Height, AspectRatio.None);
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Initialize HTML to PDF converter
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Initialize WebKit converter settings
Dim settings As New WebKitConverterSettings()
'Set WebKit path
settings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings
'Convert URL to PDF
Dim document As PdfDocument = htmlConverter.ConvertPartialHtml("input.html", "pic", PdfPageSize.A4.Width, PdfPageSize.A4.Height, AspectRatio.None)
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
ConvertPartialHtml(String, String, Single, Single, AspectRatio, out PdfLayoutResult)
Converts URL to PDF document
Declaration
public PdfDocument ConvertPartialHtml(string url, string htmlElementID, float width, float height, AspectRatio aspectRatio, out PdfLayoutResult layoutResult)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | Path to the Html resource. |
| System.String | htmlElementID | Used to convert particular part of a HTML page to PDF |
| System.Single | width | Preferred width of the PDF page. |
| System.Single | height | Preferred height of the PDF page. |
| AspectRatio | aspectRatio | Aspect ratio of the PDF. |
| PdfLayoutResult | layoutResult | Layout result |
Returns
| Type | Description |
|---|---|
| PdfDocument | PDF document |
Remarks
To know more details about partial HTML to PDF conversion, refer this link.
Examples
//Initialize HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Initialize WebKit converter settings
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKit path
settings.WebKitPath = @"/QtBinaries/";
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings;
//Initialize PDF layout result
PdfLayoutResult pdfLayoutResult = null;
//Convert URL to PDF and get PDF layout result
PdfDocument document = htmlConverter.ConvertPartialHtml("input.html", "pic", PdfPageSize.A4.Width, PdfPageSize.A4.Height, AspectRatio.None, out pdfLayoutResult);
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Initialize HTML to PDF converter
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Initialize WebKit converter settings
Dim settings As New WebKitConverterSettings()
'Set WebKit path
settings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings
'Initialize PDF layout result
Dim pdfLayoutResult As PdfLayoutResult = Nothing
'Convert URL to PDF and get PDF layout result
Dim document As PdfDocument = htmlConverter.ConvertPartialHtml("input.html", "pic", PdfPageSize.A4.Width, PdfPageSize.A4.Height, AspectRatio.None, pdfLayoutResult)
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
ConvertPartialHtml(String, String, String)
Declaration
public PdfDocument ConvertPartialHtml(string htmlString, string baseUrl, string htmlElementID)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | htmlString | |
| System.String | baseUrl | |
| System.String | htmlElementID |
Returns
| Type |
|---|
| PdfDocument |
ConvertPartialHtml(String, String, String, out PdfLayoutResult)
Declaration
public PdfDocument ConvertPartialHtml(string htmlString, string baseUrl, string htmlElementID, out PdfLayoutResult layoutResult)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | htmlString | |
| System.String | baseUrl | |
| System.String | htmlElementID | |
| PdfLayoutResult | layoutResult |
Returns
| Type |
|---|
| PdfDocument |
ConvertPartialHtml(String, String, String, Single, Single, AspectRatio)
Declaration
public PdfDocument ConvertPartialHtml(string htmlString, string baseUrl, string htmlElementID, float width, float height, AspectRatio aspectRatio)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | htmlString | |
| System.String | baseUrl | |
| System.String | htmlElementID | |
| System.Single | width | |
| System.Single | height | |
| AspectRatio | aspectRatio |
Returns
| Type |
|---|
| PdfDocument |
ConvertPartialHtml(String, String, String, Single, Single, AspectRatio, out PdfLayoutResult)
Declaration
public PdfDocument ConvertPartialHtml(string htmlString, string baseUrl, string htmlElementID, float width, float height, AspectRatio aspectRatio, out PdfLayoutResult layoutResult)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | htmlString | |
| System.String | baseUrl | |
| System.String | htmlElementID | |
| System.Single | width | |
| System.Single | height | |
| AspectRatio | aspectRatio | |
| PdfLayoutResult | layoutResult |
Returns
| Type |
|---|
| PdfDocument |
ConvertPartialHtmlToImage(String, String)
Converts URL to Image
Declaration
public Image[] ConvertPartialHtmlToImage(string url, string htmlElementID)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | Path to the Html resource. |
| System.String | htmlElementID | Used to convert particular part of a HTML page to image |
Returns
| Type | Description |
|---|---|
| System.Drawing.Image[] | Image Array |
Remarks
To know more details about partial HTML to Image conversion, refer this link.
Examples
//Initialize HTML converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
// WebKit converter settings
WebKitConverterSettings webKitSettings = new WebKitConverterSettings();
//Assign the WebKit binaries path
webKitSettings.WebKitPath = @"/QtBinaries/";
//Assign the WebKit settings
htmlConverter.ConverterSettings = webKitSettings;
//Convert Partial HTML to Image
Image[] image = htmlConverter.ConvertPartialHtmlToImage("input.html", "pic");
//Save Image
image[0].Save("Output.jpg");
'Initialize HTML converter
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
' WebKit converter settings
Dim webKitSettings As New WebKitConverterSettings()
'Assign the WebKit binaries path
webKitSettings.WebKitPath = "/QtBinaries/"
'Assign the WebKit settings
htmlConverter.ConverterSettings = webKitSettings
'Convert Partial HTML to Image
Dim image As Image() = htmlConverter.ConvertPartialHtmlToImage("input.html", "pic")
'Save Image
image(0).Save("Output.jpg")
See Also
ConvertPartialHtmlToImage(String, String, String)
Declaration
public Image[] ConvertPartialHtmlToImage(string htmlString, string baseUrl, string htmlElementID)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | htmlString | |
| System.String | baseUrl | |
| System.String | htmlElementID |
Returns
| Type |
|---|
| System.Drawing.Image[] |
ConvertPartialHtmlToSvg(String, String, Stream)
Converts an URL or local file to SVG and writes the converted SVG into a stream.
Declaration
public void ConvertPartialHtmlToSvg(string url, string htmlElementID, Stream outputStream)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | The URL or local file path of the HTML document to convert to SVG. |
| System.String | htmlElementID | Used to convert particular part of a HTML page to SVG |
| System.IO.Stream | outputStream |
Remarks
To know more details about HTML to Partial SVG conversion, refer this link.
Examples
//Initialize HTML converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
// WebKit converter settings
WebKitConverterSettings webKitSettings = new WebKitConverterSettings();
//Assign the WebKit binaries path
webKitSettings.WebKitPath = @"/QtBinaries/";
//Assign the WebKit settings
htmlConverter.ConverterSettings = webKitSettings;
Stream stream = new MemoryStream();
//Convert Partial HTML to SVG
htmlConverter.ConvertPartialHtmlToSvg("input.html", "pic", stream);
using (System.IO.FileStream output = new System.IO.FileStream(@"C:\MyOutput.svg", FileMode.Create))
{
stream.CopyTo(output);
}
stream.Dispose();
'Initialize HTML converter
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit
' WebKit converter settings
Dim webKitSettings As New WebKitConverterSettings()
'Assign the WebKit binaries path
webKitSettings.WebKitPath = "/QtBinaries/"
'Assign the WebKit settings
htmlConverter.ConverterSettings = webKitSettings
Dim stream As New MemoryStream()
'Convert Partial HTML to SVG
htmlConverter.ConvertPartialHtmlToSvg("input.html", "pic", stream)
File.WriteAllBytes("Sample.svg", stream.ToArray())
stream.Dispose()
See Also
ConvertPartialHtmlToSvg(String, String, String)
Converts an URL or local file to SVG and writes the converted SVG into a file.
Declaration
public void ConvertPartialHtmlToSvg(string url, string htmlElementID, string outputPath)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | The URL or local file path of the HTML document to convert to SVG. |
| System.String | htmlElementID | Used to convert particular part of a HTML page to SVG |
| System.String | outputPath | The path of the converted SVG file |
Remarks
To know more details about HTML to Partial SVG conversion, refer this link.
Examples
//Initialize HTML converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
// WebKit converter settings
WebKitConverterSettings webKitSettings = new WebKitConverterSettings();
//Assign the WebKit binaries path
webKitSettings.WebKitPath = @"/QtBinaries/";
//Assign the WebKit settings
htmlConverter.ConverterSettings = webKitSettings;
//Convert Partial HTML to SVG
htmlConverter.ConvertPartialHtmlToSvg("input.html", "pic", "Output.svg");
'Initialize HTML converter
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit
' WebKit converter settings
Dim webKitSettings As New WebKitConverterSettings()
'Assign the WebKit binaries path
webKitSettings.WebKitPath = "/QtBinaries/"
'Assign the WebKit settings
htmlConverter.ConverterSettings = webKitSettings
'Convert Partial HTML to SVG
htmlConverter.ConvertPartialHtmlToSvg("input.html", "pic", "Output.svg")
See Also
ConvertToImage(String)
Converts URL to Image
Declaration
public Image[] ConvertToImage(string url)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | Path to the Html resource. |
Returns
| Type | Description |
|---|---|
| System.Drawing.Image[] | Image Array |
Remarks
To know more details about HTML to Image conversion, refer this link.
Examples
//Initialize HTML converter with WebKit rendering engine
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
WebKitConverterSettings webKitSettings = new WebKitConverterSettings();
//Set WebKit path
webKitSettings.WebKitPath = @"/QtBinaries/";
//Assign WebKit settings to HTML converte
htmlConverter.ConverterSettings = webKitSettings;
//Convert URL to Image
Image[] image = htmlConverter.ConvertToImage("http://www.syncfusion.com");
//Save the image.
image[0].Save("Sample.jpg");
'Initialize HTML converter with WebKit rendering engine
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
Dim webKitSettings As New WebKitConverterSettings()
'Set WebKit path
webKitSettings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = webKitSettings
'Convert URL to Image
Dim image As Image() = htmlConverter.ConvertToImage("http://www.syncfusion.com ")
'Save the image
image(0).Save("Sample.jpg")
See Also
ConvertToImage(String, String)
Converts HTML string to Image
Declaration
public Image[] ConvertToImage(string htmlString, string baseUrl)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | htmlString | Html data. |
| System.String | baseUrl | Used to retrieve images, scripts and stylesheets. |
Returns
| Type | Description |
|---|---|
| System.Drawing.Image[] | Image Array |
Remarks
To know more details about HTML string to Image conversion, refer this link.
Examples
string htmlString = "Hello World!!!";
string baseURL = "";
//Initialize HTML converter with WebKit rendering engine
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
WebKitConverterSettings webKitSettings = new WebKitConverterSettings();
//Set WebKit path
webKitSettings.WebKitPath = @"/QtBinaries/";
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = webKitSettings;
//Convert HTML string to Image
Image[] image = htmlConverter.ConvertToImage(htmlString, baseURL);
//Save the image.
image[0].Save("Sample.jpg");
Dim htmlString As String = "Hello World!!!
Dim baseURL As String = ""
'Initialize HTML converter with WebKit rendering engine
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
Dim webKitSettings As New WebKitConverterSettings()
'Set WebKit path
webKitSettings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = webKitSettings
'Convert HTML string to Image
Dim image As Image() = htmlConverter.ConvertToImage(htmlString, baseURL)
'Save the image.
image(0).Save("Sample.jpg")
See Also
ConvertToMhtml(String, Stream)
Converts an URL or local file to MHTML and writes the converted MHTML into a stream.
Declaration
public void ConvertToMhtml(string url, Stream outputStream)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | The URL or local file path of the HTML document to convert to MHTML. |
| System.IO.Stream | outputStream |
Remarks
To know more details about HTML to MHTML conversion, refer this link.
Examples
Initialize HTML converter with WebKit rendering engine
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Initialize WebKit converter settings
WebKitConverterSettings webKitSettings = new WebKitConverterSettings();
//Set WebKit path
webKitSettings.WebKitPath = @"/QtBinaries/";
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = webKitSettings;
MemoryStream stream = new MemoryStream();
//Convert URL to MHTML
htmlConverter.ConvertToMhtml("http://www.syncfusion.com", stream);
using (FileStream output = new FileStream("MyOutput.mhtml", FileMode.Create))
{
stream.CopyTo(output);
}
stream.Dispose();
'Initialize HTML converter with WebKit rendering engine
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Initialize WebKit converter settings
Dim webKitSettings As New WebKitConverterSettings()
'Set WebKit path
webKitSettings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = webKitSettings
Dim stream As New MemoryStream()
'Convert URL to MHTML
htmlConverter.ConvertToMhtml("http://www.syncfusion.com", stream)
File.WriteAllBytes("Sample.mhtml", stream.ToArray())
stream.Dispose()
See Also
ConvertToMhtml(String, String)
Converts an URL or local file to MHTML and writes the converted MHTML into a file.
Declaration
public void ConvertToMhtml(string url, string outputPath)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | The URL or local file path of the HTML document to convert to MHTML. |
| System.String | outputPath | The path of the converted MHTML file. |
Examples
//Initialize HTML converter with WebKit rendering engine
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Initialize WebKit converter settings
WebKitConverterSettings webKitSettings = new WebKitConverterSettings();
//Set WebKit path
webKitSettings.WebKitPath = @"/QtBinaries/";
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = webKitSettings;
//Convert URL to MHTML
htmlConverter.ConvertToMhtml("http://www.syncfusion.com", "sample.mhtml");
'Initialize HTML converter with WebKit rendering engine
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Initialize WebKit converter settings
Dim webKitSettings As New WebKitConverterSettings()
'Set WebKit path
webKitSettings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = webKitSettings
'Convert URL to MHTML
htmlConverter.ConvertToMhtml("http://www.syncfusion.com", "sample.mhtml")
See Also
ConvertToSvg(String, Stream)
Converts an URL or local file to SVG and writes the converted SVG into a stream.
Declaration
public void ConvertToSvg(string url, Stream outputStream)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | The URL or local file path of the HTML document to convert to SVG. |
| System.IO.Stream | outputStream | The stream of the converted SVG file. |
Remarks
To know more details about HTML to Partial SVG conversion, refer this link.
Examples
//Initialize HTML converter with WebKit rendering engine
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
WebKitConverterSettings webKitSettings = new WebKitConverterSettings();
//Set WebKit path
webKitSettings.WebKitPath = @"/QtBinaries/";
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = webKitSettings;
Stream stream = new MemoryStream();
//Convert URL to SVG
htmlConverter.ConvertToSvg(url, stream);
using (System.IO.FileStream output = new System.IO.FileStream(@"C:\MyOutput.svg", FileMode.Create))
{
stream.CopyTo(output);
}
stream.Dispose();
'Initialize HTML converter with WebKit rendering engine
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Initialize WebKit converter settings
Dim webKitSettings As New WebKitConverterSettings()
'Set WebKit path
webKitSettings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = webKitSettings
Dim stream As New MemoryStream()
'Convert URL to SVG
htmlConverter.ConvertToSvg("http://www.syncfusion.com", stream)
File.WriteAllBytes("Sample.svg", stream.ToArray())
stream.Dispose()
See Also
ConvertToSvg(String, String)
Converts an URL or local file to SVG and writes the converted SVG into a file.
Declaration
public void ConvertToSvg(string url, string outputPath)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | The URL or local file path of the HTML document to convert to SVG. |
| System.String | outputPath | The path of the converted SVG file |
Remarks
To know more details about HTML to SVG conversion, refer this link.
Examples
//Initialize HTML converter with WebKit rendering engine
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
WebKitConverterSettings webKitSettings = new WebKitConverterSettings();
//Set WebKit path
webKitSettings.WebKitPath = @"/QtBinaries/";
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = webKitSettings;
//Convert URL to SVG
htmlConverter.ConvertToSvg("http://www.syncfusion.com", "sample.svg");
'Initialize HTML converter with WebKit rendering engine
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
Dim webKitSettings As New WebKitConverterSettings()
'Set WebKit path
webKitSettings.WebKitPath = "/QtBinaries/"
'Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = webKitSettings
'Convert URL to SVG
htmlConverter.ConvertToSvg("http://www.syncfusion.com", "sample.svg")
See Also
GetHtmlBounds(String)
Calculates and retrieves the dimensions (width and height) of the HTML content based on the current settings, such as viewport width and scale.
Declaration
public RectangleF GetHtmlBounds(string url)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | url | The URL or local file path of the HTML document to get the HTML size value. |
Returns
| Type |
|---|
| System.Drawing.RectangleF |
GetHtmlBounds(String, String)
Calculates and retrieves the dimensions (width and height) of the HTML content based on the current settings, such as viewport width and scale.
Declaration
public RectangleF GetHtmlBounds(string htmlString, string baseURL)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | htmlString | |
| System.String | baseURL |
Returns
| Type |
|---|
| System.Drawing.RectangleF |