Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Mar 17, 2020 7:29 am

Hi,

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>&shy;</p> // Should print an invisible character. Results in Spire.PDF hanging (no output, no errors)
<p>&zwnj;</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

jani.karna@cubiq.fi
 
Posts: 2
Joined: Fri May 17, 2019 6:23 am

Tue Mar 17, 2020 9:54 am

Hello,

Thanks for your inquiry.
I did notice that the <br> tag of the inserted HTML text was not parsed correctly. This issue has been logged into our bug tracking system with the ticket SPIREPPT-1097 for further investigation. If there is any update, we will inform you. Sorry for the inconvenience caused.

Besides, regarding inserting some invisible characters you mentioned, I tested the below code with the latest Spire.Presentation Pack Hotfix Version:5.2.1, the program didn't hang and the empty lines could be rendered. Attached is my output file. If you are using an old version, I suggest you could download the latest version and try again.
Code: Select all
            Presentation ppt = new Presentation();
            IAutoShape shape = ppt.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 50, 400, 100));
            shape.TextFrame.Paragraphs.Clear();
            string formattedComment = "<p>Lorem ipsum dolor sit amet,</p>" +
                    "<p>consectetur adipiscing elit, </p>"+
                    "<p>  </p>" +
                    "<p>&shy;</p>" +
                    "<p>&zwnj;</p>" +
                    "<p>sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p>";
            string htmlText = "<html><body><font color='black'><div style='font-size:12px'>" + formattedComment + "</div></font></body></html>";
            shape.TextFrame.Paragraphs.AddFromHtml(htmlText);
            ppt.SaveToFile("output.pptx", FileFormat.Pptx2013);


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Wed Mar 18, 2020 6:27 am

Thank you for a quick reply.

I tried the latest hot fix version and it indeed works as desired when using &zwnj; character. Thank you!

The version we used previously was 4.4.0.

Good luck with getting <br/> tag to work properly.

br,
Jani

jani.karna@cubiq.fi
 
Posts: 2
Joined: Fri May 17, 2019 6:23 am

Wed Mar 18, 2020 6:38 am

Hello,

Thanks for your feedback.
Once there is any good news about the issue SPIREPPT-1097, we will let you know ASAP.
Wish you a nice day!

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Mar 20, 2020 9:26 am

Hello,

Hope you are doing well.
Glad to inform that we just released Spire.Presentation Pack Hotfix Version:5.3.6, which fixed the bug SPIREPPT-1097. Welcome to download it from the following link.
Our website: https://www.e-iceblue.com/Download/down ... t-now.html
Nuget: https://www.nuget.org/packages/Spire.Presentation/5.3.6

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Thu Mar 26, 2020 9:04 am

Hello,

Greetings from E-iceblue.
Have you tested the hotfix? Does it resolve your issue?
Any feedback will be greatly appreciated!

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.PDF