Provides a container for LAYOUTRECT elements and other content in a print template.
A DEVICERECT element represents a page to be printed or viewed in print preview. DEVICERECT elements must surround any content to be printed or previewed in a print template. UI elements included in the print template—such as buttons for use during print preview—should not be included in any of the template's DEVICERECT elements.
A DEVICERECT element is intended for use when building a print template. While this element renders on a Web page, most of its functionality is disabled when it is used outside a print template.
A DEVICERECT element typically contains LAYOUTRECT elements, which are containers for the content brought into a print template from the current document in the browser or another source. A DEVICERECT element can contain other HTML content as well, such as div, p, ul, or img elements. These elements can be used to provide boilerplate content, like a copyright notice or a company logo.
A print template typically consists of a number of DEVICERECT elements (often dynamically created through script) for each page to be printed or previewed. See the LAYOUTRECT reference page for an example.
To provide proper page formatting, a DEVICERECT element must have a style that defines the width and height properties for the page. A print template can obtain the current page setup information by querying the TemplatePrinter behavior properties, including pageWidth and pageHeight. A style for a DEVICERECT element typically includes a border, background, or margin so that the user can see the edges of pages in print preview mode.
When using the DEVICERECT element, you must prefix it with an XML namespace. Declare the namespace using the IMPORT processing instruction. For example, the namespace "IE" can be declared by the following statement.
<?import implementation="#default" namespace="IE">
The DEVICERECT element syntax to use with this namespace is <IE:DEVICERECT ... >.
**Security Warning: **Writing an Microsoft ActiveX control, binary behavior, or other binary object for use on a Web page that can load an unspecified print template can compromise the security of your application. Such a control could be appropriated to load insecure or malicious print templates. Write your control to load only specific, pre-defined templates. For more information, please review Beyond Print Preview: Print Customization for Internet Explorer 5.5 and Designing Secure ActiveX Controls.
Click below to download a sample application that demonstrates the print and print preview features of Internet Explorer. The application includes eight templates that increase in complexity from minimal functionality to those that include user interface elements. You can also use the application to test templates of your own design. You must download the sample application to your own computer to run it.
Minimum supported client
Minimum supported server
Windows 2000 Server