We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Pdf.Generator.Text.IsHtmlTagSupported and text segments strange behaviour


In Aspose.Pdf, when adding several Segments to a Text object that has the property IsHtmlTagSupported sets to true, only the first segment is rendered in the pdf.

Using the sample code below, I’ve been able to reproduce this behaviour with Aspose.Pdf 5.4 and 6.0

        static void Main(string[] args)
Pdf pdf = new Pdf();
Section section = pdf.Sections.Add();
        <span style="color:green;">// Don't work, prints only "Hello"</span>
        <span style="color:#2b91af;">Text</span> text1 = <span style="color:blue;">new</span> <span style="color:#2b91af;">Text</span>();
        text1.IsHtmlTagSupported = <span style="color:blue;">true</span>;
        text1.Segments.Add(<span style="color:#a31515;">"Hello"</span>);
        text1.Segments.Add(<span style="color:#a31515;">" world!"</span>);

        <span style="color:green;">// Works, prints "Hello world!"</span>
        <span style="color:#2b91af;">Text</span> text2 = <span style="color:blue;">new</span> <span style="color:#2b91af;">Text</span>();
        text2.IsHtmlTagSupported = <span style="color:blue;">false</span>;
        text2.Segments.Add(<span style="color:#a31515;">"Hello"</span>);
        text2.Segments.Add(<span style="color:#a31515;">" world!"</span>);

        <span style="color:green;">// Works, prints "Hello world!"</span>
        <span style="color:#2b91af;">Text</span> text3 = <span style="color:blue;">new</span> <span style="color:#2b91af;">Text</span>();
        text3.IsHtmlTagSupported = <span style="color:blue;">true</span>;
        text3.Segments.Add(<span style="color:#a31515;">"Hello world!"</span>);

        <span style="color:blue;">using</span> (<span style="color:#2b91af;">Stream</span> s = <span style="color:blue;">new</span> <span style="color:#2b91af;">FileStream</span>(<span style="color:#a31515;">@"c:\temp\test.pdf"</span>, <span style="color:#2b91af;">FileMode</span>.OpenOrCreate, <span style="color:#2b91af;">FileAccess</span>.ReadWrite))
    }</pre><pre style="font-family:Consolas;font-size:13;color:black;background:white;"><br></pre><pre style="font-family:Consolas;font-size:13;color:black;background:white;">Any idea ? Am I doing something wrong ?</pre><pre style="font-family:Consolas;font-size:13;color:black;background:white;">Thanks</pre></div>

Hello Pascal,

Thanks for using our products.

I have tested the scenario and I am able to notice the same problem. For the sake of correction I have logged it as PDFNET-29187 (for Aspose.Pdf for .NET 5.4.0) and PDFNEWNET-29188 (for Aspose.Pdf for .NET 6.0.0) in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

PS, The problem is occurring in version 6.0.0 because the same code of v5.4.0 has been ported into this Aspose.Pdf for .NET 6.0.0.

The issues you have found earlier (filed as PDFNEWNET-29188) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.