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

Free Support Forum - aspose.com

Providing Autofit property to table

Hi there,

Some of the tables in my document are extending outside of the page, So i used the following statements to fit tables which are extending outside of page.

MainDocument.CompatibilityOptions.GrowAutofit = true; (OR)

DocumentBuilder buil = new DocumentBuilder(MainDocument);

RowFormat rf = buil.RowFormat;

rf.AllowAutoFit = true;

But, Unfortunately above two techniques are not working for me, could you please help me out to fit the tables in the width of page which are extending outside only…

following HTML content to create the table in document. Could u pls suggest on this?.

First Table to fit in Word.

dfdsfsdfsdfsdfsdfsd
i hate u
sdfsdfsdfsdfdsdfsdfd sdfsdfdsfsdfsdfsdfsd sdfsdfsdfsdfsdeeeeeeeeeeeeeeee 55555555555555555555555555555555555555555555 fffffffffffffffffffffffffffffffffffffffffffffffffffffff
blank data no data by srimadhav

Thanks,

Hi

Thanks for your inquiry. You can try specifying table width in percents in your HTML. For example se the following code:

string html = "

First Table to fit in Word.

"

+ "

"

+ " "

+ "

dfdsfsdfsdfsdfsdfsd
i hate u"

+ "

sdfsdfsdfsdfdsdfsdfd"

+ "

sdfsdfdsfsdfsdfsdfsd "

+ "

sdfsdfsdfsdfsdeeeeeeeeeeeeeeee "

+ "

55555555555555555555555555555555555555555555"

+ "

fffffffffffffffffffffffffffffffffffffffffffffffffffffff "

+ " blank data "

+ "

no data by srimadhav

";

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.InsertHtml(html);

doc.Save(@“Test001\out.doc”);

But you should note, that in this particular example 100% width will not work, because text in your HTML table cannot be wrapped. So the table occurs wider than needed.

Best regards.

Hi Alexey,

Thanks for your response, but unfortunately i didn’t know how many tables in html, this HTML string is coming from database.

Is there any way to set autowidth property for tables by grabing all tables in document like,

foreach (Section sect in MainDocument.Sections)

{

foreach (Node node in sect.Body.ChildNodes)

{

if (node.NodeType == NodeType.Table)

{

Table tab = (Table)node;

if (tab.Rows.Count > 1)

{

tab.Rows[0].RowFormat.HeadingFormat = true;

tab.Rows[0].RowFormat.AllowAutoFit=true; // Shall we do anything here to fit table?

}

}

}

}

Thanks,

Hi Srinu,

Thanks for your inquiry. Unfortunately, there is no way to specify width of the table using Aspsoe.Words. Also, you cannot specify “Fit to Content” or “Fit to Window” options. I linked your request to the appropriate issue, you will be notified as soon as it is resolved.

Best regards.

Hi

I am also missing the “Fit to Window” option for one of my upcoming projects.

Is it possible for you to estimate when the issue will be resolved, as this means a lot for my buing decision related to Aspose.Words?

Nikolaj

Hi

Thanks for your inquiry. Unfortunately, it is difficult to provide you a reliable estimate regarding this issue. I will notify you as soon as this feature is available. Hopefully, we will add this functionality somewhere in the first half of the next year. But I cannot promise you anything at the current stage.

Best regards.

The issues you have found earlier (filed as WORDSNET-581) have been fixed in this .NET update and in this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(82)