Free Support Forum - aspose.com

Style property background-image

Hello. Does anybody know how to solve a problem that HTML containing table cells with set up background-image style property is converted to DOC format incorreectly. Another words image on background is simply not implemented. Certainly, firstly I checked the HTML in few browsers and there were all right. The C# code I used to generate doc is shown below.

(new Aspose.Words.License()).SetLicense(“Aspose.Custom.lic”);

Document document = new Document();
DocumentBuilder builder = new DocumentBuilder(document);
Aspose.Words.PageSetup pageSetup = builder.PageSetup;
pageSetup.Orientation = Aspose.Words.Orientation.Landscape;

builder.InsertParagraph();
builder.InsertHtml(Resource1.html1); // Resource1.html1 contains HTML I have attached

document.Save(“D:\test.doc”, SaveFormat.Doc);

Hi

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

Thanks for your request. The problem is that HTML and MS Word formats are very different formats. Some features available in HTML are not available in MS Word and vice versa. That is why it is difficult and barely impossible to convert HTML to DOC and vice versa without loses.

In your case, HTML allows specifying image as background of table cell, but in MS Word there is no such feature. In MS Word there is no direct way to achieve this. Of course, you can just insert an image behind text, but this will not be background of table cell.

You should also note that even MS Word does not import background image of table cell from HTML.

Best regards.

Alexey, thank you very much for quick and comprehensive answer.

Related to the mentioned problem I have decided to place tag in the table cell instead of the implementation of background-image style property. I met another challenge: my table has paddings anywhere. When I place tag inside of the table cell I do not need any padding of this cell. I only wish my image (texture) took all the area of the cell. When I try to remove padding from the cell I saw discrepancy between column borders. I attached two screenshots: normal displaying in browser and incorrect conversion in MSWord. Also I attached file with markup.

How can I acquire wished texture of the table cell without problems?

Hi

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

Thank you for additional information. May I know what you would like to achieve? Maybe there is more simple way to do so. Maybe you can achieve what you need without using HTML.

Best regards.

Unfortunately, I can not give up from using HTML because I need to make a small but very essential correction to the system of report generation in large project. All reports that are built there are based on HTML markup.


I only wish to change one thing (look at attachments on my previous comment and you will understand) - impose texture on cells of the first column. Initially they only have background color, now I want to add a texture.

I have solved ny problem. Made some changes in mark up. Alexey, thank you for responses

Hi

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

It is perfect that you found a way to work this problem around.

Best regards