Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Wed Mar 16, 2016 3:07 pm

Hi,
I'm evaluating the Spire Presentation and I'm looking for the possibility to insert an HTML formatted text inside a shape.

Is it possible?

Best regards,
Luca

luca.vassallo
 
Posts: 7
Joined: Wed Mar 16, 2016 10:07 am

Thu Mar 17, 2016 3:09 am

Hi Luca,

Thanks for your posting.
Please try the below method.
Code: Select all
shape.TextFrame.Paragraphs.AddFromHtml(html);


Best Regards,
Amy
E-iceblue Support Team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Thu Mar 17, 2016 9:47 am

Hi Amy,
thanks for the support, it works (with valid XHTML).

No way to mantain the formatted text? May be useful to mantain characters and paragraphs html tags.

Best Regards,
Luca

luca.vassallo
 
Posts: 7
Joined: Wed Mar 16, 2016 10:07 am

Fri Mar 18, 2016 2:11 am

Hi Luca,

Thanks for your feedback.
Please share your formatted html text which you want to mantain to help us know your issue.
Thank you.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Fri Mar 18, 2016 5:36 pm

Hi Amy,
the html is entered by the user with a html form and is not well formed. It contains a lot of "malformed" tags because the users made cut and paste from word...

This is an example that throw error when you try to append it to a shape:
Code: Select all
<html><body>                       <p>
                    <font color="#000000" face="Times New Roman" size="3">
</font></p><p style="margin: 0cm 0cm 0pt 18pt;"><span style='font-family: "Arial",sans-serif; font-size: 14pt; mso-bidi-font-style: italic;'><font color="#000000">Nel periodo
considerato sono state effettuate:</font></span><span style='font-family: "Arial",sans-serif; font-size: 8pt; mso-bidi-font-style: italic;'><font color="#000000">&nbsp;</font></span></p><ul><li style="margin: 0cm 0cm 0pt 18pt;"><b style="mso-bidi-font-weight: normal;"><span style='color: red; font-family: "Arial",sans-serif; font-size: 14pt; mso-bidi-font-style: italic;'>n. 196 Verifiche</span></b></li></ul><p style="margin: 0cm 0cm 0pt 18pt;"><span style='font-family: "Arial",sans-serif; font-size: 14pt; mso-bidi-font-style: italic;'>così suddivise:</span><span style='font-family: "Arial",sans-serif; font-size: 10pt; mso-bidi-font-style: italic;'>&nbsp;</span></p><ul><li style="margin: 0cm 0cm 0pt 18pt;"><b style="mso-bidi-font-weight: normal;"><span style='color: red; font-family: "Arial",sans-serif; font-size: 14pt; mso-bidi-font-style: italic;'>n.</span></b><b style="mso-bidi-font-weight: normal;"><span style='font-family: "Arial",sans-serif; font-size: 14pt; mso-bidi-font-style: italic;'> <span style="color: red;">43
verifiche</span></span></b><span style='color: red; font-family: "Arial",sans-serif; font-size: 14pt; mso-bidi-font-style: italic;'> <b style="mso-bidi-font-weight: normal;">Snam</b></span><span style='font-family: "Arial",sans-serif; font-size: 14pt; mso-bidi-font-style: italic;'> su attività documentali in </span><span style='font-family: "Arial",sans-serif; font-size: 14pt; mso-bidi-font-style: italic;'>conformità alle norme</span></li></ul><ul><span style='font-family: "Arial",sans-serif; font-size: 14pt; mso-bidi-font-style: italic;'>UNI EN ISO <span style="mso-spacerun: yes;">&nbsp;&nbsp;</span>9001 – Qualità <br></span><span style='font-family: "Arial",sans-serif; font-size: 14pt; mso-bidi-font-style: italic;'>UNI EN ISO 14001 – Ambiente <br></span><span style='font-family: "Arial",sans-serif; font-size: 14pt; mso-bidi-font-style: italic;'>UNI EN ISO 18001 – Sicurezza <br></span><font color="#000000"><span style='font-family: "Arial",sans-serif; font-size: 14pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-ansi-language: IT; mso-fareast-language: IT; mso-bidi-language: AR-SA;'>UNI EN ISO 50001 – Energia</span></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </ul></body></html>


So, I get the decision to save the HTML to an image and then include the image inside the presentation:

Code: Select all
Image image = TheArtOfDev.HtmlRenderer.WinForms.HtmlRender.RenderToImage(html, 650, 400);
System.IO.Stream imageStream = image.toStream(ImageFormat.Png);
RectangleF rect = new RectangleF(40, 80, image.Width, image.Height);
IEmbedImage embImage = slide.Shapes.AppendEmbedImage(ShapeType.Rectangle, imageStream, rect);
embImage.ShapeLocking.AspectRatioProtection = true;


You can close the issue.

Thanks for the support.

Best Regards,
Luca

luca.vassallo
 
Posts: 7
Joined: Wed Mar 16, 2016 10:07 am

Mon Mar 21, 2016 2:05 am

Hi Luca,

Thanks for your reply.
I am glad that you found out a solution.
Welcome to write to us again for further problems.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Presentation