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.

Wed Sep 22, 2021 12:03 pm

Hello,
In the application we are working on, when generating document sometimes we have to render paragraphs by using HTML. in most cases the document get renderd correctly ( all the contant stay with in the page margin) however in some cases it won't appear like we expect it to be.
below demonstrate my code
Code: Select all
string htmlString = "CHECK BELOW FOR FULL HTML CODE";
Section workingSection = _agendaDocument.Sections[0];
Paragraph cellTwoPara = workingSection.AddParagraph();
cellTwoPara.AppendHTML(htmlString);

cellTwoPara.Format.HorizontalAlignment = HorizontalAlignment.Justify;
cellTwoPara.ApplyStyle("EcuriaBodyStyle");
cellTwoPara.Format.AfterAutoSpacing = false;
cellTwoPara.Format.AfterSpacing = 15;



My SAMPLE HTML CODE
Code: Select all
<ol style="margin-top:0;margin-bottom:0;">
<li style="text-align:justify;margin:0pt 0pt 0pt 0pt;list-style-type:decimal;color:#000000;background-color:transparent;font-family:Calibri;font-size:11pt;font-weight:bold;font-style:normal;">
<span style="color:#000000;background-color:transparent;font-family:Calibri;font-size:11pt;font-weight:bold;font-style:normal;">That the deputation be received and noted.</span></li>
<li style="text-align:justify;margin:0pt 0pt 0pt 0pt;list-style-type:decimal;color:#000000;background-color:transparent;font-family:Calibri;font-size:11pt;font-weight:bold;font-style:normal;"><span style="color:#000000;background-color:transparent;font-family:Calibri;font-size:11pt;font-weight:bold;font-style:normal;">That </span><span style="color:#000000;background-color:#C0C0C0;font-family:Calibri;font-size:11pt;font-weight:bold;font-style:normal;">(residents name)</span><span style="color:#000000;background-color:transparent;font-family:Calibri;font-size:11pt;font-weight:bold;font-style:normal;"> be thanked for his/her/their presentation and any notes that comply with Council&#39;s Code of Practice for Meeting Procedures and the laws of defamation, be included in the Minutes.</span></li></ol>


Below is the actual output
screenshot_paragraph_issue.png


This is the expected output
screenshot_paragraph_expected.png

infra
 
Posts: 18
Joined: Tue Apr 03, 2018 12:05 pm

Thu Sep 23, 2021 7:46 am

Hello,

Thanks for your inquiry.
Please refer to the following code.
Code: Select all
            Section workingSection = _agendaDocument.Sections[0];
            int count = workingSection.Paragraphs.Count;
            Paragraph cellTwoPara = workingSection.AddParagraph();
            cellTwoPara.AppendHTML(htmlString);
            for (int i = count; i < workingSection.Paragraphs.Count; i++)
            {
                Paragraph para = workingSection.Paragraphs[i];
                para.Format.HorizontalAlignment = HorizontalAlignment.Justify;
                para.ApplyStyle("EcuriaBodyStyle");
                para.Format.AfterAutoSpacing = false;
                para.Format.AfterSpacing = 15;
                para.Format.FirstLineIndent = 0;
                para.Format.LeftIndent = 0;
            }

If this does not help you, please provide your input file (if any) and your complete code to help us investigate further. You can send them to us (support@e-iceblue.com) via email. Thanks in advance for your assistance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Thu Sep 23, 2021 8:35 am

Hello Brian,
Your solution worked perfectly
btw your for loop has to start from 0 not from the count.

but i had to adjust the intends just before saving the document.

thank you very much. you saved my day !!

infra
 
Posts: 18
Joined: Tue Apr 03, 2018 12:05 pm

Thu Sep 23, 2021 9:08 am

Thanks for your feedback.

If you encounter any issues related to our products in the future, please feel free to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.Doc