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

Free Support Forum - aspose.com

Different output in word format and in browser

Hello Team,


We are using Aspose.Words 9.0 to render reports in word as well as in browser.

We are using insertHTML() method to output text in word document.

Both the output differ as far as the following points are concerned,

1. Border of the table used is different in word and browser output.
2. Images in column 1 are center aligned in browser output but not in word output.
3. Text in column 2 is center aligned in browser output but not in word output.
4. Last two images in column 1 are visible in browser output but not in word output.

Attached

1. Word Output "Output in Word Document.doc"
2. Browser Output "Output in browser.PNG"
3. HTML string "html.txt"

Regards,
Dwarika


here is the sample code through which you can easily re-produce this issue.

string path = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

//Initialize Aspose license. Aspose Word version 9.0.0.0
Aspose.Words.License lic = new Aspose.Words.License();
lic.SetLicense(path + @"\Aspose.Total.lic");
Aspose.Pdf.License lic1 = new Aspose.Pdf.License();
lic1.SetLicense(path + @"\Aspose.Total.lic");

Document doc = new Document();
DocumentBuilder documentBuilder = new DocumentBuilder(doc);
Run run;
Aspose.Words.Font font;

//set the page set-up
PageSetup pageSetup = documentBuilder.CurrentSection.PageSetup;
pageSetup.PaperSize = PaperSize.A4; //set the page size.

documentBuilder.ParagraphFormat.ClearFormatting();
//set font
run = new Run(doc);
font = run.Font;

documentBuilder.InsertHtml("<Table border=1 style=‘border-collapse: collapse’; BORDERCOLOR=#000000; width=‘100%’ align=Left cellspacing=‘0’ cellpadding=4> Band"+
Interpretation Likely Impacts (for work in general)
”+
üü
”+
Low Risk A low risk candidate is likely to have a strong fit”+
“to jobs where step-by-step procedures, team working and strict working hours are important
”+
ü
Moderate to Low Risk”+
A moderate to low risk candidate is likely to have a reasonable fit to jobs where step-by-step procedures, team working and strict working hours are important ”+
Moderate Risk”+
A moderate risk candidate is likely to have a moderate fit to jobs where step-by-step procedures, team working and strict working hours are important
”+
High Risk”+
“A high risk candidate is likely to have a weak fit to jobs where step-by-step procedures, team working and strict working hours are important
”+
”+
Very High Risk
A very high risk candidate is likely to have a very weak fit to jobs where step-by-step procedures, team working and strict working hours are important ”);


doc.Save(“HTMLBulletTest.doc”);
StartWord(“HTMLBulletTest.doc”);

Hi Dwarika,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry.

1. The problem with borders occurs because your HTML is corrupted. Here is table definition from your HTML:

<Table border=1 style="border-collapse: collapse"; BORDERCOLOR=#000000; width=""100%"" align=Left cellspacing=""0"" cellpadding=4>

I highlighted places where this snippet is corrupted. Here is how this definition should look:

<Table border="1" style="border-collapse: collapse; border-color:#000000;" width="100%" align="left" cellspacing="0" cellpadding="4">

2. Use align attribute instead of style.text-aligh. Please see the following HTML snippet:

<td width=""20%"" bgcolor=#008A00 align="center">

3. This is the same issue as previous.

4. I cannot reproduce this problem.

Best regards.

Hello alexey,


Thanks very much for your quick reply.
I would like clear the doubts around this issue.

1. The problem with borders occurs because your HTML is corrupted. Here is table definition from your HTML:

Dwarika: HTML is not corrupted. This is because of we have pasted the HTML contents from the Web Page direct to Notepad. Also if you take a look at the sample code i have provided, then you will see that there are no duplicate “” “” signs used in the string which is provided to documentBuilder.InsertHTML() method.

Also if you take a look at Browser output table borders are flat, very thin black line. If same is observed using Word output table borders are wide, grey in color and somewhat projected. I hope now it is clear about the problem around the borders now.

2. Use align attribute instead of style.text-aligh. Please see the following HTML snippet:
3. This is the same issue as previous.

Dwarika: Are you suggesting a work around to use align attribute and not style.text-align? If yes, then is this because Aspose does not support the later tag (style.text-align) when used in formatting. Please confirm.

4. I cannot reproduce this problem.

Dwarika: Please take a look at “HTMLBulletTest.doc”. This is still re-producible with the sample code i have provided. This attachment is the direct output of the sample code. Please open the attachment and observe the forth row and first column to see “x” is not appearing, the fifth row and first column to see “x x” is not appearing in the document printed.

We are facing this issue while printing the content in word document. And i have also stated that we are using Aspose.Words 9.0; in which version of Aspose you have verified this issue?

Regards,
Dwarika



Hi Dwarika,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information.

1. Duplicated double quotes is only part of the problem.

<Table border=1 style="border-collapse: collapse"; BORDERCOLOR=#000000; width="100%" align=Left cellspacing="0" cellpadding=4>

Here is highlighted more serious problem. First of all there is no BORDERCOLOR attribute. There should be border-color attribute defined within style as shown below:

<Table border="1" style="border-collapse: collapse; border-color:#000000;" width="100%" align="left" cellspacing="0" cellpadding="4">

After this modification table borders looks correctly in Word document. So I still think your HTML is corrupted.

2,3. Yes, please use align attribute.

4. Still do not see any problems here. I attached screenshot where you can see that no data is missed in the first column.

We always check with the latest version. There is no sense to check with old versions.

Best regards,

Hello alexey,


Thanks very much for your suggestion.

Point 1,2, and 3 are resolved after making changes as suggested by you.

Still i have queries related to point 4.

1. In which version of Aspose.Words you are verifying this issue?
2. From the screen shot it is visible you are using MS Word 2007. Is it correct?

We are using MS Word 2003 to print the document in Word Format. Is this the reason we are not getting last two rows with expected images.

If you could verify this with MS Word 2003 and let us know your inputs then that will be very helpful to us.

Attached is the latest Word document after doing changes as suggested by you. This document still shows the error in rendering last two images in first column.

Regards,
Dwarika

Hi Dwarika,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I am still unable to reproduce the problem on my side, but I have one idea why this might occur. Please try using the following HTML:

<span style="font-family: wingdings; font-size: 80%; color: #FFFFFF;">û</span>

Instead of:

<span style="font-family: Verdana; font-size: 80%; color: #FFFFFF;"></span>

Hope this helps.

Best regards.

Hi Dwarika,

I was facing the similar issue and for resolution I have used

<span style="font-family: MS Mincho; font-size: 80%; color: #FFFFFF;"></span>

instead of :

<span style="font-family: Verdana; font-size: 80%; color: #FFFFFF;"></span>

After changing the font we don't need to change the HTML character code (✘) to any other character code.

Regards,

Prakash Raj

Dell services

Hi Raj,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing your experience.

Best regards,