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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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">

            <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 value="{!contact.firstname}"/>

             <apex:column width="25%">
                <apex:facet name="header">
                    <apex:outputLabel value="Owner">                     
                <apex:outputField value="{!}"/>


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
up vote 5 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"

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

    Your content here...



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 '14 at 19:59

Your Answer


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.