we are using Spire.PDF to fill a powerpoint template file (PPTX) with images and text to existing shapes.
We are inserting user provided text in HTML format. We now have a problem where empty lines are not rendered at all.
Consider the following text:
Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
The empty line is not rendered to the powerpoint. The result for this text would be:
Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
The HTML formatting in this example would be like this (coming from an html editor in our app):
- Code: Select all
<p>Lorem ipsum dolor sit amet,</p>
<p>consectetur adipiscing elit, </p>
<p><br></p>
<p>sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p>
And the code we use to insert the text to an existing shape is like this:
- Code: Select all
IAutoShape commentsShape = (IAutoShape)ppt.Slides[0].Shapes[0];
commentsShape.TextFrame.Paragraphs.Clear();
commentsShape.TextFrame.Paragraphs.AddFromHtml("<html><body><font color='black'><div style='font-size:12px'>" + formattedComment + "</div></font></body></html>");
We have tried multiple ways to get an empty line. I list here some of what we have tried:
- Code: Select all
<p><br><p>
<p><br/></p>
<br>
<br/>
<p style="height:30px;"></p>
<p style="height:30px; display: block;"></p>
<p style="white-space: pre-line;"></p>
If there is any content inside <p></p> tags, the content will be rendered, taking one line of space. We tried some characters that should result in invisible content:
- Code: Select all
<p> </p> // Contains an invisible character in unicode format. Results in Spire.PDF hanging (no output, no errors)
<p>­</p> // Should print an invisible character. Results in Spire.PDF hanging (no output, no errors)
<p>‌</p> // Should print an invisible character. Results in Spire.PDF hanging (no output, no errors)
There IS one way we were able to make what appears as an empty line:
- Code: Select all
<p style="color: white">'</p>
You know what this means. Looks like an empty line assuming the background color of the shape is white. When the text is copied to a notepad, the quote marks appear and the magic is dissolved
Help would be appreciated.
br,
Jani