Showing posts with label Static Resource. Show all posts
Showing posts with label Static Resource. Show all posts

Friday, June 1, 2012

Static Resource vs Document


Static Resources v/s Documents:

  1. Static resources are data cached and you can refer them easily in VF (including zip files) which store on Sales force server.
  2. Static Resources and Documents are having an absolute limit of 5MB for each document.
  3. You can package a collection of related files into a directory hierarchy and upload that hierarchy as a .zip or .jar archive), images, style sheets, JavaScript, and other files.
  4. You can reference a static resource by name in page markup by using the $Resource global variable instead of hard-coding document IDs.
  5. JavaScript or CSS is preferable to including the markup inline. Managing this kind of content using static resources allows you to have a consistent look and feel for all your pages and shared set of JavaScript functionality.

Referencing a Static Resource in Visualforce Page:

<apex:image url="{!$Resource.TestImage}" width="50" height="50" />
or
<apex:includeScript value="{!$Resource.MyJavascriptFile}"/>

Friday, March 9, 2012

Header Footer in PDF

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.