We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to maintain formatting while inserting html to Word document?

Hi Team,

We are inserting html to word document using below code.

builder.insertHtml(html);

where html is a string that contains the attached inputhtml data ,attached is the Output file generated and expected.

Issue is ::: The formatting of the text in the word doc does not match the input html.

Please confirm – Is builder.insertHtml() method of aspose java does support maintaining the format of html while converting to word document ?
Is it possible to have same formatting in word document as that in html ,what is the possible way of doing that?

Thanks
Sonam Arora

Hi Sonam,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. In your scenario, Aspose.Words does not generate the expected output for bullets. I have attached the output document and expected output document with this post for your kind reference. Please confirm that you want the same output as shared in Expected.docx.

For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-10342. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

Hi Tahir,
I am rendering wordfile from html.The html is taken from ckeditor and is using padding-top which displays distance of line from top.In my html I am setting padding top differently for each line so as to maintain difference between lines.But the difference in lines is not visible in word file.

PFA the input html,source code,and output generated.
Kindly suggest is aspose not able to handle padding-top/padding-bottom from html??



Will appreciate for soon reply as its quite urgent.
Thanks in advance

Regards
Sonam

Hi Tahir,
The same issue is there with margin tag.Please resolve it as soon as possible.

Thanks
Sonam

Hi Tahir,

In Short,
The aspose is able to handle padding-left from CKEditor but not padding-top and margin tags.
Please assist on this.


Thanks
Sonam

Hi Sonam,

Thanks for your inquiry. Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.

Hi Tahir,

Attached the files with their description and standalone code.

InputHtml-1st ---->Input html taken text editor like ckeditor and converted to aspose file that generated the Output Word File --output_1st. InputHtml have padding-left tag for aligning the text and bullets.


InputHtml-2nd – >Input html taken text editor like ckeditor and converted to aspose file that generated the Output Word File --output_2nd_Actual.However it should generates the output_2nd_Expected as I have added padding-top in InputHtml-2nd file.

padding top in InputHtml should create some difference in OutputFile generated.But its not affecting the word file.
Added the standalone code too.

Please assist on this.

Thanks
Sonam


Hi Sonam,

Thanks for your inquiry.

Regarding padding-left issue, I have managed to reproduce the same issue
at my side. For the sake of correction, I have logged this problem in
our issue tracking system as WORDSNET-10393. I have linked this forum
thread to the same issue and you will be notified via this forum thread
once this issue is resolved. We apologize for your inconvenience.

Regarding padding-top issue, please note that Aspose.Words mimics the same behavior as MS Word does. If you convert your HTML to Docx using MS Word, you will get the same output.


Hi Tahir,

For sake of correction here.Just to notify you aspose mimics behaviour in case of padding-left ,but not in case of padding-top.Please clarify.

Thanks
Sonam

If aspose is not able to understand padding-top ,is there any other tag from ckeditor that aspose can understand to handle spacing between lines.
As padding-bottom the other alternative I am trying also is not recognizable by Aspose.
Please assist.


Thanks
Sonam Arora

Hi Sonam,

Please check the attached image (LeftPaddingIssue.png) for issue WORDSNET-10393.

Regarding padding-top issue, please open your input html in MS Word and check the top padding. See the MSWord-Behaviour.png for detail.

Hi Tahir,
Thanks for the response .
But,I am not sure where my issue is going.
Well in just a simple words ::
padding-top a tag from text editor like CKEditor when used in html and this html is saved as word document.Watever value i give to padding-top these are not getting reflected in word file saved through aspose code.
Kindly assist.

Thanks
Sonam

Hi Sonam,

Thanks for your inquiry. As I shared earlier, Aspose.Words mimics the same behavior as MS Word does. Please open the attached html in MS Word and check the top padding of list items. There is no top padding in Word document.

However, I have logged this problem in our issue tracking system as WORDSNET-10417.
Our development team will check the possibilities of the fix of this issue. I have linked this forum thread to the same issue and you will be
notified via this forum thread once this issue is resolved. We apologize
for your inconvenience.

Hi Tahir,

Thanks for update Will wait for next update.

Thanks
Sonam

Hi Sonam,

Thanks for your patience.

Regarding padding-left issue, It is to inform you that our development team has completed the work on the issue (WORDSNET-10393) and has come to a conclusion that this issue and the undesired behavior you're observing is actually not a bug in Aspose.Words. So, we have closed this issue as 'Not a Bug'. Aspose.Words shows the same output in Word document as input html is shown in browser.

Regarding padding-top issue (WORDSNET-10417), this is a bug in Aspose.Words and we will update you via this forum thread once this issue is resolved.

Hi Sonam,

Thanks for your patience. The issue WORDSNET-10342 duplicates WORDSNET-10393. So, we have closed this issue as 'Not a Bug'.

Hopefully, the fix of WORDSNET-10417 (padding-top issue) will be available in August 2014 release. We will inform you via this forum thread once this issue is resolved.