Printing one or more files in the background

Asynchronous printing of one or more files PDF format files to the current printer is available with the  BatchPrintPDF API . With batch printing, files are downloaded and printed in the background, allowing users to continue with other tasks on the displayed page.

Since the printing is asynchronous then the  IsSpooling API or the  WaitForSpoolingComplete API can be used to start and end a suitable UI to show the user that printing is in progress. WaitForSpoolingComplete() is used in this sample.

Use with ScriptX.Services

BatchPrintPDF() is an API provided by ScriptX.Add-on. An emulation of this API is implemented in  MeadCo ScriptX.Services print client modules . These are used throughtout these samples to allow "single source". An alterative is to use the  ScriptX.Services Print API 'directly'.

This is a basic example of BatchPrintPDF use:

function BatchPrintPDF(urlList) {
  // print to the current printer
  MeadCo.ScriptX.Printing.SetPrintScale(-1); // ensure shrinks to fit if needed
  var urls = urlList.split(";");
  for (var i=0; i < urls.length;i++) {
    MeadCo.ScriptX.Printing.BatchPrintPDF(urls[i]);
  }
}
<body>
<button id="idPrint" onclick="BatchPrintPDF('report.pdf;report2.pdf;report3.pdf')">Print reports</button>
</body>

 

Print to: