I am unable to convert HTML with css for 2 column data into word using Aspose.word library
@ravibaburali Could you please attach the problematic HTML document here for testing? We will check the issue and provide you more information.
Hi Alexey Noskov.
Thanks for your response.
Here we are trying to convert this HTML to word (.docx).
Below is sample HTML(there are more tables in original requirement )
<html>
<head>
<style>
.nobreak {
break-inside: avoid;
}
.newspaper {
column-count: 2;
}
th, td {
border-color: #7F7F7F;
}
.section {
font-family: 'Arial';
font-size: 8pt;
font-weight: bold;
}
.p {
word-break: break-all;
white-space: normal;
}
.content8 {
font-family: 'Arial';
font-size: 8pt;
word-wrap: break-word";
}
.border-none {
border-collapse: collapse;
border: none;
}
.border-none td {
border: 1px solid black;
}
.border-none tr:first-child td {
border-top: none;
}
.border-none tr:last-child td {
border-bottom: none;
}
.border-none tr td:first-child {
border-left: none;
}
.border-none tr td:last-child {
border-right: none;
}
</style>
</head>
<body>
<div class="newspaper">
<table border='0' style="width:350px; table-layout:fixed" cellspacing="1" cellpadding="0">
<tr>
<td style="font-size:10pt; font-family:'Arial'">testing data<br /></td>
</tr>
<tr>
<td style="font-size:8pt; font-family:'Arial'"> </td>
</tr>
<tr>
<td>testing data </td>
</tr>
</table>
</div>
</body>
</html>
Thanks
Ravi babu
@ravibaburali I have checked your document and the result is expected. MS Word behaves the same way.ms.docx (12.5 KB)
aspose.docx (7.3 KB)
Sorry , I am not able to open the document .
Would like to know if this is possible to get HTML style in doc file?
Do you have any sample code if this is possible.
Your help is highly appreciated.
Thanks
Ravi babu
I could able to open the doc files from the site, can you please use the below sample with more data. It should come in two columns in word.
<html>
<head>
<style>
.nobreak {
break-inside: avoid;
}
.newspaper {
column-count: 2;
}
th, td {
border-color: #7F7F7F;
}
.section {
font-family: 'Arial';
font-size: 8pt;
font-weight: bold;
}
.p {
word-break: break-all;
white-space: normal;
}
.content8 {
font-family: 'Arial';
font-size: 8pt;
word-wrap: break-word";
}
.border-none {
border-collapse: collapse;
border: none;
}
.border-none td {
border: 1px solid black;
}
.border-none tr:first-child td {
border-top: none;
}
.border-none tr:last-child td {
border-bottom: none;
}
.border-none tr td:first-child {
border-left: none;
}
.border-none tr td:last-child {
border-right: none;
}
</style>
</head>
<body>
<div class="newspaper">
<div class="newspaper">
<table border='0' style="width:350px; table-layout:fixed" cellspacing="1" cellpadding="0">
<tr>
<td style="font-size:10pt; font-family:'Arial'">testing data<br /></td>
</tr>
<tr>
<td style="font-size:8pt; font-family:'Arial'"> </td>
</tr>
<tr>
<td>testing data -- This is para 1 testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1
<td>
</tr>
<tr>
<td>testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2</td>
</tr>
<tr>
<td>testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3</td>
</tr>
<tr>
<td>testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4</td>
</tr>
<tr>
<td>testing data This is para 5testing data This is para 5testing data This is para 5testing data This is para 5testing data This is para 5testing data This is para 5testing data This is para 5testing data This is para 5</td>
</tr>
<tr>
<td>testing data This is parta 6 testing data This is parta 6testing data This is parta 6testing data This is parta 6testing data This is parta 6testing data This is parta 6testing data This is parta 6</td>
</tr>
<tr>
<td>testing data This is para 7testing data This is para 7testing data This is para 7testing data This is para 7testing data This is para 7testing data This is para 7testing data This is para 7testing data This is para 7</td>
</tr>
<tr>
<td>testing data This is para 8testing data This is para 8testing data This is para 8testing data This is para 8testing data This is para 8testing data This is para 8testing data This is para 8testing data This is para 8testing data This is para 8testing data This is para 8testing data This is para 8</td>
</tr>
<tr>
<td>testing data This is para 9testing data This is para 9testing data This is para 9testing data This is para 9testing data This is para 9testing data This is para 9testing data This is para 9testing data This is para 9</td>
</tr>
<tr>
<td>testing data -- This is para 1 testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1
<td>
</tr>
<tr>
<td>testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2</td>
</tr>
<tr>
<td>testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3</td>
</tr>
<tr>
<td>testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4</td>
</tr>
<tr>
<td>testing data -- This is para 1 testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1testing data -- This is para 1
<td>
</tr>
<tr>
<td>testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2testing data -- This is para 2</td>
</tr>
<tr>
<td>testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3testing data -- This is para 3</td>
</tr>
<tr>
<td>testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4testing data -- This is para 4</td>
</tr>
</table>
</div>
</body>
</html>
Thanks
Ravi babu
@ravibaburali No, it does not. ms.docx (13.4 KB)
MS Word as well as Aspose.Words reads the document with one column. If you need your HTML document to be read as multicolumn document, you can set columns count after opening the document. For example see the following code:
Document doc = new Document(@"C:\Temp\in.html");
doc.FirstSection.PageSetup.TextColumns.SetCount(2);
doc.Save(@"C:\Temp\out.docx");
out.docx (7.7 KB)
Thanks a lot for your help, This helped me to move futher to continue with development.
One last thing is there any property to format in proper HTML (avioding spl chars like •).
HTML input :
<strong>DCM</strong>:
<br />• Advise RTL on invocation of the Business Recovery Plan and respective recovery strategy to implement <br />
<br />
<strong>RTL</strong>:
<br />• Establish and maintain communication to Divisional CMT in order to exchange information on nature of the incident and status
Word Ouput :
DCM :
• Advise RTL on invocation of the Business Recovery Plan and respective recovery strategy to implement
RTL:
• Inform recovery team members of invocation and initiate recovery of business processes
• Implement
@ravibaburali You can use <ul>
(unordered list) to get the desired output:
<strong>DCM</strong>:
<ul>
<li>Advise RTL on invocation of the Business Recovery Plan and respective recovery strategy to implement</li>
</ul>
<strong>RTL</strong>:
<ul>
<li>Establish and maintain communication to Divisional CMT in order to exchange information on nature of the incident and status</li>
</ul>
Or you can use escape code •
<strong>DCM</strong>:
<br />• Advise RTL on invocation of the Business Recovery Plan and respective recovery strategy to implement <br />
<br />
<strong>RTL</strong>:
<br />• Establish and maintain communication to Divisional CMT in order to exchange information on nature of the incident and status