[]
Provides methods for converting HTML to PDF and images.
This class is deprecated as of GcHtml v6.0.0. While old code that uses this and related classes will continue to work, it is recommended to switch to using the new GcHtmlBrowser class instead. For information on how to convert existing code please see documentation at https://www.grapecity.com/documents-api-pdf/docs/online/render_html_to_pdf.html and https://www.grapecity.com/documents-api-imaging/docs/online/render_html_to_image.html.
Note that the 3 platform-specific packages (GrapeCity.Documents.Html.Windows.X64, GrapeCity.Documents.Html.Linux.X64 and GrapeCity.Documents.Html.Mac.X64) are no longer needed and should be removed from your projects even if you do not convert your code to using GcHtmlBrowser.[Obsolete("Use GcHtmlBrowser class instead.")]
public class GcHtmlRenderer : IDisposable
Initializes a new instance of GcHtmlRenderer from HTML string.
public GcHtmlRenderer(string html)
html
stringThe HTML string to render.
Initializes a new instance of GcHtmlRenderer from System.Uri.
public GcHtmlRenderer(Uri htmlUri)
htmlUri
System.UriThe URI specifying the source HTML page.
Gets the last log message from the headless Chromium shell.
[ThreadStatic]
public static string LastLogMessage
Gets or sets a whitelist to passthrough Windows authentication for the specified domains.
For example: "*example.com,*foobar.com,*baz".
public string AuthServerWhitelist { get; set; }
Gets or sets the destination folder for the Chromium downloads.
If this property is not set, the downloads are stored to [root]/.local-chromium, where [root] is where the project binaries are located.
public static string BrowserDestinationFolder { get; set; }
Gets a value indicating whether the GcHtmlRenderer has been disposed of.
public bool IsDisposed { get; }
Gets a value indicating if GcHtmlRenderer is available on the current platform.
public static bool IsSupported { get; }
Gets or sets the optional path to Chrome, Edge, or Chromium executable to run.
public static string PathToGcHtmlToPdf { get; set; }
Gets or sets a proxy server, overrides system settings. Affects HTTP and HTTPS requests only.
For example: "https://proxy-ip:proxy-port" or "socks5://127.0.0.1:1080".
public string ProxyServer { get; set; }
Gets or sets the number of milliseconds to wait before deeming the page to be ready.
Setting this property to a value greater than 0, activates LoadLazyImages mode.
public int VirtualTimeBudget { get; set; }
Gets or sets the maximum navigation time, in milliseconds.
Defaults to 180000 ms.
public static int WaitDuration { get; set; }
Gets or sets the optional factory for System.Net.WebSockets.WebSocket implementations.
For more information, see comments to WebSocketFactory.
public static WebSocketFactory WebSocketFactory { get; set; }
Applies a GcImaging license key to use by the current instance of GcHtmlRenderer.
Up to five images can be created without a license.
public void ApplyGcImagingLicenseKey(string key)
key
stringThe GcImaging license key to apply.
Applies a GcPdf license key to use by the current instance of GcHtmlRenderer.
Up to five PDFs can be created without a license.
public void ApplyGcPdfLicenseKey(string key)
key
stringThe GcPdf license key to apply.
Clean up any resources being used.
public void Dispose()
Performs cleanup operations on managed and unmanaged resources.
protected virtual void Dispose(bool disposing)
disposing
boolPerforms cleanup operations on unmanaged resources.
protected ~GcHtmlRenderer()
Renders the source HTML to an existing GcBitmap.
public bool RenderToGcBitmap(GcBitmap bitmap, HtmlToImageFormat format = null)
bitmap
GcBitmapThe destination GcBitmap.Note that its current content will be lost.
format
HtmlToImageFormatThe formatting attributes.
True if HTML was successfully rendered; otherwise, false.
Creates a JPEG image from the source HTML and saves it to a specified stream.
public bool RenderToJpeg(Stream outputStream, JpegSettings settings = null)
outputStream
System.IO.StreamThe destination stream.
settings
JpegSettingsThe set of parameters for the output image.
True if JPEG was successfully saved; otherwise, false.
Creates a JPEG image file from the source HTML.
public bool RenderToJpeg(string outputFilePath, JpegSettings settings = null)
outputFilePath
stringThe destination file path.
settings
JpegSettingsThe set of parameters for the output image.
True if the browser process has exited; otherwise, false.
Creates a PDF document from the source HTML and saves it to a specified stream.
public bool RenderToPdf(Stream outputStream, PdfSettings settings = null)
outputStream
System.IO.StreamThe destination stream.
settings
PdfSettingsThe set of parameters for the output PDF.
True if PDF was successfully saved; otherwise, false.
Creates a PDF file from the source HTML.
public bool RenderToPdf(string outputFilePath, PdfSettings settings = null)
outputFilePath
stringThe destination file path.
settings
PdfSettingsThe set of parameters for the output PDF file.
True if the browser process has exited; otherwise, false.
Creates a PNG image from the source HTML and saves it to a specified stream.
public bool RenderToPng(Stream outputStream, PngSettings settings = null)
outputStream
System.IO.StreamThe destination stream.
settings
PngSettingsThe set of parameters for the output image.
True if PNG was successfully saved; otherwise, false.
Creates a PNG image file from the source HTML.
public bool RenderToPng(string outputFilePath, PngSettings settings = null)
outputFilePath
stringThe destination file path.
settings
PngSettingsThe set of parameters for the output image.
True if the browser process has exited; otherwise, false.
Sets a GcImaging license key to use by all instances of GcHtmlRenderer.
Up to five images can be created without a license.
public static void SetGcImagingLicenseKey(string key)
key
stringThe GcImaging license key to set.
Sets a GcPdf license key to use by all instances of GcHtmlRenderer.
Up to five PDFs can be created without a license.
public static void SetGcPdfLicenseKey(string key)
key
stringThe GcPdf license key to set.