We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

InsertXHTML error: The 'img' start tag on line 1 position 95 does not match the end tag of 'p'.

Thread ID:

Created:

Updated:

Platform:

Replies:

148432 Oct 18,2019 07:23 PM UTC Oct 21,2019 06:06 AM UTC ASP.NET Core - EJ 2 1
loading
Tags: DocIO
Michael
Asked On October 18, 2019 07:23 PM UTC

I am trying to insert HTML that has an image embedded in it, the image is about 86 K

HTML looks something like:

<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmwAAAHvCAYAAADpWYPOAAAAAXNSR0I..........mCC"></p>

And I get this error:

System.NotSupportedException
  HResult=0x80131515
  Message=DocIO support only welformatted xhtml
Details:
The 'img' start tag on line 1 position 95 does not match the end tag of 'p'. Line 1, position 86886.

This is the C# code I use:

        public static void MergeFieldEvent(object sender, MergeFieldEventArgs args)
        {
            if (args.FieldName.Equals("Appendix"))
            {
                WParagraph paragraph = args.CurrentMergeField.OwnerParagraph;
                int paraIndex = paragraph.OwnerTextBody.ChildEntities.IndexOf(paragraph);
                int paraItemIndex = paragraph.ChildEntities.IndexOf(args.CurrentMergeField);

                string html_string = args.FieldValue.ToString();
                html_string = html_string.Replace("<br>", "<br />");

                paragraph.OwnerTextBody.InsertXHTML(html_string, paraIndex, paraItemIndex);
                args.Text = string.Empty;
            }
        }

Can you please help solving this problem?


Poorani Rajendran [Syncfusion]
Replied On October 21, 2019 06:06 AM UTC

Hi Michael,

Thank you for contacting Syncfusion support.

Essential DocIO supports only well-formatted HTML file. While inserting HTML string, it should be in standard format (HTML is in proper XML). While analyzing the given HTML string, it is not a proper XML (there is no end tag of <img> tag). So, the exception occurs at your end.

So, to resolve this problem at your end, please modify the HTML string into standard format before inserting into the paragraph. We have modified your HTML string into standard format.

Please use the below modified HTML string:

 
"<p><img src=\"data: image / png;base64,iVBORw0KGgoAAAANSUhEUgAAAmwAAAHvCAYAAADpWYPOAAAAAXNSR0I..........mCC\"></img></p>” 

Please refer our UG documentation to know more about working with HTML using DocIO:
https://help.syncfusion.com/file-formats/docio/html

Please let us know if you have any other questions.

Regards,
Poorani Rajendran
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon