---
title: "HTMLCanvasElement.ToDataURL"
url: "https://reference.aspose.com/html/net/aspose.html/htmlcanvaselement/todataurl/"
product: "Aspose.HTML for .NET API Reference"
description: "HTMLCanvasElement ToDataURL method. returns a data URI containing a representation of the image in the format specified by the type parameter defaults to PNG. The returned image is in a resolution of 96 dpi"
---

## ToDataURL() {#todataurl}

returns a data URI containing a representation of the image in the format specified by the type parameter (defaults to PNG). The returned image is in a resolution of 96 dpi.

```csharp
public string ToDataURL()
```

### Return Value

A DOMString containing the requested data URI.

### See Also

* class [HTMLCanvasElement](../)
* namespace [Aspose.Html](../../../aspose.html/)
* assembly [Aspose.HTML](../../../)

---

## ToDataURL(*string*) {#todataurl_1}

returns a data URI containing a representation of the image in the format specified by the type parameter (defaults to PNG). The returned image is in a resolution of 96 dpi.

```csharp
public string ToDataURL(string type)
```

| Parameter | Type | Description |
| --- | --- | --- |
| type | String | A string indicating the image format. The default format type is image/png. |

### Return Value

A DOMString containing the requested data URI.

### See Also

* class [HTMLCanvasElement](../)
* namespace [Aspose.Html](../../../aspose.html/)
* assembly [Aspose.HTML](../../../)

---

## ToDataURL(*string, double*) {#todataurl_2}

returns a data URI containing a representation of the image in the format specified by the type parameter (defaults to PNG). The returned image is in a resolution of 96 dpi.

```csharp
public string ToDataURL(string type, double encoderOptions)
```

| Parameter | Type | Description |
| --- | --- | --- |
| type | String | A string indicating the image format. The default format type is image/png. |
| encoderOptions | Double | A Number between 0 and 1 indicating image quality if the requested type is image/jpeg or image/webp. |

### Return Value

A DOMString containing the requested data URI.

### See Also

* class [HTMLCanvasElement](../)
* namespace [Aspose.Html](../../../aspose.html/)
* assembly [Aspose.HTML](../../../)
