locked
Microsoft Word Page Margins RRS feed

  • Question

  • User-1731144759 posted

    Hi I am using the following code to display a table in Microsoft word.  Is there anyway to set the page margins of the document? 

    string style = "<style> @page{ margin:.5in .75in .5in .75in;}</style> ";

    //SWE.ContactManager.Utilities.ContactListToWord ml = new SWE.ContactManager.Utilities.ContactListToWord();

    SWE.Candidates.CustomReports.RankingForm rf = new SWE.Candidates.CustomReports.RankingForm();Table t = rf.CreateForm();

    Response.Clear();

    Response.AddHeader("content-disposition", "attachment;filename=RankingForm" + DateTime.Now.ToString("MM_dd_yy") + ".doc");

    Response.Charset = "";

    Response.Cache.SetCacheability(HttpCacheability.NoCache);

    Response.AppendHeader("Content-Type", "application/msword");

    StringWriter stringWrite = new StringWriter();

    HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

    t.RenderControl(htmlWrite);

    Response.Write(style);

    Response.Write(stringWrite.ToString());

    Response.End();

    Tuesday, May 19, 2009 7:00 PM

All replies