Generated word document is not as per the expectation

Hi ,
I am generating Word document through HTML but it not as per the expectation.some part of content is missing.

var doc1 = new Aspose.Words.Document();
var builder = new Aspose.Words.DocumentBuilder(doc1);
InsertHeaderFooter(builder.CurrentSection, HeaderFooterType.FooterPrimary);
InsertHeaderFooter(builder.CurrentSection, HeaderFooterType.HeaderFirst);
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.PageSetup.PageStartingNumber = 1;
builder.PageSetup.RestartPageNumbering = true;
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.Write("Page ");
builder.InsertField("PAGE", string.Empty);
builder.MoveToDocumentEnd();

HttpResponse resp = HttpContext.Current.Response;
resp.Clear();
resp.ClearHeaders();
resp.ContentType = "application/word";

doc1.Save(resp.OutputStream, Aspose.Words.SaveFormat.Docx);

----------------------------------
In HTML I am able to see main question and 5 sub questions but when I assign same HTML to ASPOSE word then it generates the word document which contain main question and only 3 sub questions.
Currently I am using 1 month temporary license,Kindly correct me if I did something wrong.

Hi Sanjay,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Html document
  • Please attach the output Word file that shows the undesired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click ‘Reply’ button that will bring you to the ‘reply page’ and there at the bottom you can include any attachments with that post by clicking the ‘Add/Update’ button.

Awaiting for your reply ,As you requested I sent you the HTML and Generated word document in my last replied.
Could you please response on this ASAP ,as I sent it 3 days back and still no reply.

Hi Sanjay,

Thanks for your inquiry. Unfortunately, we have not found any documents in this forum thread. Could you please share the requested detail here for testing?

PS: To attach these resources, please zip them and Click ‘Reply’ button that will bring you to the ‘reply page’ and there at the bottom you can include any attachments with that post by clicking the ‘Add/Update’ button.

Sending the documents once again.

Hi Sanjay,

Thanks for sharing the documents. Your input document contains table row with style “page-break-inside:avoid;”. Please remove this style from the TR tag or set it to page-break-inside:auto;. You can also generate the desired output by setting value of RowFormat.AllowBreakAcrossPages property to true. Please check following code example. Hope this helps you.

Document doc = new Document(MyDir + "test.htm");
foreach (Row row in doc.GetChildNodes(NodeType.Row, true))
{
    row.RowFormat.AllowBreakAcrossPages = true;
}
doc.Save(MyDir + "Outv16.4.0.docx");

Thanks ! its working
But as I am using Document builder ,SO how can I use the same code for document builder.
I am passing HTML string in document builder by InsertHTML method.

Document doc = new Document(MyDir + "test.htm");
foreach (Row row in doc.GetChildNodes(NodeType.Row, true))
{
    row.RowFormat.AllowBreakAcrossPages = true;
}
doc.Save(MyDir + "Outv16.4.0.docx");

Its Done…Thanks

Hi

I am sending you my HTML and Output Word document.

HTML seems perfect but when I generate Word document through ASPOSE with the help of HTML, then design got distorted. Rectangles are not coming properly.

Please let me know on this.

Hi Sanjay,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. If you convert your html to Word document using MS Word, you will get the same output.

The border is applied to paragraph in your input document. You can remove this border using following code example. Hope this helps you.

Document doc = new Document(MyDir + "test.htm");
foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
{
    para.ParagraphFormat.Borders.ClearFormatting();
}
doc.Save(MyDir + "Outv16.4.0.docx");