[]
Represents a page in a GcHtmlBrowser instance.
public class HtmlPage : IDisposable
Gets the owner GcHtmlBrowser.
public GcHtmlBrowser Browser { get; }
Gets the timeout settings for various browser operations.
public TimeoutOptions TimeoutOptions { get; }
Clean up any resources being used.
public void Dispose()
Executes a script in the browser context.
public T EvaluateExpression<T>(string script)
script
stringScript to be evaluated in browser context.
Script return value.
T
The type to deserialize the result to.
Performs cleanup operations on unmanaged resources.
protected ~HtmlPage()
Gets the full HTML content of the page, including the doctype.
public string GetContent()
Gets the size of page scrollable area, in pixels.
public Size GetContentSize()
Gets the page title.
public string GetTitle()
Gets the virtual window size, in pixels.
public Size GetWindowSize()
Reloads the page.
public void Reload(PageLoadStates waitUntil = PageLoadStates.Load)
waitUntil
PageLoadStatesWhen to consider navigation succeeded.
Renders the current page to an existing GcBitmap.
public void Render(GcBitmap bitmap, PngOptions options = null)
bitmap
GcBitmapThe destination GcBitmap. Note that its current content will be lost.
options
PngOptionsThe set of parameters for the output image.
Renders the current page to an existing GcBitmap and crops.
public void RenderAndCrop(GcBitmap bitmap, PngOptions options = null, Color? backColor = null, int leftMargin = 0, int topMargin = 0, int rightMargin = 0, int bottomMargin = 0)
bitmap
GcBitmapThe destination GcBitmap. Note that its current content will be lost.
options
PngOptionsThe set of parameters for the output image.
backColor
System.Drawing.Color?The color to be treated as the background to crop. If not set, the color of the bottom right pixel of the image is taken as the background.
leftMargin
intThe width of the left margin, in pixels.
topMargin
intThe height of the top margin, in pixels.
rightMargin
intThe width of the right margin, in pixels.
bottomMargin
intThe height of the bottom margin, in pixels.
Clears an override of the default background color.
public void ResetDefaultBackgroundColor()
Saves the current page to a stream in JPEG format.
public void SaveAsJpeg(Stream outputStream, JpegOptions options = null)
outputStream
System.IO.StreamThe destination stream.
options
JpegOptionsThe set of parameters for the output JPEG image.
Saves the current web page as a JPEG image file.
public void SaveAsJpeg(string outputFilePath, JpegOptions options = null)
outputFilePath
stringThe destination file path.
options
JpegOptionsThe set of parameters for the output JPEG image.
Saves the current page to a stream in PDF format.
public void SaveAsPdf(Stream outputStream, PdfOptions options = null)
outputStream
System.IO.StreamThe destination stream.
options
PdfOptionsThe set of parameters for the output PDF document.
Creates a PDF file from the current page.
public void SaveAsPdf(string outputFilePath, PdfOptions options = null)
outputFilePath
stringThe destination file path.
options
PdfOptionsThe set of parameters for the output PDF file.
Saves the current page to a stream in PNG format.
public void SaveAsPng(Stream outputStream, PngOptions options = null)
outputStream
System.IO.StreamThe destination stream.
options
PngOptionsThe set of parameters for the output PNG image.
Saves the current page as a PNG image file.
public void SaveAsPng(string outputFilePath, PngOptions options = null)
outputFilePath
stringThe destination file path.
options
PngOptionsThe set of parameters for the output PNG image.
Saves the current page to a stream in WEBP format.
public void SaveAsWebp(Stream outputStream, WebpOptions options = null)
outputStream
System.IO.StreamThe destination stream.
options
WebpOptionsThe set of parameters for the output WEBP image.
Saves the current page as a WEBP image file.
public void SaveAsWebp(string outputFilePath, WebpOptions options = null)
outputFilePath
stringThe destination file path.
options
WebpOptionsThe set of parameters for the output WEBP image.
Sets the HTML markup to the page.
public void SetContent(string html, PageLoadStates waitUntil = PageLoadStates.Load)
html
stringHTML markup to assign to the page.
waitUntil
PageLoadStatesWhen to consider navigation succeeded.
Sets the background color to be used if the HTML markup doesn't specify one.
public void SetDefaultBackgroundColor(Color color)
color
System.Drawing.ColorSets the virtual window size, in pixels.
public void SetWindowSize(Size windowSize)
windowSize
System.Drawing.SizeRenders the current page to an image in JPEG format and returns it as a byte array.
public byte[] ToJpegBytes(JpegOptions options = null)
options
JpegOptionsThe set of parameters for the output JPEG image.
The byte array with image data in JPEG format.
Renders the current page to a PDF document and returns it as a byte array.
public byte[] ToPdfBytes(PdfOptions options = null)
options
PdfOptionsThe set of parameters for the output PDF document.
The byte array with a PDF document.
Renders the current page to an image in PNG format and returns it as a byte array.
public byte[] ToPngBytes(PngOptions options = null)
options
PngOptionsThe set of parameters for the output PNG image.
The byte array with image data in PNG format.
Renders the current page to an image in WEBP format and returns it as a byte array.
public byte[] ToWebpBytes(WebpOptions options = null)
options
WebpOptionsThe set of parameters for the output WEBP image.
The byte array with image data in WEBP format.
Waits for network idle during the specified amount of time.
public void WaitForNetworkIdle(int idleTime = 500, int maxTimeout = 30000)
idleTime
intHow long to wait for no network requests, in milliseconds.
maxTimeout
intMaximum time to wait for, in milliseconds.