Liquid UI - Documentation - 19.18 Printing tables

19.18 Printing tables


Prerequisites


Purpose

To show a real time scenario demonstrating how to print output in table format using WS scripts. The WS platform extends the functionality of WS by providing the ability to use printers through Webscript.


Prerequisites

To use wsprint, you must first load the necessary files using the load command. These files are as follows.

  • wsprint.dll
  • wsprint.js


User Interface

Printing table output with WSPrint.

In this example, we will print output in a table format using wsprint. The process is as follows.

  1. Create a new function to contain the operation. In this example we will name our function 'printAligntTest()'.
  2. Define the printer that we will use. In this case, we will use the built-in XPS Document Writer.
  3. Once the printer is defined, specify the margins and place them into an array.
  4. Specify the output font and size. In this example, we chose Times New Roman and set the size to 15.
  5. Call the print function, passing the font and margin values as arguments.
  6. Add the table rows. Each row is created as a variable and the rows are then passed to an array which is in turn passed to the tablePrint() function.
  7. Run the function.


Script Details

      System.LoadFile('wsprint.js');

 function printAlignTest() {
     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};
    a.print({font:aFont, margin:pMargin });	
		
		var row1= ['One','two','three'];
		var row2=['four','five','six'];
		var tablerows=[row1,row2];
		a.tablePrint(tablerows);
	
	}
	catch(err){
      System.TraceOutput(err);
    }
 }

printAlignTest();

Can't find the answers you're looking for?