function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Alex Waddell 17Alex Waddell 17 

How to adjust margins on VF page while rendering as PDF

Hello,

I need to make my margins smaller on my Visual Force page while rendering as PDF

I added the following to code to my VF page but I am not seeing any changes...
        <head>
            <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
            <style type="text/css">
                @page{
                margin:0.25in;
                }

               
            </style>      
        </head>
Below is the rest of my code. Can anyone help me make the margins smaller?
 
<apex:page standardController="Correspondence__c" renderAs="pdf" >
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
            <style type="text/css">
                @page{
                margin:0.25in;
                }

               
            </style>      
        </head>    
        <body>   
            <table cellpadding="1" width="100%">
                <tr>
                    <td width="35%">
                        <apex:outputPanel >
                            <apex:image url="/servlet/servlet.FileDownload?file=0151D0000005bAO" width="100" Height="50"/>
                        </apex:outputPanel>
                    </td>
                    <td width="50%">
                        <apex:outputPanel >
                           <b> Case Information </b>
                        </apex:outputPanel>
                    </td>
                    <td width="15%">
                        <apex:outputPanel style="width:100% font-family: sans-serif;font-size:8pt;">
                           <b> Form 2067 </b> <br></br>
                        	December 2012-2
                        </apex:outputPanel>
                    </td>    
                </tr>
            </table>  


 <table cellpadding="6" width="70%">
                <tr>
                    <td style="vertical-align: text-top;">
                            To:
				    </td><td>
                        <div class="mybox">
        		<apex:outputField value="{!Correspondence__c.Payer_Name__c}"/><br/>
                <apex:outputField value="{!Correspondence__c.Payer_Fax_Number__c}"/><br/>
										
						</div>
                    </td>
                    <td style="vertical-align: text-top;">                      
                            From:
			       </td><td>
                        <div class="mybox">       			
                Outreach Health Services<br/>
        		251 W Renner Rd, <br/>
        		Richardson, TX 75080 
						</div>
                    </td>
                </tr>
            </table>       
             <table style="width:100% font-family: sans-serif;font-size:8pt;" border="1" width="100%">


          <tr width = "100%">
            <td width = "32%">Case Name
                <br></br>
            <apex:outputField Value="{!Correspondence__c.Case_Name__c}" />
            </td>

            <td width = "11%">Category <br></br> PERS</td>
            <td width = "11%">Case No. <br></br> <apex:outputField Value="{!Correspondence__c.Case_No__c}"/></td>
            <td width = "11%">Category<br></br> &nbsp;  </td>
            <td width = "11%">Case No.<br></br> &nbsp;  </td>
          </tr>       

        </table>        
        <table style="width:100% font-family: sans-serif;font-size:8pt;" border="1" width="100%">


          <tr width = "100%">

            <td width = "60%">Address(Street, City, State, ZIP Code)
                <br></br>
            <apex:outputField Value="{!Correspondence__c.Patient_Address__c}"/>
              </td>
            <td width = "40%">Area Code and Telephone No.
                <br></br>
    <apex:outputField Value="{!Correspondence__c.Payer_Fax_Number__c}"/>   
				</td>      
			</tr>
        </table>        
   <b style="width:100% font-family: sans-serif;font-size:8pt;">Please Check all that apply.</b>  
<br></br>
<br></br>
             <table style="width:100% font-family: sans-serif;font-size:8pt;">


          <tr>
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td> Absent Parent</td>
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>Change in Address/Telephone</td>  
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>Change in Circumstances </td>
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>Child Care</td>  
			<td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>Community Placement Resources</td>
          </tr>
          <tr>
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td> Deductions</td>
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>Employment Services</td>  
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>EPSDT </td>
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>Family Health Services Name</td>  
			<td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>Family Planning</td>
          </tr>       
          <tr width = "100%">
            <td width = "5%"></td>
            <td width = "15%"></td>
            <td width = "5%"></td>
            <td width = "15%"></td>
            <td width = "5%"></td>
            <td width = "15%"></td>
            <td width = "5%"></td>
            <td width = "15%"></td>
            <td width = "5%"></td>
            <td width = "15%"></td>
          </tr> 
          <tr>
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td> Household Composition</td>
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>Income</td>  
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>LTSS Information Shared </td>
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>Medicaid</td>  
			<td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>Medical/Disability</td>
          </tr>
          <tr>
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>MERP Shared</td>
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>Nursing Care/Level of Care</td>  
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>Protective Services</td>
            <td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>Refugee Services</td>  
			<td><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td>Resources</td>
          </tr>
		</table>
		<table style="width:100% font-family: sans-serif;font-size:8pt;">
          <tr>
            <td width="5%"><apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td width="15%">Supported Services</td>
            <td width="5%">  <apex:outputField Value="{!Correspondence__c.VF_Checkbox__c}"/></td>
            <td width="15%">TANF</td>  
            <td width="5%"><apex:outputField Value="{!Correspondence__c.Other__c}"/></td>
            <td width="5%">  Other:</td>
            <td width="40%"><apex:outputField Value="{!Correspondence__c.Reason_for_Form__c}"/></td>
          </tr>       
        </table> 
	<table  width="100%" style="width:100% font-family: sans-serif;font-size:8pt;" border="1">
        <tr>
        <td>
         Comments/Response
        <br></br>
		<apex:outputField Value="{!Correspondence__c.Comment_Response__c}"/>
        <br></br>
        <br></br>
		<br></br>
		<br></br>
		<br></br>
<br></br>
<br></br>
	 </td>        
	</tr>
</table>
		<br></br>
		<table  width="100%" style="width:100% font-family: sans-serif;font-size:8pt;">
          <tr>
			<td width="50%"></td>
            <td width="30%"></td>
            <td>Area code and Telephone No.</td>  
          </tr>   
             </table>
		<table  width="100%" style="width:100% font-family: sans-serif;font-size:8pt;">
          <tr>
			<td width="50%"></td>
            <td width="30%"><apex:outputField Value="{!Correspondence__c.CreatedDate}"/></td>
            <td> 75080 </td>  
          </tr>   
             </table>

		<table  width="100%" style="width:100% font-family: sans-serif;font-size:8pt;">
          <tr>
			<td width="47%">______________________________________ </td>
            <td>__________________________ </td>
            <td></td>  
          </tr>   
             </table>
<table width="100%" style="width:100% font-family: sans-serif;font-size:8pt;" >
                      <tr>
            <td width="10%"></td>
			<td width="20%">Signature </td>
            <td width="10%"></td>
			<td width="15%"></td>
            <td width="15%">Date</td>
            <td width="10%"></td>
            <td width="25%"></td>
            
          </tr>      
        </table> 
 <apex:image url="/servlet/servlet.FileDownload?file=0151D0000005cdx" width="100%"/>

        </body>
    </html>
</apex:page>


 
Scott Nelson SolutionistScott Nelson Solutionist
Try:
@media print {
	margin:1800pt;
}

 
Raj VakatiRaj Vakati
/* Default left, right, top, bottom margin is 2cm */
@page { margin: 2cm } 

/* First page, 10 cm margin on top */
@page :first {
  margin-top: 10cm;
}

/* Left pages, a wider margin on the left */
@page :left {
  margin-left: 3cm;
  margin-right: 2cm;
}

@page :right {
  margin-left: 2cm;
  margin-right: 3cm;
}

http://edutechwiki.unige.ch/en/CSS_for_print_tutorial