ScriptX logotype
  • Getting started
  • Documentation
  • Samples
  • Pricing
Free Trial Downloads
  • Home
  • Getting started
  • Documentation
  • Samples
  • Pricing
Developers ›  Knowledge Bank ›  Technical Reference ›  ScriptX.Services ›  Web ServiceAPI Reference ›  PrintHtml ›  htmlPrintDefaults (GET)

htmlPrintDefaults (GET)

{server}/api/v1/printHtml/htmlPrintDefaults/{units}

Description

Returns the default settings for printing HTML, default device info and a list of available device names - useful for populating a UI, e.g. with a list of the printers available.

Where a value of 0 corresponds to 'Default' (eg. for printBackgroundColorsAndImages or printingPass), the setting will be taken from the Internet Explorer settings on the machine providing ScriptX.Services.

Applies to:

  • ScriptX.Services for Cloud
  • ScriptX.Services for On-Premise Devices (Authorisation header is ignored)
  • ScriptX.Services for Windows PC

Request parameters


units (integer, required): 0 = Default, 1 = Inches, 2 = Mm

units (integer, required)
Specifies the measurement units to be used for margin settings, header and footer heights etc. Value can be 0 (Default), 1 (inches) or 2 (mm).

Response model


PrintHtmlDefaultSettings {
    settings (HtmlPrintSettings, optional),
    device (DeviceSettings, optional),
    availablePrinters (Array[string], optional)
}

HtmlPrintSettings {
    locale (string, optional),
    shortDateFormat (string, optional),
    longDateFormat (string, optional),
    timeformat (string, optional),
    timezoneOffset (integer, optional),
    documentUrl (string, optional),
    header (string, optional),
    footer (string, optional),
    headerFooterFont (string, optional),
    page (PageSettings, optional),
    viewScale (integer, optional),
    printBackgroundColorsAndImages (integer, optional): 0 = Default, 1 = True, 2 = False,
    pageRange (string, optional),
    printingPass (integer, optional): 0 = Default, 1 = All, 2 = Odd, 3 = Even,
    extraHeadersAndFooters (ExtraHeaderAndFooterSettings, optional),
    jobTitle (string, optional)
}
DeviceSettings {
    printerName (string, optional),
    paperSizeName (string, optional),
    paperSourceName (string, optional),
    collate (integer, optional): 0 = Default, 1 = True, 2 = False,
    copies (integer, optional),
    duplex (integer, optional): 0 = Default, 1 = Simplex, 2 = Vertical, 3 = Horizontal,
    paperPageSize (Size, optional),
    unprintableMargins (Margins, optional),
    status (integer, optional),
    port (string, optional),
    attributes (integer, optional),
    serverName (string, optional),
    shareName (string, optional),
    location (string, optional),
    isLocal (boolean, optional),
    isNetwork (boolean, optional),
    isShared (boolean, optional),
    isDefault (boolean, optional),
    bins (Array[string], optional),
    forms (Array[string], optional)
}

PageSettings {
    orientation (integer, optional): 0 = Default, 1 = Landscape, 2 = Portrait,
    units (integer, optional): 0 = Default, 1 = Inches, 2 = Mm,
    margins (Margins, optional)
}
ExtraHeaderAndFooterSettings {
    allPagesHeader (string, optional),
    allPagesFooter (string, optional),
    firstPageHeader (string, optional),
    firstPageFooter (string, optional),
    extraFirstPageFooter (string, optional),
    allHeaderHeight (integer, optional),
    allFooterHeight (integer, optional),
    firstHeaderHeight (integer, optional),
    firstFooterHeight (integer, optional),
    extraFirstFooterHeight (integer, optional)
}
Size {
    width (number, optional),
    height (number, optional)
}
Margins {
    left (string, optional),
    top (string, optional),
    bottom (string, optional),
    right (string, optional)
}

Response properties

PrintHtmlDefaultSettings:
settings (HtmlPrintSettings)
Settings for print job content as described in the HtmlPrintSettings class
device (DeviceSettings, optional)
Settings for printer/device as described in the DeviseSettings class.
availablePrinters (Array[string], optional)
An array of the names of all printers/devices available on the print server.
HtmlPrintSettings:
locale (string, optional)
ISO 639-1 language code (eg. "en" for English, "es" for Spanish), used to determine locale-dependent date and time display formats.
shortDateFormat (string, optional)
Short date format string. Default is d (locale-dependent).
longDateFormat (string, optional)
Long date format string. Default is D (locale-dependent).
timeformat (string, optional)
Short time format string. Default is t (locale-dependent).
timezoneOffset (integer, optional)
Client timezone offset (in hours) from UTC.
documentUrl (string, optional)
URL of the HTML document to be printed. Always null when responding to GET settings request.
header (string, optional)
String to print in header of printed output pages. Tokens can be used to represent common information such as date, time, page number etc.
footer (string, optional)
String to print in footer of printed output pages. Tokens can be used to represent common information such as date, time, page number etc.
headerFooterFont (string, optional)
Font that will be used for headers and footers of printed output pages. If value is an empty string the system default font will be used.
page (PageSettings, optional)
Additional page settings as defined by the PageSettings class.
viewScale (integer, optional)
The scaling factor expressed as a percentage that will used to print the document. Value can be -1 ('shrink-to-fit'), 0 ('Default') or any value between 30 and 999.
printBackgroundColorsAndImages (integer, optional)
Option that determines whether background colors and images will be included in the printed output. Value can be 0 (Default), 1 (True) or 2 (False).
pageRange (string, optional)
String that determines which pages of the printed output to print eg. "1,3,5-8" will print pages 1, 3, 5, 6, 7 and 8.
printingPass (integer, optional)
Option to print select pages from printed output. Value can be 0 (Default), 1 (All), 2 (Odd) or 3 (Even).
extraHeadersAndFooters (ExtraHeaderAndFooterSettings, optional)
Extended settings for headers and footers as defined by the ExtraHeaderAndFooterSettings class.
jobTitle (string, optional)
String that identifies a print job. Always null when responding to GET settings request.
DeviceSettings:
printerName (string, optional)
Name of the printer/device on the server. If 'default' was used for the deviceName parameter this will be the default server printer.
paperSizeName (string, optional)
Current paper size setting for the device.
paperSourceName (string, optional)
Current paper source setting (or bin) for the device (eg. 'Upper tray').
collate (integer, optional)
Current collation setting for the device. Value can be 0 (Default), 1 (True) or 2 (False).
copies (integer, optional)
Current device setting for number of copies to be printed.
duplex (integer, optional)
Current duplex setting for the device. Value can be 0 (Default), 1 (Simplex ie. not Duplex), 2 (Vertical duplex) or 3 (Horizontal duplex).
paperPageSize (Size, optional)
Current paper page size for the device as described by the Size class.
unprintableMargins (Margins, optional)
Current device setting for unprintable margins as described by the Margins class.
status (integer, optional)
Current status of the device. Value can be any reasonable combination of these values.
port (string, optional)
A string that identifies the port(s) used to transmit data to the printer. If a printer is connected to more than one port, the names of each port will be separated by commas (for example, "LPT1:,LPT2:,LPT3:").
attributes (integer, optional)
The current attributes of the printer. Value can be any reasonable combination of these values.
serverName (string, optional)
A string giving the name of the server computer controlling the printer. If the string is empty then the printer is controlled locally.
shareName (string, optional)
A string identifying the share point of the printer. This value is only present if PRINTER_ATTRIBUTE_SHARED is set in attributes.
location (string, optional)
A string describing the physical location of the printer.
isLocal (boolean, optional)
Whether the printer is a local printer (true) or not (false). isLocal tests whether PRINTER_ATTRIBUTE_LOCAL is set in attributes.
isNetwork (boolean, optional)
Whether the printer is a network printer (true) or not (false). isNetwork tests whether PRINTER_ATTRIBUTE_NETWORK is set in attributes.
isShared (string, optional)
Whether the printer is a shared printer (true) or not (false). isShared tests whether PRINTER_ATTRIBUTE_SHARED is set in attributes.
isDefault (boolean, optional)
Whether the printer is the default printer of the server computer (true) or not (false).
bins (Array[string], optional)
Lists the available paper sources for a printer. The names returned are suitable for use with the paperSource property.
forms (Array[string], optional)
Lists the available paper sizes (forms) for a printer. The names returned are suitable for use with the paperSize property.
PageSettings:
orientation (integer, optional)
Setting for page orientation. Value can be 0 (Default), 1 (Landscape) or 2 (Portrait).
units (integer, optional)
Option that specifies the measurement units to be used for margin settings, header and footer heights etc. Value can be 0 (Default), 1 (inches) or 2 (mm).
margins (Margins, optional)
Option that specifies the page margins to be used for printed output as defined by the Margins class. Units are specified by the units setting (see above).
ExtraHeaderAndFooterSettings:
allPagesHeader (string, optional)
String or HTML snippet to print in header of all printed output pages. Tokens can be used to represent common information such as date, time, page number etc.
allPagesFooter (string, optional)
String or HTML snippet to print in footer of all printed output pages. Tokens can be used to represent common information such as date, time, page number etc.
firstPageHeader (string, optional)
String or HTML snippet to print in header of first printed output page in place of allPagesHeader. Tokens can be used to represent common information such as date, time, page number etc.
firstPageFooter (string, optional)
String or HTML snippet to print in footer of first printed output page in place of allPagesFooter. Tokens can be used to represent common information such as date, time, page number etc.
extraFirstPageFooter (string, optional)
String or HTML snippet to print as extra footer of first printed output page in addition to allPagesFooter or firstPageFooter. Tokens can be used to represent common information such as date, time, page number etc.
allHeaderHeight (integer, optional)
Height of headers for all pages, using units as specified in the units setting (see above).
allFooterHeight (integer, optional)
Height of footers for all pages, using units as specified in the units setting (see above).
firstHeaderHeight (integer, optional)
Height of header for first page where firstPageHeader has been specified, using units as specified in the units setting (see above).
firstFooterHeight (integer, optional)
Height of footer for first page where firstPageFooter has been specified, using units as specified in the units setting (see above).
extraFirstFooterHeight (integer, optional)
Height of extra footer for first page where extraFirstPageFooter has been specified, using units as specified in the units setting (see above).
Size:
width (number, optional)
The width of the paper specified by paperSizeName. Units are as specified in the units request parameter.
height (number, optional)
The height of the paper specified by paperSizeName. Units are as specified in the units request parameter.
Margins:
left (string, optional)
Left page margin.
top (string, optional)
Top page margin.
bottom (string, optional)
Bottom page margin.
right (string, optional)
Right page margin.
X
Header and footer tokens

Use the following tokens to represent specific information in headers and footers as shown in the table below. These are the standard Internet Explorer header/footer metasymbols:

Token Meaning
&w Window title
&u Page address (URL)
&d Date in short format (as specified by Regional Settings in Control Panel)
&D Date in long format (as specified by Regional Settings in Control Panel)
&t Time in the format specified by Regional Settings in Control Panel
&T Time in 24-hour format
&p Current page number
&P Total number of pages
&& A single ampersand (&)
&b The text immediately following these characters as centered
&b&b The text immediately following the first "&b" as centered, and the text following the second "&b" as right-justified

X
Printer/device status codes

The status code returned by a device can be any reasonable combination of the following values:

Name Value Meaning
PRINTER_STATUS_BUSY 0x00000200 The printer is busy.
PRINTER_STATUS_DOOR_OPEN 0x00400000 The printer door is open.
PRINTER_STATUS_ERROR 0x00000002 The printer is in an error state.
PRINTER_STATUS_INITIALIZING 0x00008000 The printer is initializing.
PRINTER_STATUS_IO_ACTIVE 0x00000100 The printer is in an active input/output state.
PRINTER_STATUS_MANUAL_FEED 0x00000020 The printer is in a manual feed state.
PRINTER_STATUS_NO_TONER 0x00040000 The printer is out of toner.
PRINTER_STATUS_NOT_AVAILABLE 0x00001000 The printer is not available for printing.
PRINTER_STATUS_OFFLINE 0x00000080 The printer is offline.
PRINTER_STATUS_OUT_OF_MEMORY 0x00200000 The printer has run out of memory.
PRINTER_STATUS_OUTPUT_BIN_FULL 0x00000800 The printer's output bin is full.
PRINTER_STATUS_PAGE_PUNT 0x00080000 The printer cannot print the current page. Windows 95/98/Me: Indicates the page is being "punted" (that is, not printed) because it is too complex for the printer to print.
PRINTER_STATUS_PAPER_JAM 0x00000008 Paper is jammed in the printer.
PRINTER_STATUS_PAPER_OUT 0x00000010 The printer is out of paper.
PRINTER_STATUS_PAPER_PROBLEM 0x00000040 The printer has a paper problem.
PRINTER_STATUS_PAUSED 0x00000001 The printer is paused.
PRINTER_STATUS_PENDING_DELETION 0x00000004 The printer is being deleted.
PRINTER_STATUS_POWER_SAVE 0x01000000 The printer is in power save mode.
PRINTER_STATUS_PRINTING 0x00000400 The printer is printing.
PRINTER_STATUS_PROCESSING 0x00004000 The printer is processing a print job.
PRINTER_STATUS_SERVER_UNKNOWN 0x00800000 The printer status is unknown.
PRINTER_STATUS_TONER_LOW 0x00020000 The printer is low on toner.
PRINTER_STATUS_USER_INTERVENTION 0x00100000 The printer has an error that requires the user to do something.
PRINTER_STATUS_WAITING 0x00002000 The printer is waiting.
PRINTER_STATUS_WARMING_UP 0x00010000 The printer is warming up.

X
Printer/device attributes

The attributes returned for a device can be any reasonable combination of the following values:

Name Value Meaning
PRINTER_ATTRIBUTE_DEFAULT 0x00000004 Windows 95/98/Me: Indicates the printer is the default printer in the system.
PRINTER_ATTRIBUTE_DIRECT 0x00000002 Job is sent directly to the printer (it is not spooled).
PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST 0x00000200 If set and printer is set for print-while-spooling, any jobs that have completed spooling are scheduled to print before jobs that have not completed spooling.
PRINTER_ATTRIBUTE_ENABLE_BIDI 0x00000800 Windows 95/98/Me: Indicates whether bi-directional communications are enabled for the printer.
PRINTER_ATTRIBUTE_FAX 0x00004000 Windows XP: If set, printer is a fax printer. 
PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS 0x00000100 If set, jobs are kept after they are printed. If unset, jobs are deleted.
PRINTER_ATTRIBUTE_QUEUED 0x00000001 If set, the printer spools and starts printing after the last page is spooled. If not set and PRINTER_ATTRIBUTE_DIRECT is not set, the printer spools and prints while spooling.
PRINTER_ATTRIBUTE_SHARED 0x00000008 Printer is shared.
PRINTER_ATTRIBUTE_WORK_OFFLINE 0x00000400 Windows 95/98/Me: Indicates whether the printer is currently connected. If the printer is not currently connected, print jobs will continue to spool.
PRINTER_ATTRIBUTE_PUBLISHED 0x00002000 Windows 2000/XP: Indicates whether the printer is published in the directory service.
PRINTER_ATTRIBUTE_NETWORK 0x00000010 Printer is a network printer connection.
PRINTER_ATTRIBUTE_LOCAL 0x00000040 Printer is a local printer.
PRINTER_ATTRIBUTE_RAW_ONLY 0x00001000 Indicates that only raw data type print jobs can be spooled.

Example usage



Request

<h5>Response <span id="response-status"></span></h5>
<textarea id="response" readonly="readonly" rows="3" class="codefont"></textarea>
<h5>Response headers</h5>
<textarea id="headers" readonly="readonly" rows="3" class="codefont"></textarea>


document.addEventListener("DOMContentLoaded", function() {
    document.getElementById('btn_runcode').addEventListener('click', function() { callServer(); });
});

function callServer() {

    document.getElementById('response-status').textContent = "(waiting)";
    const apiUrl = "/api/v1/printHtml/htmlPrintDefaults/1";

    const headers = new Headers({
        "Authorization": "Basic " + btoa("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + ":"),
        "Content-Type": "application/json"
    });
    
    fetch(apiUrl, { method: "GET", headers: headers })
    .then(response => {
        if (!response.ok) {
            throw new Error('Network response was not ok: ' + response.statusText);
        }
        document.getElementById('response-status').textContent = 
            '(status: ' + response.status + ' ' + response.statusText + ')';
        return response.json().then(data => {
            // show JSON response in textarea element
            document.getElementById('response').value = JSON.stringify(data, null, "  ");

              // do something with the settings and device info
              var leftMargin = data.settings.page.margins.left + (data.settings.page.units === 1 ? ' inches' : ' mm';
              var availableDevices = data.availablePrinters;
              var header = data.settings.header;
              var isDefaultPrinter = data.device.isDefault;
              var currentPaperSize = data.device.paperSizeName + '(w:' + data.device.paperPageSize.width + 'in h:' + data.device.paperPageSize.height + 'in)';
              // the units request parameter was 1 so dimensions returned will be in inches
            return response.headers;
        });
    })
    .then(headers => {
        // show response headers in textarea element
        let headersText = "";
        for (let pair of headers.entries()) {
            headersText += `${pair[0]}: ${pair[1]}\n`;
        }
        document.getElementById('headers').value = headersText;
    })
    .catch(error => {
        document.getElementById('response-status').textContent = '(error: ' + error.message + ')';
        document.getElementById('response').value = "Failed to fetch data.";
    });

}





Response 
Response headers
  • Knowledge Bank
  • 'How To' Guides
    • ScriptX.Services
      • Introduction
      • Getting started
      • Evaluate with modern code
      • Maintaining investment in current code
        • Stage 1: Adding UI
        • Stage 2: Printing with ScriptX.Services
        • Stage 3: Summary and review
        • Stage 4: Error reporting
        • Stage 5: Prompted printing
        • Stage 6: Preparing for advanced uses
        • Stage 7: WaitForSpoolingComplete
        • Stage 8: Recommendations for some common issues
      • Printing with the API
      • MeadCoScriptXJS Library
      • Installing ScriptX.Services
        • For Windows PC
        • For On Premise Devices hosted on Windows Server
        • For On Premise Devices hosted on Windows 10/11
        • Configure options For On Premise Devices
        • Cloud
      • Orchestrator
      • Debugging
      • License deployment
        • For Windows PC
        • For On Premise Devices
      • Samples
        • Configure for Windows PC
        • Configure for On Premise
        • Configure for Cloud
    • Security Manager
      • Deploying a license or revision
    • ScriptX.Add-on
      • Introduction
      • Installing ScriptX on client PCs
      • Basic printing with ScriptX
      • Advanced printing features
      • Backwards compatibility
      • How to check if ScriptX is installed
      • License deployment
      • Quick start with Visual Studio
        • ASP.NET MVC
        • ASP.NET Web Forms
      • Nuget Packages
        • MeadCoScriptXJS Library
        • Installer helpers
        • ASP.NET WebForms Controls
        • Helpers for ASP.NET MVC
      • Client-side printing samples
  • Technical Reference
    • ScriptX.Services
      • Web service API
        • Service Description
          • (GET)
        • Licensing
          • licensing (GET)
          • licensing (POST)
          • licensing/ping (GET)
        • Printer
          • settings (GET)
          • current (GET)
          • current (PUT)
          • connection (PUT)
          • connection (DELETE)
        • PrintHtml
          • settings (GET)
          • deviceinfo (GET)
          • htmlPrintDefaults (GET)
          • print (POST)
          • status (GET)
          • download (GET)
          • canceljob (PUT)
        • PrintPdf
          • print (POST)
          • status (GET)
          • download (GET)
        • PrintDirect
          • print (POST)
      • Orchestrator API
        • v1
          • GET
        • v2
          • PUT
          • GET
      • ScriptX.Services compatibility roadmap
    • Security Manager
      • How it works
      • License Expiry
      • Testing for a valid license
      • About the license file (.mlf)
        • LICENSE
        • APPLICENSE
        • TITLE
        • DOMAINS
        • DOMAIN
        • PERMISSION
      • API
        • Apply
        • License
        • result
        • validLicense
    • ScriptX.Add-on
      • factory
        • baseUrl
        • ComponentVersionString
        • IsUniqueIDAvailable
        • OnDocumentComplete
        • relativeUrl
        • ResetUniqueID
        • ScriptXVersion
        • SecurityManagerVersion
        • Shutdown
        • UniqueID
      • printing
        • AddPrinterConnection
        • BatchPrintPDF
        • BatchPrintPDFEx
        • bottomMargin
        • collate
        • copies
        • currentPrinter
        • DefaultPrinter
        • disableUI
        • duplex
        • duplex2
        • EnumJobs
        • EnumPrinters
        • footer
        • GetJobsCount
        • GetMarginMeasure
        • header
        • headerFooterFont
        • IsSpooling
        • IsTemplateSupported
        • leftMargin
        • onafterprint
        • onbeforeprint
        • onbeforeunload
        • onpagesetup
        • onuserpagesetup
        • onuserprint
        • onuserprintpreview
        • orientation
        • OwnQueue
        • pageHeight
        • PageSetup
        • pageWidth
        • paperSize
        • paperSource
        • paperSource2
        • portrait
        • Preview
        • Print
        • printBackground
        • printer
        • PrintHTML
        • PrintHTMLEx
        • PrintPDF
        • PrintSetup
        • printToFileName
        • RemovePrinterConnection
        • rightMargin
        • SetMarginMeasure
        • SetPageRange
        • SetPreviewZoom
        • SetPrintScale
        • Sleep
        • templateURL
        • topMargin
        • TotalPrintPages
        • unprintableBottom
        • unprintableLeft
        • unprintableRight
        • unprintableTop
        • WaitForSpoolingComplete
      • printerControl
        • attributes
        • Bins
        • Forms
        • isLocal
        • isNetwork
        • isShared
        • Jobs
        • location
        • name
        • Pause
        • port
        • Purge
        • Resume
        • serverName
        • shareName
        • status
      • Job
        • Delete
        • Pause
        • Restart
        • Resume
      • enhancedFormatting
        • allFooterHeight
        • allHeaderHeight
        • allPagesFooter
        • allPagesHeader
        • extraFirstFooterHeight
        • extraFirstPageFooter
        • firstFooterHeight
        • firstHeaderHeight
        • firstPageFooter
        • firstPageHeader
        • pageRange
        • printingPass
      • rawPrinting
        • printer
        • printDocument
        • printString
    • Change and history logs
    • Articles
      • v1.15.x ScriptX Client Library
      • Dialogs with ScriptX.Services
      • Accessing protected content
      • Long term servicing (LTS)
 
ScriptX logotype
Home Getting started Documentation Samples Contact us

© 2025 Mead & Co Limited.

Follow us:
LinkedIn   GitHub
X

Warning:

This ScriptX.Add-on sample can only be viewed using Internet Explorer.