Free Support Forum - aspose.com

Indentation problem with HTML table

Hi Alexey,

Thanks For your continous support & suggestions.

I am facing one problem while creating table with the help of HTML tags using documentBuilder.InsertHTML() method.

I am using Aspose.word version 7.0.0.0

While creating the table with the help of HTML tags i cannot be able to add left / right indent to it.

Is there any way by using which i will be able to add the left & right indent to my HTML formatted table?

The sample code is as follows.

private void button22_Click(object sender, EventArgs e)

{

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

//Initialize Aspose license.

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);

//set the page set-up

PageSetup pageSetup = documentBuilder.CurrentSection.PageSetup;

//go to document end.

documentBuilder.MoveToDocumentEnd();

//set the page size.

pageSetup.PaperSize = PaperSize.A4;

//apply margins for page.

pageSetup.LeftMargin = 75;

pageSetup.RightMargin = 75;

pageSetup.TopMargin = 75;

pageSetup.BottomMargin = 75;

string strSample = "The demolition of the Babri mosque was planned to the last detail and Justice M.S. Liberhan, who probed the matter, was told so, former BJP member of Parliament Ram Vilas Vedanti has said.Vedanti, one of the 68 people to be indicted by the Liberhan panel, said he supervised the demolition.Hang me if you can. I stick to my words,” Vedanti, also a member of the Ram Janambhoomi Nyaas, told a gathering at the local headquarters of the Vishwa Hindu Parishad. Saffron leaders were in Karsewakpuram to mark the 17th anniversary of the demolition.";

documentBuilder.InsertHtml(strSample);

documentBuilder.InsertParagraph();

documentBuilder.ParagraphFormat.LeftIndent = 20;

string strHTMLTable = "

This is a cell This is a cell
This is the new row I'm on the new row, too!
Row with image
";

documentBuilder.InsertHtml(strHTMLTable);

doc.Save("sample.doc");

StartWord("sample.doc");

}

Please refer the attached Word document for further reference.

If you go though the attached document & sample code carefully you will find that there is page margin implemented for entire page. Which also get applied for table object.

I want to add left indent to my HTML formatted table so that my total table margin from origional page is

total mrgin = page margin + table left indent.

this indent value is given by user

I dont want my table directly get aligned to left,right or central.

1> Is there any way by which i will be able to achive above mentioned functionality?

2> Is there any HTML tag that will help us to add the indentation while creating HTML table ?

Waiting for your reply.....!!!!!

Thanks & Regards,

Dwarika

Hi Dwarika,

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

Thanks for your inquiry. There is no way to specify left indent of a table in HTML at the moment. The only way to work this problem around, I can suggest you at the moments, is post-processing of your document after inserting HTML.

Best regards

Hi Alexey,

Thanks for your suggestion & support

Will you please send me a sample code for further reference?

Is there any trick or workaround that will help me to decide the position of the table while inserting table suing HTML tags.(for eg. any combination of HTML tags)?

Thanks & regards,

Dwarika.

Hi Dwarika,

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

Thanks for your inquiry. You can find a simple example in the following forum thread:

http://www.aspose.com/community/forums/post/207790/problem-in-paragraph-formatting-while-using-html-tags.aspx

The code provided there is used to reset formatting of paragraphs upon inserting HTML, but you can use the same technique to change formatting of tables.

As I mentioned earlier, currently there is no way to specify left indent of a table in HTML.

Best regards.