wawan17
wawan17

Reputation: 11

How to set page orientation in PHP Jasper XML

I have report with width size is bigger than height size (like landscape but set to portrait in Format -> page format ireport). When I preview on ireport, its working fine, but when I load it into PHPJasperXML, it's look portrait not landscape (not same as i report preview). I want set page orientation to portrait with width size is higher than height size. Thanks.

public function print($prid) {
    $CI =& get_instance();
    $CI->load->database();        
    $server=  $CI->db->hostname;
    $db=  $CI->db->database;
    $user=  $CI->db->username;
    $pass= $CI->db->password;
    $xml = base_url('reports/purchase_request.jrxml');        
    $this->load->library('PHPJasperXML');

    $this->phpjasperxml->arrayParameter=array('PRID'=> $prid);
    $this->phpjasperxml->load_xml_file($xml);
    $this->phpjasperxml->transferDBtoArray($server,$user,$pass,$db);
    $this->phpjasperxml->outpage("I");
}

This is report loaded with PHPJasperXML: This is report loaded with PHPJasperXML

This is preview in ireport: This is preview in iReport

Upvotes: 1

Views: 1006

Answers (1)

tobi6
tobi6

Reputation: 8239

Settings

When creating the jrxml file, you have to provide

orientation="Landscape" 

additionally to all other parameters (like pageWidth, pageHeight etc.) in the top-level jasperReport tag:

<jasperReport name="MyReport" pageWidth="842" pageHeight="595" orientation="Landscape" ...

Rotating

It is not possible to rotate the page by simply setting pageWidth and pageHeight to values suitable for landscape. PHPJasperXML will check also for orientation, as I've seen in the source code.

Then PHPJasperXML will interpret this and print the page correctly.

EDIT

Just to make it more clear: PHPJasperXML provides no function to rotate a page. The report has to provide its orientation.

Upvotes: 1

Related Questions