 |
HtmlToPdf Class |
Html To Pdf Converter. This class offers the API needed to convert any web page url or html string to pdf.
Inheritance HierarchySystemObject
SelectPdf.UniversalHtmlToPdf
Namespace: SelectPdf.UniversalAssembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
SyntaxThe HtmlToPdf type exposes the following members.
Constructors
Properties| | Name | Description |
|---|
 | ConversionResult |
Gets a reference to an object that offers information about the result of the html to pdf conversion process.
|
 | Footer |
Gets a reference to an object that controls the properties of the custom footer of the generated pdf document.
|
 | Header |
Gets a reference to an object that controls the properties of the custom header of the generated pdf document.
|
 | Options |
Gets a reference to an object that controls the html to pdf conversion process and the generated pdf document properties.
|
Top
Methods| | Name | Description |
|---|
  | ConvertHtmlString(String) |
Renders the specified HTML string and returns the result as a PDF document.
|
  | ConvertHtmlString(String, String) |
Renders the specified HTML string, resolving relative resources against the given base URL,
and returns the result as a PDF document.
|
  | ConvertHtmlStringAsync(String) |
Asynchronously renders the specified HTML string and returns the result as a PDF document.
|
 | ConvertHtmlStringAsync(String, String) |
Asynchronously renders the specified HTML string, resolving relative resources against the
given base URL, and returns the result as a PDF document.
|
 | ConvertHtmlStringAsync(String, CancellationToken) |
Asynchronously renders the specified HTML string and returns the result as a PDF document,
stopping when the specified token is cancelled.
|
  | ConvertHtmlStringAsync(String, String, CancellationToken) |
Asynchronously renders the specified HTML string, resolving relative resources against the
given base URL, and returns the result as a PDF document, stopping when the specified token
is cancelled.
|
  | ConvertUrl |
Renders the web page at the specified URL and returns the result as a PDF document.
|
  | ConvertUrlAsync(String) |
Asynchronously renders the web page at the specified URL and returns the result as a PDF document.
|
  | ConvertUrlAsync(String, CancellationToken) |
Asynchronously renders the web page at the specified URL and returns the result as a PDF
document, stopping when the specified token is cancelled.
|
Top
Remarks
The result of conversion is a
PdfDocument object that can be further modified, saved to memory or into a file on the disk.
ExampleHtmlToPdf converter = new HtmlToPdf();
converter.Options.PdfPageSize = PdfPageSize.A4;
converter.Options.MarginLeft = 20;
converter.Options.MarginRight = 20;
PdfDocument doc = converter.ConvertUrl("https://www.google.com");
doc.Save("google.pdf");
doc.Close();Dim converter As New HtmlToPdf()
converter.Options.PdfPageSize = PdfPageSize.A4
converter.Options.MarginLeft = 20
converter.Options.MarginRight = 20
Dim doc As PdfDocument = converter.ConvertUrl("https://www.google.com")
doc.Save("google.pdf")
doc.Close()
See Also