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 ›  print (POST)

print (POST)

{server}/api/v1/printHtml/print

Description

Print HTML content with given HTML and device settings.

See also the OpenAPI (Swagger) definition.

Applies to:

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

Request parameters


PrintHtmlDescription {
    contentType (integer, required): 1 = Url, 2 = Html, 4 = InnerHtml,
    content (string, required),
    description (string, optional),
    settings (HtmlPrintSettings, optional),
    device (DevicePrintSettings, optional),
    protectedContentAccess (AccessControl,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)
}
DevicePrintSettings {
    printerName (string, optional),
    printToFileName (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
}
AccessControl {
    cookie (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)
}

PrintHtmlDescription:
contentType (integer, required)
Defines for the print server the type of content to be printed.
1 (Url - the content parameter will contain the URL of a document to be printed)
2 (Html - the content parameter will contain a complete HTML document wrappend in <html></html> tags)
4 (InnerHtml - the content parameter will contain an HTML fragment NOT wrapped in <html></html> tags)
content (string, required)
The content to be printed, corresponding to contentType value above. Either a URL or a string of HTML.
description (string, optional)
Optional string that can be used for tracking jobs.
settings (HtmlPrintSettings, optional)
Settings for print job content as described in the HtmlPrintSettings class.
device (DevicePrintSettings, optional)
Settings for printer/device as described in the DevicePrintSettings class.
protectedContentAccess (AccessControl,optional)
Settings for authorising access to protected content. Note this is authorisation only, authentication is not supported.
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 the print job.
DevicePrintSettings:
printerName (string, optional)
Name of the printer/device on the server to be used for the print job.
printToFileName (string, optional)
The full path specification of the file name to save print output to. The file created doesn't accumulate subsequent printouts and (for security reasons) doesn't get overwritten if it already exists. Specify a new filename for each new printout.
paperSizeName (string, optional)
Name of paper size to use for the print job.
paperSourceName (string, optional)
Name of paper source (or bin) to use for the print job (eg. 'Upper tray').
collate (integer, optional)
Collation for the print job. Value can be 0 (Default), 1 (True) or 2 (False).
copies (integer, optional)
Number of copies to be printed.
duplex (integer, optional)
Type of duplex to be used for the print job. Value can be 0 (Default), 1 (Simplex ie. not Duplex), 2 (Vertical duplex) or 3 (Horizontal duplex).
AccessControl:

ScriptX Server 10.4.0 or later is required.

10.4.8 and later support multiple cookies as required by systems such as Cold Fusion.

cookie (string, optional)
The cookie to be used to authorise access to protected content in the form name=value. With ScriptX Server 10.4.8 and later multiple name=value pairs can be given with | separating each pair.
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.

Response model


Print {
    status (integer, optional): 1 = QueuedToDevice, 2 = QueuedToFile, 3 = SoftError, 4 = Ok,
    jobIdentifier (string, optional),
    message (string, optional)
}

Print:
status (integer, optional)
Code indicating initial status of submitted job. 1 (Queued to device), 2 (Queued to file), 3 (Soft error), 4 (Ok)
jobIdentifier (string, optional)
Returns the job token which can then be used in status calls to monitor job progress and (if printing to a PDF file) download to download the output file.
message
Returns error message if status is 3, otherwise returns empty string.

Example usage


const requestData = {
    "contentType": 1,
    "content": "https://scriptxservices.meadroid.com/CloudService/HowTo",
    "settings": {
        "locale": "en-GB",
        "header": "ScriptX.Print :: Browser Agnostic Printing",
        "footer": "&D&b&p of &P&b&t",
        "page": {
            "orientation": 2,       // Portrait
            "units": 2,             // mm
            "margins": {
                "left": "12.5",
                "top": "12.5",
                "bottom": "12.5",
                "right": "12.5"
            }
        },
        "viewScale": 0
    }
};

fetch("https://scriptxservices.meadroid.com/api/v1/printHtml/print", {
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        "Accept": "application/json",
        "Authorization": "Basic " + btoa("13598d2f-8724-467b-ae64-6e53e9e9f644" + ":")
    },
    body: JSON.stringify(requestData),
    referrerPolicy: "origin-when-cross-origin",
    mode: "cors",
    credentials: "omit",
    cache: "no-store",
    redirect: "error",
    keepalive: false
})
.then(response => {
    if (!response.ok) {
        throw new Error('Network response was not ok');
    }
    return response.json();
})
.then(data => {
    if (data.status !== 3) {
        // call print job monitoring function;
        monitorJobProgress(data.jobIdentifier);
    }
})
.catch(error => {
    console.error('There has been a problem with your fetch operation:', error);
});

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

  • 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.