Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am trying to make a visualforce page with a border that renders as a PDF. Currently, there are 2 sets of tables within the visualforce page, both of which can have variable sizes depending on the results of a search. I would like to have a border on each page of the pdf, regardless of how many pages it goes to.

Here is my code:

<apex:page controller="SearchController" sidebar="false" renderAs="PDF" showHeader="false" >    
    <apex:form style="border:10px double #990033;">
<apex:pageMessages id="errors" />

<apex:pageBlock mode="edit" id="results"> 
   <div style="display: block;min-height: 9.25in;padding: 15px;">
      <table width="100%" border="0">
          <tr>  

            <td valign="top">

                <apex:image url="{!DocumentLogoUrl}" width="256" height="175" style="display: block;margin-left: auto;margin-right: auto; padding:25px;"/>

                <p>Search Results</p>

                <p><u>Town:</u><b> {!curTown}</b>

        <apex:pageBlockTable value="{!contacts}" var="contact">

             <apex:column width="25%" >
                <apex:facet name="header">
                    <apex:outputLabel value="Contact">
                    </apex:outputLabel>
                </apex:facet>
                <apex:outputLabel value="{!contact.firstname}"/>
             </apex:column>

             <apex:column width="25%">
                <apex:facet name="header">
                    <apex:outputLabel value="Owner">                     
                    </apex:outputLabel>
                </apex:facet>
                <apex:outputField value="{!contact.owner.name}"/>
            </apex:column>
          </apex:pageBlockTable>
        </td>
        </tr>
     </table>   
 </div>
</apex:pageBlock>

</apex:form>
</apex:page>

In this example, the towns listed can be of any length and the table of contacts and owners can also be of any length. I would like the border to go around each page. Currently,it gets cut off at the first page and continues onto the last page and ends there. Any suggestions?

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

Try to add a border to the @page css rule (the page area includes the boxes laid out on that page). Because of the page area the border will be drawn on each generated page:

<apex:page renderAs="pdf"
           applyHtmlTag="false" 
           showHeader="false" 
           cache="true"
           readOnly="true">

    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <style type="text/css">
    @page {
        size:A4 portrait;
        border: 2px solid black;    
    }
    </style>
    </head>

    Your content here...

</apex:page>

Image

share|improve this answer
    
Thank you!!! I finally got this working- it seems like there may be a bug with using css in the page with the <style> tag, it wouldn't work like this, but when I created a style sheet as a separate static resource this worked great! Thanks again! –  Katie Swol Apr 8 at 19:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.