Printing

A real world example demonstrating the wsprint functionality.

In this example, we will align some test before we print it. The process is as follows.

  1. Define the printer that we will use. In this case, we will use the built-in XPS DOcument Writer.
  2. Once the printer is defined, we will specify the margins and place them into an array.
  3. Specify the output font and size. In this example, we chose Times New Roman and set the size to 15. We added the underline style as well.
  4. Call the print() function, passing the margin array and the font information as options.
  5. Verify that the print operation succeeded.

The script is shown below.

       function printTest() {
     var a, b;
     try {
	    a = new Printer('Microsoft XPS Document Writer'); 
		
		var iTOP = 20;
		var iBOTTOM = 20;
	    var iLEFT = 20;
		var iRIGHT =  20;

		var pMargin = [iTOP, iBOTTOM, iLEFT, iRIGHT];
		
		var aFont={type:"Times New Roman",size:15,underline:true};
		
		a.print({font:aFont,margin:pMargin},"This is a print test \nOn to next Line");		
		
		 }
		  catch(err) {
      System.TraceOutput(err);
     }
 }

printTest();