Printing one or more files with more feature control

Asynchronous printing of one or more PDF format files 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.

Multiple files may be queued for printing and different options/features used for each print. For example, a different printer may be selected for each print, or different page ranges printed to different printers/trays.

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 simple example of printing two different pages ranges from the same document to the chosen printer with BatchPrintPDF which results in two separate prints. A 'real life' example might use different trays for each print.

// setupPrinting
// Initialise print setup used by all jobs.
function setupPrinting() {
   var printer = MeadCo.ScriptX.Printing;
   printer.printer = $("#fld-pdfprinter").val();
   printer.orientation = $('input[type=radio][name=fld-pdforientation]:checked').val();
   printer.paperSize = $("#fld-pdfpapersize").val();
   printer.paperSource2 = "" + $("#fld-pdfpapersource").val();
   printer.copies = 1;

function BatchPrintPDF() {
    MeadCo.ScriptX.Printing.SetPrintScale(MeadCo.PDFOptionsUI.ShrinkToFitChecked ? -1 : 100);
    console.log("printing to: " + MeadCo.ScriptX.Printing.printer);

    var printing = MeadCo.ScriptX.Printing;
    printing.SetPageRange(false, 1, 1);

    printing.SetPageRange(false, 3, 100); // large number for print to end of document

    // UI until both prints are spooled
<button id="idPrint" onclick="BatchPrintPDF()">Print reports</button>