Print and Export

19 Dec 20227 minutes to read

Print

To use the print functionality, set the allowPrint property to true. The rendered circular gauge can be printed directly from the browser by calling the method print.

@using Syncfusion.EJ2;

<div id="container">
<button id="export">Print</button>
	<ejs-circulargauge id="gauge" load="gaugeload" allowPrint="true">
		<e-circulargauge-axes>
			<e-circulargauge-axis startAngle="0" direction="AntiClockWise" endAngle="0" minimum="0" maximum="100" radius="80%">						
			</e-circulargauge-axis>
		</e-circulargauge-axes>
	</ejs-circulargauge>
</div>         
<script>
    window.gaugeload = function (args) {       
		window.gauge = args.gauge;		
	}
	window.onload = function () {
		document.getElementById("export").onclick = () => {
            window.gauge.print();
		};
	};
</script>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EJ2_Core_Application.Models;
using Newtonsoft.Json;
using Syncfusion.EJ2.Charts;
using Syncfusion.EJ2.LinearGauge;


namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {

            return View();
        }
    }
}

Export

Image Export

To use the image export functionality, set the allowImageExport property to true. The rendered circular gauge can be exported as an image using the export method. The method requires two parameters: image type and file name. The circular gauge can be exported as an image in the following formats.

  • JPEG
  • PNG
  • SVG
@using Syncfusion.EJ2;

<div id="container">
    <button id="export">Export</button>
		<ejs-circulargauge id="gauge" load="gaugeload" allowImageExport="true">
			<e-circulargauge-axes>
				<e-circulargauge-axis startAngle="0" direction="AntiClockWise" endAngle="0" minimum="0" maximum="100" radius="80%">						
				</e-circulargauge-axis>
			</e-circulargauge-axes>
		</ejs-circulargauge>
</div>         
<script>
    window.gaugeload = function (args) {       
		window.gauge = args.gauge;		
	}
	window.onload = function () {
		document.getElementById("export").onclick = () => {
            window.gauge.export('PNG', 'CircularGauge');
		};
	};
</script>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EJ2_Core_Application.Models;
using Newtonsoft.Json;
using Syncfusion.EJ2.Charts;
using Syncfusion.EJ2.LinearGauge;


namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {

            return View();
        }
    }
}

The image file is got as base64 string for the JPEG and PNG formats. The circular gauge can be exported to image as a base64 string using the export method. There are four parameters required: image type, file name, orientation of the exported PDF document which must be set as null for image export and finally allowDownload which should be set as false to return base64 string.

@using Syncfusion.EJ2;

<div id="container">
    <button id="export">Export</button>
		<ejs-circulargauge id="gauge" load="gaugeload" allowImageExport="true">
			<e-circulargauge-axes>
				<e-circulargauge-axis startAngle="0" direction="AntiClockWise" endAngle="0" minimum="0" maximum="100" radius="80%">						
				</e-circulargauge-axis>
			</e-circulargauge-axes>
		</ejs-circulargauge>
		<div id="data"></div>
</div>         
<script>
    window.gaugeload = function (args) {       
		window.gauge = args.gauge;		
	}
	window.onload = function () {
		document.getElementById("export").onclick = () => {
            window.gauge.export('JPEG', 'CircularGauge', null, false).then((data) => {
                document.getElementById("data").innerHTML = data;
            });
		};
	};
</script>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EJ2_Core_Application.Models;
using Newtonsoft.Json;
using Syncfusion.EJ2.Charts;
using Syncfusion.EJ2.LinearGauge;


namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {

            return View();
        }
    }
}

PDF Export

To use the PDF export functionality, the allowPdfExport property should be set to true. The rendered circular gauge can be exported as PDF using the export method. The export method requires three parameters: file type, file name and orientation of the PDF document. The orientation setting is optional and “0” indicates portrait and “1” indicates landscape.

@using Syncfusion.EJ2;

<div id="container">
    <button id="export">Export</button>
		<ejs-circulargauge id="gauge" load="gaugeload" allowPdfExport="true">
			<e-circulargauge-axes>
				<e-circulargauge-axis startAngle="0" direction="AntiClockWise" endAngle="0" minimum="0" maximum="100" radius="80%">						
				</e-circulargauge-axis>
			</e-circulargauge-axes>
		</ejs-circulargauge>
</div>         
<script>
    window.gaugeload = function (args) {       
		window.gauge = args.gauge;		
	}
	window.onload = function () {
		document.getElementById("export").onclick = () => {
            window.gauge.export('PDF', 'CircularGauge', 0);
		};
	};
</script>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EJ2_Core_Application.Models;
using Newtonsoft.Json;
using Syncfusion.EJ2.Charts;
using Syncfusion.EJ2.LinearGauge;


namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {

            return View();
        }
    }
}

NOTE

The exporting of the circular gauge as base64 string is not supported in the PDF export.