settings (GET)
{server}/api/v1/printHtml/settings
Description
Returns the current default settings for printing HTML content (headers, foooters, margins etc.).
Where a value of 0 corresponds to 'Default' (eg. for printBackgroundColorsAndImages or orientation), 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
Response model
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)
}
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)
}
Margins {
left (string, optional),
top (string, optional),
bottom (string, optional),
right (string, optional)
}
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.
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).
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.
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/settings";
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
var leftMargin = data.page.margins.left + (data.page.units === 1 ? ' inches' : ' mm';
var header = data.header;
var willPrintBackground = data.printBackgroundColorsAndImages === 1;
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.";
});
}