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
Mike_M_2Mike_M_2 

Bug in PDF getcontent (ordered lists) (list nesting)

This page:

 

<apex:page renderAs="PDF" standardStylesheets="false" >
<ol>
  <li>test1</li>
  <ol>
    <li>test2</li>
  </ol>
  <li>test3</li>
</ol>
</apex:page>

 

 

 

renders like:

1. test1

1. test2

*  test3   (where * is a bullet)

 

It should render like:

 

1. test1

   1.test2

2. test3

 

When I look at the non-pdf version (visualforce page) it renders perfectly.

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Alderete_SFDCAlderete_SFDC

Unfortunately, the current PDF rendering engine is fairly limited. There are all kinds of things that it doesn't render correctly.

 

One of those things is invalid HTML, and I'm afraid that you've got a problem with yours. Try this instead:

 

<ol>
  <li>test1</li>
  <li>
<ol> <li>test2</li> </ol>
</li> <li>test3</li> </ol>

 

Note the <li> wrapping your inner list.

 

When the PDF renderer behaves poorly, it's always worth validating your HTML to make sure you're not making the renderer's job harder unintentionally.

All Answers

Alderete_SFDCAlderete_SFDC

Unfortunately, the current PDF rendering engine is fairly limited. There are all kinds of things that it doesn't render correctly.

 

One of those things is invalid HTML, and I'm afraid that you've got a problem with yours. Try this instead:

 

<ol>
  <li>test1</li>
  <li>
<ol> <li>test2</li> </ol>
</li> <li>test3</li> </ol>

 

Note the <li> wrapping your inner list.

 

When the PDF renderer behaves poorly, it's always worth validating your HTML to make sure you're not making the renderer's job harder unintentionally.

This was selected as the best answer
Mike_M_2Mike_M_2

Wow, I've been working with HTML for for more than 10 years and did not know that rule. I have looked it up at W3C and clearly you are correct. Thanks for the answer and the lesson! Regard

 

PS, that does not give what I want either,

 

It gives:

 

1. test1

2.     1. test2

3.  test3

Alderete_SFDCAlderete_SFDC

Well, darn, you're right that it's not going to give you the outline you're after.

 

I think semantically, it's correct to put the inner list in the <li> for list item #1. So, something like:

 

<ol>
  <li>test1

    <ol>
      <li>test2</li>
    </ol>
  </li>
  <li>test3</li>
</ol>

 

You might want to wrap the parent list item content in a <p>, too, or something like that. So:

 

<ol>
  <li><p>test1</p>

    <ol>...

 

And, apologies for the PDF rendering engine's quirks. It's currently incapable of fixing tiny errors like this one, unlike every browser in common use today. We're very well aware of how painful it is to be limited to the subset of HTML that the PDF renderer supports today. I can say no more...

Mike_M_2Mike_M_2
Got it, makes perfect sense. Thanks again.