September 5, 2001 - Avoiding Multiple Print Dialogs | WebReference

September 5, 2001 - Avoiding Multiple Print Dialogs

Yehuda Shiran September 5, 2001
Avoiding Multiple Print Dialogs
Tips: September 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

The print template loader from Microsoft sometimes calls the print template more than once. Since you don't need duplicates of your printout, you need to use an action. For example, the variable invocations is initialized to zero in the beginning, and then is returned immediately upon entry when invocations are greater than one:
invocations = 0;
function CheckIfPrintRequested() {
  invocations++;
  if (invocations > 1) return;
  switch (dialogArguments.__IE_PrintType) {
    case "Prompt":
      if (printer.showPrintDialog()) PrintPrep();
      break;
    case "NoPrompt":
      PrintPrep();
      break;
    case "Preview":
    default:
      break;
  }
}
To learn more about print templates, read Column 89 (Print Templates, Part I) and Column 91 (Print Templates, Part II: TemplatePrinter.) Download Microsoft print template loader.