I am converting my HTML document to word document by using aspose.words in .NET. For that,I am using page break css in my style sheet and it’s not working with the converted word document.
this is my css css.PNG (6.0 KB)
this is my HTML part which is not working with the above css.
html.PNG (16.1 KB)
this is the word document section which has the issue.
word.PNG (32.1 KB) in this image you can see the “top sales” header . I want to get that header to the next page without break. If some header topic display like this in the document , I want to get it to the next page.
why that CSS is not working with the converted document??Could you please help me to solve this?
@nethmi Could you please attach your HTML document here for testing? We will check the issue and provide you more information.
You can insert page break into HTML document using the following HTML tag:
<br style="page-break-before:always; clear:both" />
Hii
still getting that issue.word.PNG (32.1 KB)
this is my html document and css file.HTMLandCSS.zip (3.6 KB)
@nethmi Thank you for additional information. the problem occurs because you you set page-break-inside: avoid;
on DIV
. To achieve what you need you should apply this attribute to paragraph. In your case you can use the following CSS:
h1 {
font-size: 30px;
color: #1094C8;
white-space: nowrap;
font-weight: 700;
page-break-after: avoid
}
1 Like
Hii Team,
Thank you.It’s working
1 Like
Hii Team,
Could you please clarify why that DIV is not working with “page-break-after: avoid” or “page-break-inside: avoid”. ???
@nethmi It does not work because difference in HTML DOM and Aspose.Words DOM. Aspose.Words is designed to work with MS Word documents.
There is no actual analog of DIV in MS Word document and both DIV
and P
like elements are imported as paragraphs. In your case paragraphs are inside DIV
and Aspose.Words ignores it upon importing content.
1 Like