Change Page Layout in Report

Hi Everyone,
Can anybody let me know to change the orientation of the page from Portrait to Landscape?

Add this in your custom html file

Hi Rushabh,
Below is my code and I used every option for orientation whether it is shared by your or on web, but it didn’t work for me, can you please help me out?

{%- macro add_header(page_num, max_pages, doc, letter_head, no_letterhead) -%}
    {% if letter_head and not no_letterhead %}
    <div class="letter-head">{{ letter_head }}</div>
    {% endif %}
    {%- if doc.meta.is_submittable and doc.docstatus==0-%}
    <div "text-center">
    {%- if doc.workflow_state=="Submit" -%}
     <h4 align="center"> {{ _("Approved") }}</h4></div>  
    {%- endif -%}
   {% endif %}
     {%- if doc.meta.is_submittable and doc.docstatus==2-%}
    <div class="alert alert-danger text-center">
        <h4 style="margin: 0px;">{{ _("CANCELLED") }}</h4></div>
    {%- endif -%}
    {% if max_pages > 1 %}
    <p class="text-right">{{ _("Page #{0} of {1}").format(page_num, max_pages) }}</p>
    {% endif %}
{%- endmacro -%}
<style type="text/css" media="all">
		@page {
			size: A4 landscape; /* can use also 'landscape' for orientation */
			margin-top: 3.0in;
			margin-bottom: 1.0in;
			
			@bottom-center {
				content: element(footer);
			}
			
			@top-center {
				content: element(header);
			}
		}
			
		#page-header {
			display: block;
			position: running(header);
		}
		
		#page-footer {
			display: block;
			position: running(footer);
		}
	</style>
{{ add_header(0,1,doc,letter_head, no_letterhead) }}
<label>
<p class="text-right" style="font-size:250%"><b>{{ _("BOM") }}</b></p><br>
<p class="text-right" style="font-size:100%"><b>{{ doc.name }}</b></p>
<hr size="10">
</label>
<div class="row">        
     <div class="col-xs-6">            
        <div class="row">
            <div class="col-xs-5 text-right"><label>Item</label></div>
            <div class="col-xs-7 ">{{ doc.item}} </div>
        </div>
        <div class="row">
            <div class="col-xs-5 text-right"><label>Item Name</label></div>
            <div class="col-xs-7 ">{{ doc.item_name or ''}}</div>
        </div>      
        <div class="row">
            <div class="col-xs-5 text-right"><label>Rate of Material Based on</label></div>
            <div class="col-xs-7 ">{{ doc.rm_cost_as_per or ''}}</div>
        </div>      
          <div class="row">
            <div class="col-xs-5 text-right"><label>Price List</label></div>
            <div class="col-xs-7 ">{{ doc.buying_price_list or ''}}</div>
        </div>
    </div>

    <div class="col-xs-6">
        
        <div class="row">
            <div class="col-xs-5 text-right"> <label>Is Active</label> </div>
            <div class="col-xs-7 ">{{ doc.is_active or ''}}</div>
        </div>    
       <div class="row">
            <div class="col-xs-5 text-right"> <label>Is Default</label> </div>
            <div class="col-xs-7 ">{{ doc.is_default or ''}}</div>
        </div>
     <div class="row">
            <div class="col-xs-5 text-right"> <label>With Operations</label> </div>
            <div class="col-xs-7 ">{{ doc.with_operations or ''}}</div>
        </div>
    
    </div>
            
</div>
        
<br>

<table class="table table-bordered">
    <tbody>
        <tr>
           <th>Sr</th>
            <th>Item</th>
            <th>Item Name</th>
           <th class="text-right">Location</th>
           <th class="text-right">Qty</th>
            <th class="text-right">Rate</th>
            <th class="text-right">Amount</th>
            <th class="text-right">Stock UOM</th>

            
          
        </tr>
       {%- for row in doc.items -%}
        <tr>
            <td style="width: 3%;">{{ row.idx }}</td>
            <td style="width: 35%;"> {{ row.item_code or ''}} </td>
            <td style="width: 15%;"> {{ row.item_name }} </td>
            <td style="width: 15%; text-align: right;"> {{ row.location }}</td>
            <td style="width: 10%; text-align: right;"> {{ row.qty }} </td>
            <td style="width: 12%; text-align: right;"> {{ row.rate }} </td>
            <td style="width: 10%; text-align: right;"> {{ row.amount }}</td>
            <td style="width: 10%; text-align: right;"> {{ row.stock_uom }}</td>      
        </tr>
               {%- endfor -%} 
    </tbody>
</table>
<br>
   
<div class="row">
    <div class="col-xs-6 text-right"></div>
    <div class="col-xs-4 text-right"><label>{{ _("Net Total") }}</label></div>
    <div class="col-xs-2  text-right">
      {{ doc.get_formatted("total") or '' }}
    </div>
</div>  

{%- for row in doc.taxes -%}
    {%- if not row.included_in_print_rate -%}
    {%- if row.tax_amount -%}      
<div class="row">
    <div class="col-xs-6 text-right"></div>
    <div class="col-xs-4 text-right"><label>{{ row.description }}</label></div>
    <div class="col-xs-2 text-right">{{ row.get_formatted("tax_amount", doc) }}</div>
</div> 
    {%- endif -%}
    {%- endif -%}
{%- endfor -%}

{%- if doc.discount_amount -%}
    <div class="row">
         <div class="col-xs-6 text-right"></div>
         <div class="col-xs-4 text-right"><label>{{ _("Discount") }}</label></div>
         <div class="col-xs-2 text-right">{{ doc.get_formatted("discount_amount") }}</div>
    </div> 
 {%- endif -%}         
           
<div class="row">
    <div class="col-xs-6 text-right"></div>
    <div class="col-xs-4 text-right"><label>{{ _("Grand Total") }}</label></div>
    <div class="col-xs-2 text-right">{{ doc.get_formatted("grand_total") }}</div>
</div>

<div class="row">
 <div class="col-xs-12 text-left">{{ doc.terms or '' }}</div>
</div>

I have not tried it myself. Maybe add it inside the add_header macro.

Does it show up correctly in View Source?

I have tried there also, its not working.
As far as view page source is concern, when I goto full page view and then do a view page source then it shows the code but on a wrong place whereas when I do the view page source from print format itself then it doesn’t show my code there.

@ruchin78 there is a separate field for style in the Print Format form. Did you add there?

No, I have no idea about that. I appreciate if you can help me on that.

Hi @rmehta,
I have tried it by putting it in the CSS Block, but it didn’t work. Is it the same you were talking about?

@rmehta The method for printing reports is different than for printing other documents (such as sales orders) Perhaps changing it to that method would help?