![enter image description here][1]I have been trying following code in my VF page

<apex:page standardController="Account" extensions="AccController" renderAs="PDF">
 <apex:pageBlock >
    <apex:outputLabel style="font-size:25px; font-style:bold;">{!accountName}</apex:outputLabel>
     <apex:pageBlockSection >
        <apex:repeat value="{!lstField}"  var="f">
            <apex:outputField value="{!lstAccount[0][f]}"/>

Which is showing me fields very random style, which does not look perfect like printable view, is there any way to do this ?


<div class="title">{!ObjectType} - {!account.Name}</div>
      <apex:repeat value="{!lstField}"  var="f">
            <apex:panelGrid columns="4"  border="4" width="100%">
                        <apex:outputLabel value="{!$ObjectType[SobjectApiName].fields[f].Label}"/>
                       <apex:outputField value="{!lstAccount[0][f]}"/>         


![Current Outout ][2]

  • You can use HTML tags and basic CSS - here is an example. It is also possible to reference the labels for the fields dynamically. – Keith C Dec 3 '14 at 8:46
  • New Updated code shows me the record in 2 columns, however I changed the Column="4", since I have used only 2 items in it ! Now, I want 2 fields in one row, check out the new Updated Image too. – Salesforce Steps Dec 3 '14 at 12:23
  • You should use your browser's "View Source" to see the HTML generated. You are probably outputting a succession of tables each containing 2 of the 4 columns you want. Personally, I think its easier to stick to the raw HTML for PDF output and just use things like apex:repeat. – Keith C Dec 3 '14 at 12:57

See Best Practices for Rendering a PDF. <apex: outputField> is on the list of Components That Are Unsafe to Use in a PDF.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.