Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Mar 14, 2017 3:51 pm

Hello

This is a bit of a strange issue.. i hope i explain it well:

When appending html to a paragraph spire.doc is sticking the first <p> of the html at the bottom of the paragraph! It’s a bit hard to explain so ill let the code speak:

This is a sample of HTML:
<p ><span style="font-family: Book Antiqua;"><strong><span style="text-decoration: underline;">HISTORY:</span></strong> </span></p>
<p ><span style="font-family: Book Antiqua;">&nbsp;</span></p>
<p ><span style="font-family: Book Antiqua;">His&nbsp;initial complaints included&nbsp;<span style='font-family:Times New Roman; font-size:12pt; font-weight: normal; font-style: normal; text-decoration: none; color: #000000; background-color: #FFFFFF;'>low back, left shoulder, right shoulder, left arm, right arm, left elbow and right elbow</span>&nbsp;pain.</span></p>

Code: Select all
using(Document report = new Document())
                            {
                                Section rSection = report.AddSection();
                                report.Sections.Add(rSection);
                                rParagraph.AppendHTML(sectionText); // sectionText equals the html I pasted above //
                                rSection.Paragraphs.Add(rParagraph);
                                report.SaveToFile(reportFullPath);
}


So instead of showing:

HISTORY:
His initial complaints included low back, left shoulder, right shoulder, left arm, right arm, left elbow and right elbow pain.

Its showing like this:

His initial complaints included low back, left shoulder, right shoulder, left arm, right arm, left elbow and right elbow pain.
HISTORY:

Any idea??? Please help!

Thanks
Roy

shakazulu89
 
Posts: 4
Joined: Sun Nov 27, 2016 11:05 am

Wed Mar 15, 2017 3:57 am

Hello,

Thanks for your inquiry. There is some wrong with your code,the line"rSection.Paragraphs.Add(rParagraph); " is not needed, so please type the following code snippet.

Code: Select all
                Section rSection = report.AddSection();
                rSection.AddParagraph().AppendHTML(sectionText);
                report.SaveToFile(reportFullPath);


If there are any questions, please contact us.

Sincerely,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Return to Spire.Doc