Dec 4, 2010

Header Footer in PDF

Hi All,

It is about how we can put header and footer in a visual force page which is rendered as PDF.

<head>

<style>

@page {
    margin : 70pt .5in .5in .5in;
    @top-center {
        content : "My Header";
     }
    @bottom-left {
        content : "My Footer on Left Side";
        font-size : 10 px;
        color : #808080;
    }
    @bottom-center {
        content : "My Footer in center" ;
        font-size : 10 px;
        color : #808080;
    }
}

</style>

</head>

Now if we want to add a image in header then add:

@top-center {
        content : element(header);
     }

div.header {
    position : running(header) ;
}

in style and

<div class="header">
    <apex:image value="Image URL" />
</div>

before the body. We can also change font-size , font family , color etc of page using @page style.

Thanks

2 comments:

  1. My Requirement is "Generate a PDF file on opportunity record, PDF contains Header with name & address, body contains Product Items - product name, qty and price, Footer contains the address of the organisation."

    i.e., Detail Page must have a command button, whenever it is clicked a pdf has to be generated in such a way that Opportunity name has to appear on header, opportunity product name, qty, price has to appear on body, Address in the footer

    Please help me regarding this requirement.

    If you can, please email me the code

    ReplyDelete
  2. i have created user in partner portal,their if i click the home tab displaying Dashboard details,when same user login in communities ,home tab clicking dashboard details are not displaying ,plz let me know the reason

    reply to giri.arni@gmail.com

    ReplyDelete