0

I a m trying to get a visualforce page as a pdf page, i am using some css code also, but on pdf page no css class is added to fields, but inline css i can add to fields, someone tell me how to add css classes with fields.

1 Answer 1

3

You can add CSS via a static resource. There is more in the developer force article Creating Professional PDF Documents with CSS and Visualforce.

Use the apex:stylesheet tag along with the URLFOR function to access the static resource. For example, with a static resource of advancedpdfresource that has a css file in it called qstyles.css do:

<apex:stylesheet value="{!URLFOR($Resource.advancedpdfresource, 'qstyles.css')}"/>.

Then in your code you can use the class attribute if you are using normal HTML elements or the styleClass attribute if you are using supported standard components (e.g., apex:outputPanel, etc.). For example:

<apex:outputText value="{!myControllerProperty}" styleClass="myCssClass" />

If you are having trouble, one helpful way to troubleshoot can be to render the PDF as html instead and inspect it with a browser tool such as the Chrome developer console to see what's going on with the styles.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .