Word table to html table conversion

When we convert word to html, the table html elements <table><td> has width and heights. Is there any way we have <table><td> without width and heights?

@tech.purchases You can reset width of cell before saving document to HTML:

Document doc = new Document(@"C:\Temp\in.docx");

foreach (Table t in doc.GetChildNodes(NodeType.Table, true))
{
    foreach (Row r in t.Rows)
    {
        foreach (Cell c in r.Cells)
            c.CellFormat.Width = 0;
    }
}

HtmlSaveOptions opt = new HtmlSaveOptions();
opt.PrettyFormat = true;

doc.Save(@"C:\Temp\out.html", opt);

Thank you for quick reply.

Below is my code. where will the above solution fit? please help.

WordsApi wordsApi = new WordsApi(App.AppSid,App.AppKey);

var stream = this.GetFileStream(this.Request);

ConvertDocumentRequest convertDocumentRequest = new ConvertDocumentRequest(stream, format);
Stream outputStream = wordsApi.ConvertDocument(convertDocumentRequest);

//RETURN html as string
byte[] buffer = new byte[outputStream.Length];
outputStream.Read(buffer, 0, (int)outputStream.Length);

@tech.purchases You are using Aspose.Words Cloud API. I will move your request into the appropriate forum. My colleagues from the Cloud team will help you shortly.

Below converted html has table and cell width. Is there a way we have table as width: 100% and no height and width for td??

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse:collapse; width:401.25pt">

<td style="border-bottom-style:solid; border-bottom-width:0.75pt; border-right-style:solid; border-right-width:0.75pt; border-top-style:solid; border-top-width:0.75pt; height:32.85pt; vertical-align:middle; width:64.6pt"><p style="text-align:center"><span>July 10, 2023</span></p></td>

@tech.purchases

Please try the SaveAs method using the HtmlSaveOptionsData method as follows. Hopefully, it will help you accomplish the task.

var wordsApi = new WordsApi("xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxx");
var request = new SaveAsRequest();
request.Name = "Table.docx";
request.SaveOptionsData = new HtmlSaveOptionsData()
{
    TableWidthOutputMode = HtmlSaveOptionsData.TableWidthOutputModeEnum.None,
    FileName = "Table.html",
    ZipOutput = true
};
await wordsApi.SaveAs(request);

Thank you for your reply. We do not store file in storage. Is there any way to use SaveAs Request api to accept streams like we used to do using wordsApi.ConvertDocument method? Also please suggest if the same HtmlSaveOptions can be used using wordsApi.ConvertDocument method.

@tech.purchases

Yes, you may try the online version of the SaveAs API method as follows. The Online versions do not use cloud storage for file processing.

var wordsApi = new WordsApi("xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxx");
var request = new SaveAsOnlineRequest();
request.Document = File.OpenRead("Table.TableStyle.docx");
request.SaveOptionsData = new HtmlSaveOptionsData()
{
    TableWidthOutputMode = HtmlSaveOptionsData.TableWidthOutputModeEnum.None,
    FileName = "tabletest.html",
    ZipOutput = true
};
await wordsApi.SaveAsOnline(request);