ComponentOne ASP.NET MVC Controls
PrintDocument Class
File
wijmo.js
Module
wijmo

Class that enables the creation of custom documents for printing.

The PrintDocument class makes it easy to create documents for printing or exporting to PDF. Most browsers allow you to select the paper size, orientation, margins, and whether to include page headers and footers.

To use, instantiate a append method, and finish by calling the print method.

For example:

// create the document
var doc = new wijmo.PrintDocument({
  title: 'PrintDocument Test'
});

// add some simple text
doc.append('<h1>Printing Example</h1>');
doc.append('<p>This document was created using the <b>PrintDocument</b> class.</p>');

// add some existing elements
doc.append(document.getElementById('gaugeControl'));

// print the document (or export it to PDF)
doc.print();

The example below shows how you can create a printer-friendly version of a document which can be printed or exported to PDF and other formats directly from the browser:

{@sample Core/PrintDocument Example}

Constructor

Properties

Methods

Constructor

constructor

constructor(options?: any): PrintDocument

Initializes a new instance of the PrintDocument class.

Parameters
Optional

JavaScript object containing initialization data for the PrintDocument.

Returns
PrintDocument

Properties

copyCss

Gets or sets a value that determines whether the PrintDocument should include the CSS style sheets defined in the main document.

The default value for the property is true.

Type
boolean

title

Gets or sets the document title.

Setting this property to null causes the PrintDocument to use the title from the current document.

Type
string

Methods

addCSS

addCSS(href: string): void

Adds a CSS style sheet to the document.

Parameters
  • href: string

    URL of the CSS file that should be added to the document.

Returns
void

append

append(child: any): void

Appends an HTML element or string to the document.

Parameters
  • child: any

    HTML element or string to append to the document.

Returns
void

print

print(callback?: Function): void

Prints the document.

Parameters
Optional

Optional callback invoked after the document finishes printing.

Returns
void