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
Salesforce 283Salesforce 283 

Add horizontal lines each table row in PDF

Hi Guys,
      How to apply horizontal lines each row in PDF(not normal visualforce page). Please help me out this problem.


Thanks,
Mahesh.
  
Alexander TsitsuraAlexander Tsitsura
Hi dev,

You can add border attribute to your apex:pageBlockTable.
 
<apex:page controller="PdfController" renderAs="pdf">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!accounts}" var="a" border="1">
            <apex:column value="{!a.Name}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>


As a common practice, if your question is answered, please choose 1 best answer. 
But you can give every answer a thumb up if that answer is helpful to you.

Thanks,
Alex
 
Alexander TsitsuraAlexander Tsitsura
Or you can use style for set border
style="border:1px solid black"
Alex
Salesforce 283Salesforce 283
Hi Alexander, I have not used pageblocktable. Take one table which has header and some rows and need to display horizontal lines each row except header in PDF. Regards, Mahesh.
Alexander TsitsuraAlexander Tsitsura
You can create style for it

Please see my example below
 
<apex:page showheader="false" sidebar="false" applyHtmlTag="false" renderAs="pdf">
    <head>
        <style type="text/css">
            table {
                border-collapse:collapse;
                border-width: 1px;
                border-color: #000000;
            }
            table tr {
                border-width: 1px;
                border-style: solid;
                border-color: #000000;
            }
            table td {
                border-width: 1px;
                border-style: solid;
                border-color: #000000;
            }
         </style> 
     </head>

    <apex:pageBlock >
        <table >
            <tr>
                <td>row 1 col 1</td>
                <td>row 1 col 2</td>
            </tr>
            
            <tr>
                <td>row 2 col 1</td>
                <td>row 2 col 2</td>
            </tr>
        </table>
    </apex:pageBlock>
</apex:page>


Thanks,
Alex