Namespace

MeadCo.ScriptX.Print.HTML

MeadCo.ScriptX.Print.HTML

MeadCo.ScriptX.Print.HTML

A static class providing printing of HTML content.

Requires: meadco-core.js, meadco-scriptxprint.js

The purpose of these libraries is to assist those with a body of client javascript code targetting use of the ScriptX Add-On for Internet Explorer. These libraries assist with continuing with a large part of the code intact when transitioning to using ScriptX.Services instead/as well.

Includes processing of calls to the print api that return "printing to file" including collecting the file output.

View Source meadco-scriptxprinthtml.js, line 1

Members

# static documentContentToPrint

Get the complete currently displayed document as string of HTML.

Form values are preserved in the source document then the document cloned.

A base element is created if required. style elements are included. script and object elements are not included.

Properties:
Name Type Description
documentContentToPrint string

the current content in the window document as html

View Source meadco-scriptxprinthtml.js, line 629

# static version

Get the version of this module as a string major.minor.hotfix.build

Properties:
Name Type Description
version string

View Source meadco-scriptxprinthtml.js, line 814

# static version

Get the version of this module as a string major.minor.hotfix.build

Properties:
Name Type Description
version string

View Source meadco-scriptxprintpdf.js, line 254

Methods

# static connect(serverUrl, licenseGuid, onFail)

Specify the server to use and the subscription/license id.

Attempt to connect to the defined ScriptX.Services server and obtain default soft html and device settings for the default device as well as the list of available printers.

This call is not required if client side code doesnt need to know about available printers but can assume (at least .connectLite() is required).

This call is synchronous and therefore not recommended. Use connectAsync()

Parameters:
Name Type Description
serverUrl string

the 'root' url to the server (the api path will be added by the library)

licenseGuid string

the license/subscription identifier

onFail function

the function to call if an error occurs when making the connection

View Source meadco-scriptxprinthtml.js, line 743

# static connectAsync(serverUrl, licenseGuid, resolve, reject)

Specify the server to use and the subscription/license id.

Attempt to connect to the defined ScriptX.Services server and obtain default soft html and device settings for the default device as well as the list of available printers.

This call is not required if client side code doesnt need to know about available printers but can assume (at least .connectLite() is required).

Parameters:
Name Type Description
serverUrl string

the 'root' url to the server (the api path will be added by the library)

licenseGuid string

the license/subscription identifier

resolve function

function to call on success

reject function

function to call on failure

View Source meadco-scriptxprinthtml.js, line 774

# static connectLite(serverUrl, licenseGuid)

Specify the server and the subscription/license id to use on AJAX calls. No call is made in this function

Parameters:
Name Type Description
serverUrl string

the 'root' url to the server (the api path will be added by the library)

licenseGuid string

the license/subscription identifier

View Source meadco-scriptxprinthtml.js, line 731

# static frameContentToPrint(sFrame) → {string}

Get the complete currently displayed document in a frame as string of HTML.

Form values are preserved in the source document then the document cloned.

A base element is created if required. style elements are included. script and object elements are not included.

Parameters:
Name Type Description
sFrame string

the name of the frame

View Source meadco-scriptxprinthtml.js, line 633

the current content in the frame window document as html

string

# static previewDocument()

Display a preview of the document as it will be printed.

View Source meadco-scriptxprinthtml.js, line 680

# static previewFrame(sFrame)

Display a preview of the frame content document it will be printed.

Parameters:
Name Type Description
sFrame string

the name of the iframe whose content is to be printed.

View Source meadco-scriptxprinthtml.js, line 690

# static printDocument(fnCallOnDone, fnCallback, data) → {boolean}

Print the complete current document in the window using the settings made by property updates before this function is called.

Parameters:
Name Type Description
fnCallOnDone function

function to call when printing complete (and output returned), arg is null on no error, else error message.

fnCallback function

function to call when job status is updated

data any

object to give pass to fnCallback

View Source meadco-scriptxprinthtml.js, line 651

  • true if a print was started (otherwise an error will be thrown)
boolean

# static printFrame(sFrame, fnCallOnDone, fnCallback, data) → {boolean}

Print the complete current document in the named iframe using the settings made by property updates before this function is called.

Parameters:
Name Type Description
sFrame string

the name of the iframe whose content is to be printed.

fnCallOnDone function

function to call when printing complete (and output returned), arg is null on no error, else error message.

fnCallback function

function to call when job status is updated

data any

object to give pass to fnCallback

View Source meadco-scriptxprinthtml.js, line 665

  • true if a print was started (otherwise an error will be thrown)
boolean

# static printFromUrl(sUrl, fnCallOnDone, fnCallback, data) → {boolean}

Print the document obtained by downloading the given url using the settings made by property updates before this function is called.

Parameters:
Name Type Description
sUrl string

the fully qualified url to the document to be printed.

fnCallOnDone function

function to call when printing complete (and output returned), arg is null on no error, else error message.

fnCallback function

function to call when job status is updated

data any

object to give pass to fnCallback

View Source meadco-scriptxprinthtml.js, line 701

  • true if a print was started (otherwise an error will be thrown)
boolean

# static printHtml(sHtml, fnCallOnDone, fnCallback, data) → {boolean}

Print the fragment of html using the settings made by property updates before this function is called.

Parameters:
Name Type Description
sHtml string

fragment/snippet of html to print, must be complete HTML document.

fnCallOnDone function

function to call when printing complete (and output returned), arg is null on no error, else error message.

fnCallback function

function to call when job status is updated

data any

object to give pass to fnCallback

View Source meadco-scriptxprinthtml.js, line 716

  • true if a print was started (otherwise an error will be thrown)
boolean

Type Definitions

number

# BooleanOption

Enum to describe a boolean value or use the default

Properties:
Name Type Description
DEFAULT number

0 use the default at the print server

TRUE number

1

FALSE number

2

View Source meadco-scriptxprinthtml.js, line 78

# ExtraHeaderAndFooterSettings

Properties:
Name Type Description
allPagesHeader string
allPagesFooter string
firstPageHeader string
firstPageFooter string
extraFirstPageFooter string
allHeaderHeight number
allFooterHeight number
firstHeaderHeight number
firstFooterHeight number
extraFirstFooterHeight number

View Source meadco-scriptxprinthtml.js, line 114

# Margins

Properties:
Name Type Description
left number

left margin in requested units

top number

top margin in requested units

right number

right margin in requested units

bottom number

bottom margin in requested units

View Source meadco-scriptxprinthtml.js, line 95

number

# PageMarginUnits

Enum to describe the units used on measurements - NOTE please use MeadCo.ScriptX.Print.MeasurementUnits instead

Properties:
Name Type Description
DEFAULT number

0 use the default at the print server

INCHES number

1

MM number

2 millimeters

Deprecated:
  • Yes

View Source meadco-scriptxprinthtml.js, line 24

number

# PageOrientation

Enum to describe the orientation of the paper

Properties:
Name Type Description
DEFAULT number

0 use the default at the print server

LANDSCAPE number

1

PORTRAIT number

2

View Source meadco-scriptxprinthtml.js, line 42

# PageSettings

Properties:
Name Type Description
orientation PageOrientation

orientation of the paper (size and source is a device setting)

units MeasurementUnits

measurement units for margins

margins Margins

margins to use

View Source meadco-scriptxprinthtml.js, line 105

number

# PrintingPass

Enum to describe the pages to be printed

Properties:
Name Type Description
DEFAULT number

0 use the default at the print server

ALL number

1 print all pages

ODD number

2 print odd numbered pages only

EVEN number

3 print even numbered pages only

View Source meadco-scriptxprinthtml.js, line 59

# Settings

The soft settings to use when printing html content - headers, footers and margins (Device settings such as papersize, printer are described with MeadCo.ScriptX.Print.deviceSettings)

Properties:
Name Type Description
header string

Page header for all pages.

footer string

Page footer for all pages.

headerFooterFont string

description of font to use for header/footer

viewScale number

the scaling to use when printing expressed as a percentage. -1 => scale to fit

locale string

language/locale - used for formatting date/time values in header/footer. defaults to client browser setting

timezoneOffset number

client browser timezone offset so server will print correct time

shortDateFormat string

formating string for short dates, if not provided then uses the locale default, or the server default

longDateFormat string

formating string for long dates, if not provided then uses the locale default, or the server default

printBackgroundColorsAndImages BooleanOption

True if background colours and images are to be printed.

page PageSettings

orientation and margins to use on the paper

extraHeadersAndFooters ExtraHeaderAndFooterSettings

enhanced headers and footers

pageRange string

the (set of) page ranges to print, if empty, print all.

printingPass PrintingPass

print all, or odd or even only?

jobTitle string

description to use on the job in the print queue

documentUrl string

the document url to use in headers and footers

View Source meadco-scriptxprinthtml.js, line 593