Click here to Skip to main content
15,894,955 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello friends,
I'm trying to dynamically generate doc file and I' m able to do it so. Problem is that i want to add page no in footer the doc file.
Any idea, how to do it. . ??

VB
Response.AddHeader("content-disposition", "attachment;filename=" & FileName & "")
           Response.Charset = ""
           Response.Cache.SetCacheability(HttpCacheability.NoCache)
           Response.ContentType = "application/msword"
           Dim ioWriter As New System.IO.StringWriter()
           Dim htmlWriter As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(ioWriter)
<pre lang="msil">Dim strDocBody As String
               strDocBody = "<html " + "xmlns:o='urn:schemas-microsoft-com:office:office' " + "xmlns:w='urn:schemas-microsoft-com:office:word'" + "xmlns='http://www.w3.org/TR/REC-html40'>" + "<head>" + "<title>Dynamic Generated Document</title>"

               strDocBody = strDocBody + "<!--[if gte mso 9]>" + "<xml>" + "<w:WordDocument>" + "<w:View>Print</w:View>" + "<w:Zoom>100</w:Zoom>" + "<w:DoNotOptimizeForBrowser/>" + "</w:WordDocument>" + "</xml>" + "<![endif]-->"
               strDocBody = strDocBody + "<style> @page" + "{size:8.5in 11.0in; mso-first-footer:ff1; mso-footer: f1; mso-header: h1; padding:24.0pt 24.0pt 24.0pt 24.0pt;" + " margin:0.75in 0.75in 0.5in 1in ; " + " mso-header-margin:.5in; " + " mso-footer-margin:.5in; mso-paper-source:0; mso-header:url('" + strheaderfooterpath + "') h1; mso-footer:url('" + strheaderfooterpath + "') f1;}" + " div.Section1" + " {page:Section1;}" + "p.MsoFooter, li.MsoFooter, div.MsoFooter{margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:'Arial';}" + "p.MsoHeader, li.MsoHeader, div.MsoHeader {margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:'Verdana';}" + "-->" + "</style>" + "</head>"
               'strBody.Append("<body lang=EN-US style='tab-interval:.5in'>" & _
               '                  "<div class=Section1>")
               strDocBody = strDocBody + "<body lang=EN-US style='tab-interval:.5in'>" + "<div class=Section1>" + "" + "" + "" + "" + "" + "" + "<!--[if supportFields]>" + "<div style='mso-element:header' id=h1><p class=MsoHeader></p></div>" + "<div style='mso-element:footer' id=f1> " + "<p class=MsoFooter style='border:none;padding:0in;mso-padding-alt:0in 0in 1.0pt 0in'><o:p> </o:p></p> " + " " + " " + " </p></div><![endif]-->" + "</div>"

               strMessage.AppendLine(strDocBody)
               strMessage.AppendLine("<form >")
.
.
.
strMessage.AppendLine("</form>")
<pre lang="vb">strMessage.AppendLine("</body>")
               strMessage.AppendLine("</html>")
               htmlWriter.Write(strMessage.ToString())
               Response.Write(ioWriter.ToString())
               Response.[End]()



Posted
Comments
dhage.prashant01 15-Apr-11 6:21am    
No help??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900