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
Niki Shah 12Niki Shah 12 

how to use external css on pdf page

I create a pdf page now i want to use external css on pdf page.i used give to link for boot streap but it's not working.
Raj VakatiRaj Vakati
Render as PDF does not handle external CSS . Please download them and add to Static Resources 

https://developer.salesforce.com/forums/?id=906F0000000BYVjIAO
Niki Shah 12Niki Shah 12
It's not woking
 
Raj VakatiRaj Vakati
Give me your code .. Can you please download the bootstrap and upload them using static resource and try 
NanduNandu
Hi Niki shah,

you can try below code...
 
<apex:page renderAs="pdf" showHeader="false" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false">
    <html>
    <head>
        <style>
            @page {
                size: letter;
                margin: 25mm;
                @top-center {
                    content: "Sample";
                }
                @bottom-center {
                    content: "Page " counter(page) " of " counter(pages);
                }
            }
            .page-break {
                display:block;
                page-break-after:always;
            }
            body {
                font-family: Arial Unicode MS;
            }
        </style>
    </head>
    <body>
    <div class="page-break">Page A</div>
    <div class="page-break">Page B</div>
    <div>Page C</div>
    </body>
   </html>
</apex:page>
Ajay K DubediAjay K Dubedi
Hi Niki,
You can use external css on pdf page through static resources.
How to Use external css in Visual force Pages
Step 1: Create a CSS file.
Open NOTEPAD or any text editor and type the following code:
h1
{
color:green;
}
Save the file with a .css extension (say CssExample.css)
Step 2:
Upload the saved file as a Static resource.
Setup -> Develop -> Static Resources and click on NEW.
Give a name for the static resource say CssExample. Remeber to set the Cache Control as "Public".
Step 3:
Create a visualforce page and paste the following code..
<apex:page standardstylesheets="false" showheader="false">
<apex:stylesheet value="{!$Resource.CssExample}"/>
<h1> This text is displayed using CSS </h1>
</apex:page>
Save the page. Now you can see that the text within <h1> tag is displayed in GREEN color because you have specified so in the CSS file.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi