Search results

Print and Export in ASP.NET Core Linear Gauge

30 Jul 2021 / 2 minutes to read

Print

The rendered Linear Gauge can be printed directly from the browser by calling the print method. To use the print functionality, set the AllowPrint property as ”true“.

tagHelper
Copied to clipboard
@using Syncfusion.EJ2;

<div id="container">
    <button id="print">Print</button>
        <ejs-lineargauge id="gauge" load="gaugeLoad" allowPrint="true" orientation="Horizontal">
            <e-lineargauge-axes>
                <e-lineargauge-axis minimum="0" maximum="120">
                </e-lineargauge-axis>
            </e-lineargauge-axes>
      </ejs-lineargauge>
</div>
<script>
    window.gaugeLoad = function (args) {
        window.gauge = args.gauge;
    }
    window.onload = function () {
        document.getElementById("print").onclick = () => {
            window.gauge.print();
        };
    };
</script>

Linear Gauge with print functionality

Export

Image Export

To use the image export functionality, set the AllowImageExport property as ”true”. The rendered Linear Gauge can be exported as an image using the export method. This method requires two parameters: export type and file name. The Linear Gauge can be exported as an image with the following formats.

  • JPEG
  • PNG
  • PDF
tagHelper
Copied to clipboard
@using Syncfusion.EJ2;

<div id="container">
    <button id="export">Export</button>
        <ejs-lineargauge id="gauge" load="gaugeLoad" allowImageExport="true" orientation="Horizontal">
            <e-lineargauge-axes>
                <e-lineargauge-axis minimum="0" maximum="120">
                </e-lineargauge-axis>
            </e-lineargauge-axes>
      </ejs-lineargauge>
</div>
<script>
    window.gaugeLoad = function (args) {
        window.gauge = args.gauge;
    }
    window.onload = function () {
        document.getElementById("export").onclick = () => {
            window.gauge.export('PNG', 'LinearGauge');
        };
    };
</script>

Linear Gauge with image export

PDF Export

To use the PDF export functionality, set the AllowPdfExport property as ”true”. The rendered Linear 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 of the PDF document can be set as ”Portrait” or ”Landscape“.

tagHelper
Copied to clipboard
@using Syncfusion.EJ2;

<div id="container">
    <button id="export">Export</button>
        <ejs-lineargauge id="gauge" load="gaugeLoad" allowPdfExport="true" orientation="Horizontal">
            <e-lineargauge-axes>
                <e-lineargauge-axis minimum="0" maximum="120">
                </e-lineargauge-axis>
            </e-lineargauge-axes>
      </ejs-lineargauge>
</div>
<script>
    window.gaugeLoad = function (args) {
        window.gauge = args.gauge;
    }
    window.onload = function () {
        document.getElementById("export").onclick = () => {
            window.gauge.export('PDF', 'LinearGauge', 0);
        };
    };
</script>

Linear Gauge with image export

Exporting Linear Gauge as base64 string of the file

The Linear Gauge can be exported as base64 string for the JPEG, PNG and PDF formats. The rendered Linear Gauge can be exported as base64 string of the exported image or PDF document used in the export method. The arguments that are required for this method is export type, file name, orientation of the exported PDF document and ”allowDownload” boolean value that is set as ”false” to return base64 string. The value for the orientation of the exported PDF document is set as ”null” for image export and ”Portrait” or ”Landscape” for the PDF document.

tagHelper
Copied to clipboard
@using Syncfusion.EJ2;

<div id="container">
    <button id="export">Export</button>
        <ejs-lineargauge id="gauge" Load="gaugeLoad" AllowImageExport="true" Orientation="Horizontal">
            <e-lineargauge-axes>
                <e-lineargauge-axis Minimum="0" Maximum="120">
                </e-lineargauge-axis>
            </e-lineargauge-axes>
      </ejs-lineargauge>
</div>
<script>
    window.gaugeLoad = function (args) {
        window.gauge = args.gauge;
    }
    window.onload = function () {
        document.getElementById("export").onclick = () => {
            window.gauge.export('JPEG', 'LinearGauge', null, false).then((data) => {
                let base64 = data;
                document.writeln(base64);
            });
        };
    };
</script>

Linear Gauge with base64 string

Note: The exporting of the Linear Gauge as base64 string is not applicable for the SVG format.