Print a single Base64 encoded PDF document

To synchronously print a single Base64 encoded document use the  PrintPDF() API.

A  data URL with media type application/pdf and base64 encoded data of the PDF document to be printed is given for the url parameter rather than a document url.

Data URL:

data:application/pdf;base64,< .. encoded pdf data ..>

Synchronous printing blocks the browser UI so its use is discouraged. We recommend using one of the BatchPrint APIs instead.

Note when using ScriptX.Services printing is not synchronous at the browser due to the asynchronous nature of the calls to the server that does the printing. In this case WaitForSpoolingComplete() will work and enable a 'busy' UI to be implemented. However it will not work as expected with ScriptX.Add-on.


ScriptX.Addon or ScriptX.Services for Windows PC or ScriptX.Services On Premise (with ScriptX.Server or later) is required.

The use of the ScriptX Client libraries that emulate the Add-on API means the same code can be written for all browsers.

The PDF library must be included:

<script src="~/Scripts/jquery-3.1.1.js"></script>
<script src="/scripts/MeadCo.ScriptX/meadco-core.js"></script>
<script src="/scripts/MeadCo.ScriptX/meadco-scriptxprint.js"></script>
<script src="/scripts/MeadCo.ScriptX/meadco-scriptxprintpdf.js"></script> <-- PDF library required --> 
<script src="/scripts/MeadCo.ScriptX/meadco-scriptxfactory.js"></script>
<script src="/scripts/MeadCo.ScriptX/meadco-scriptxprintlicensing.js"></script>
<script src="/scripts/MeadCo.ScriptX/meadco-secmgr.js"></script>
<script src="/scripts/meadco-scriptx-1.10.1.js" type="text/javascript"></script>

Then the same code works:

var base64EncodedPDF = "data:application/pdf;base64,JVBERi0xLjUKJYCBgoMKMSAwIG9iago8PC9GaWx0ZXIvRmxhdGVEZWNvZGUvRmlyc3QgMTQxL04gMjAvTGVuZ3==";
$(window).on("load", function () {
        .then(function() {
            $("#btn-print").click(function(e) {
                // print the pdf, no prompt, shrinktofit
                MeadCo.ScriptX.Printing.PrintPDF({ "url": base64EncodedPDF },false,true);
        .catch(function(e) {
            app.Messages.ErrorBox("Unable to initialise ScriptX: " + e);

PDF to be printed: