ABOUT US

|

SUPPORT

|

BLOG

DOWNLOADS    

 

 

 

 


 

 

Printing

 

 

 

 

 

 

Printing is possible in the WebRenderer Server Edition through the API. The methods available in IBrowserCanvas that relate to printing are:

  • void print()
  • void print(boolean scaleWidth, PageFormat pf)
  • Printable getPrintable( boolean scaled )
  • void setPrintHeaders(String leftHeader, String rightHeader)
  • void setPrintFooters(String leftFooter, String rightFooter)

When printing, the print method should be called after the onDocumentComplete() method has fired. This allows the page to be completely loaded before printing begins. The simplest way to print is to call print() on the browser. Note that the print methods can cause a java.awt.print.PrinterException. eg.

  try {
     browser.print();
} catch (PrinterException ex) {
     System.out.println(ex);
}

The other option for print takes a boolean argument which indicates if the size of the entire image should be scaled to fit on the width of the page. A java.awt.print.PageFormat is also passed in where the page orientation can be set (default is portrait).

The getPrintable method also takes a boolean argument which indicates if the size of the entire image should be scaled to fit on the width of the page. It returns a java.awt.print.Printable object, used for printing in Java.

The other methods are for setting the headers and footers when the print methods are used. Strings containing the desired text to set are passed into these methods. The following information about the page can also be set by including the code in the string. The null value can be passed in to prevent headers or footers from being printed.

Detail Code Default position
page title &t leftHeader
page url &u rightHeader
page number &p leftFooter
date and time &d rightFooter

 

 

 

 

 

 Copyright © JadeLiquid Software - www.jadeliquid.com