- Where Developers Learn, Share, & Build Careers


I try to make a word document using this code:

  HttpContext. Current.Response Clear (); HttpContext.Current.Response.Charset = ""; HttpContext.Current.Response.ContentType = "App / Doctor"; HttpContext.Current.Response.AddHeader ("content-dispute", "attachment; file name =" + date time.Now + ".doc"); Var strHTMLContent = new stringbilder (); StrHTMLContent.Append ("& lt; h1 title = 'heading' align = 'center'style =' font-family: verdana; font-size: 80%; color: black '& gt; & lt; u & gt; document Title & lt; / u & gt; & lt; / h1 & gt; "); StrHTMLContent.Append ("& lt; br & gt;"); StrHTMLContent.Append ("& lt; Table alignment = 'center' & gt;"); // column headers with strhtmlcontent.Append ("& lt; tr & gt;"); StrHTMLContent.Append ("& lt; td style = 'width: 100px; background: # 99CC00' & gt; & lt; b & gt; column1 & lt; / b & gt; & lt; / td & gt; ); StrHTMLContent.Append ("& lt; td style = 'width: 100px; background: # 99CC00' & gt; & lt; b & gt; column2 & lt; / b & gt; & lt; / td & gt; ); StrHTMLContent.Append ("& lt; td style = 'width: 100px; background: # 99CC00' & gt; & lt; b & gt; column 3 & lt; / b & gt; & lt; / td & gt; ); StrHTMLContent.Append ("& lt; / tr & gt;"); // First line data strHTMLContent.Append ("& lt; tr & gt;"); StrHTMLContent.Append ("& lt; td style = 'width: 100px'> & lt; / td & gt;"); StrHTMLContent.Append ("& lt; td style = 'width: 100px' & gt; b ;); StrHTMLContent.Append ("& lt; td style = 'width: 100px'> c & lt; / td>"); StrHTMLContent.Append ("& lt; / tr & gt;"); // second line data strHTMLContent.Append ("& lt; tr & gt;"); StrHTMLContent.Append ("& lt; td style = 'width: 100px' & gt; D & lt; / td & gt;"); StrHTMLContent.Append ("& lt; td style = 'width: 100px'> E & lt; / td>"); StrHTMLContent.Append ("& lt; td style = 'width: 100px'> F "); StrHTMLContent.Append ("& lt; / tr & gt;"); StrHTMLContent.Append ("& lt; / table & gt;"); StrHTMLContent.Append ("& lt; br & gt; & lt; br & gt;"); StrHTMLContent.Append ("& lt; p align = 'center' & gt; NOTE: This is a dynamically generated word document & lt; / p & gt;"); HttpContext.Current.Response.Write (strHTMLContent); // HttpContext.Current.Response.BinaryWrite (strHTMLContent); HttpContext.Current.Response.End (); HttpContext.Current.Response.Flush ();   

Does anyone know how to convert this word document to a PDF file?

Since you are creating HTML to convert, so you can go from HTML to PDF You can use the API for:. ITextSharp is free.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -