0

I have a table created in Visualforce page and rendered as a PDF. There are columns where long texts (with no whitespaces) can exist. However, it seems impossible to make these texts to wrap so that it doesnt overflow to the next column. I have tried different CSS properties such as below but none seem to work

.my-style {
   white-space: normal;
   word-wrap: break-word;
   overflow-wrap: break-word;
}

My problem is similar to this question Wrap a long line of text that is without spaces in visualforce rendered as pdf and from some searching, this seems to be a known issue when rendering a Visualforce as PDF before. But I wanted to know if this is something that has been fixed already / has a work around?

1
  • word-wrap/overflow-wrap is CSS Level 3, which is not supported by the PDF renderer. As far as I'm aware, there's no CSS workaround.
    – sfdcfox
    Dec 9, 2021 at 17:09

1 Answer 1

2

Salesforce uses the Flying Saucer library to convert Visualforce pages to PDF.

Flying Saucer only supports up to CSS 2.1.

word-wrap and overflow-wrap were introduced in CSS 3, and are thus not supported.

white-space: normal appears to be the default, was introduced in CSS 2.1, and it does wrap words, but it requires whitespace.

If you don't have whitespace, there's nothing you can do with CSS to make your PDF render the way you want it to.

About the only thing I can think of here would be to choose a moderate number of letters that you can safely display in a column (without overflowing), and then process your text in a custom controller (or controller extension) to insert line breaks after every X characters.

1
  • Thanks for this info. I'll see what I can come up with regarding processing the texts in a controller.
    – ancrila
    Dec 10, 2021 at 9:18

You must log in to answer this question.

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