1

I am trying to display some HTML(stored as HTML text in rich text field) in to vf page via output text tag. This HTML text has unordered list inside an unordered list(like a nested unordered list). It is working fine in normal preview but when i render as PDF, it is displayed as one single unordered list instead of nested one.

PFB, the HTML text.

<div>test data</div><div><ul><li>This is line number 1</li><ul><li>This is line number 1.1</li><li>This is line number 1.2</li></ul></ul><div><br></div></div><div><ul><li>This is line number 2</li></ul><div><br></div></div>

VF page

<apex:page renderAs="pdf" controller="TsetVFController" id="myPage" applyHtmlTag="false" showHeader="false" > 
    
<h1> 
Test Code 
</h1> 
   
<apex:outputText value="{!analysis}" escape="false" /> 

</apex:page>

Controller

public with sharing class TsetVFController { 
    public String analysis {get; set;}
    public TsetVFController (){ 
        analysis = '<div>test data</div><div><ul><li>This is line number 1</li><ul><li>This is line number 1.1</li><li>This is line number 1.2</li></ul></ul><div><br></div></div><div><ul><li>This is line number 2</li></ul><div><br></div></div>';
    } 
}

Above is when previewed normally rendered normally

Above is when rendered as pdf rendered as pdf

i need the nested list in pdf as well. can anyone help.

2
  • You could try to change the API version of the VF page to 27 - seems to render PDF's better than most other API versions. Can change this version under Setup --> Visualforce Pages --> Edit --> Version Settings tab
    – Instread
    Aug 20, 2020 at 19:19
  • @Instread I changed the version to 27 but no use. It is still the same
    – Sisir
    Aug 20, 2020 at 19:52

1 Answer 1

1

Tested this with a rich text field, and the nested indentation renders in the PDF normally. If you're using the "analysis" HTML string variable like in your example, the closing LI for the "This is line number 1" list item needs to move to the end of the nested/indented UL

Original code:

analysis = '<div>test data</div><div><ul><li>This is line number 1</li><ul><li>This is line number 1.1</li><li>This is line number 1.2</li></ul></ul><div><br></div></div><div><ul><li>This is line number 2</li></ul><div><br></div></div>';

Amended code:

analysis = '<div>test data</div><div><ul><li>This is line number 1<ul><li>This is line number 1.1</li><li>This is line number 1.2</li></ul></li></ul><div><br></div></div><div><ul><li>This is line number 2</li></ul><div><br></div></div>';
1
  • Yes i get the proper indentation when i change the HTML text as you mentioned. But the problem is, users copay and paste the content in to Rich text field. some of which has the HTML structure as the one i mentioned. Problem is for those copied content. when previewed it is fine but when rendered as pdf it is breaking.
    – Sisir
    Aug 21, 2020 at 10:17

You must log in to answer this question.

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